:root {
  --paper: #f5f7fa;
  --surface: #ffffff;
  --ink: #10233f;
  --muted: #667287;
  --line: #dce2e9;
  --orange: #ff5c35;
  --orange-dark: #d94322;
  --blue: #2357d8;
  --soft-blue: #eaf0ff;
  --success: #1e8b5b;
  --shadow: 0 22px 60px rgba(25, 47, 77, 0.1);
  --radius: 22px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  overflow-x: hidden;
  color: var(--ink);
  background:
    radial-gradient(circle at 82% 9%, rgba(35, 87, 216, 0.08), transparent 24rem),
    linear-gradient(rgba(16, 35, 63, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(16, 35, 63, 0.025) 1px, transparent 1px),
    var(--paper);
  background-size: auto, 28px 28px, 28px 28px, auto;
  font-family: "Segoe UI Variable", "Microsoft YaHei UI", "PingFang SC", sans-serif;
  min-height: 100vh;
}
button, textarea, input { font: inherit; }
button { color: inherit; }
.page-shell { width: calc(100% - 40px); max-width: 1180px; margin: 0 auto; }
.topbar { height: 84px; display: flex; align-items: center; justify-content: space-between; }
.brand { display: inline-flex; gap: 11px; align-items: center; color: var(--ink); text-decoration: none; font-weight: 800; letter-spacing: -0.03em; font-size: 19px; }
.brand-mark { width: 31px; height: 31px; border: 2px solid var(--ink); border-radius: 9px; position: relative; display: inline-block; transform: rotate(-2deg); }
.brand-mark i { position: absolute; height: 3px; border-radius: 2px; background: var(--orange); left: 6px; }
.brand-mark i:first-child { width: 16px; top: 9px; }
.brand-mark i:last-child { width: 10px; top: 16px; }
.network-state { display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: 13px; font-weight: 650; }
.pulse { width: 9px; height: 9px; background: var(--success); border-radius: 50%; box-shadow: 0 0 0 5px rgba(30, 139, 91, 0.12); }
.security-alert { margin: 0 0 16px; padding: 13px 16px; border: 1px solid #e9a28f; border-radius: 12px; background: #fff2ed; color: #9b2f18; font-size: 13px; line-height: 1.6; }
.security-alert[hidden] { display: none; }
.hero { min-height: 480px; padding: 58px 6% 52px; display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 8%; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: 30px; box-shadow: var(--shadow); position: relative; overflow: hidden; }
.hero::after { content: ""; position: absolute; right: -100px; bottom: -170px; width: 420px; height: 420px; border: 1px solid rgba(35, 87, 216, 0.15); border-radius: 50%; box-shadow: 0 0 0 42px rgba(35, 87, 216, 0.025), 0 0 0 84px rgba(35, 87, 216, 0.02); pointer-events: none; }
.hero-copy, .qr-card { position: relative; z-index: 1; min-width: 0; }
.eyebrow, .panel-kicker { margin: 0 0 10px; color: var(--blue); text-transform: uppercase; font-family: "Cascadia Mono", "SFMono-Regular", monospace; letter-spacing: 0.13em; font-weight: 700; font-size: 12px; }
h1 { margin: 0; font-family: "Arial Narrow", "Bahnschrift Condensed", "Microsoft YaHei UI", sans-serif; font-size: clamp(54px, 7vw, 92px); line-height: 0.94; letter-spacing: -0.065em; font-weight: 850; max-width: 700px; overflow-wrap: anywhere; }
h1 em { color: var(--orange); font-style: normal; }
.lead { max-width: 620px; margin: 28px 0 30px; color: var(--muted); line-height: 1.8; font-size: 16px; }
.signal-route { display: flex; align-items: center; width: min(390px, 100%); }
.device-icon { display: block; border: 2px solid var(--ink); position: relative; background: white; }
.desktop-icon { width: 38px; height: 25px; border-radius: 3px; }
.desktop-icon::after { content: ""; position: absolute; width: 17px; height: 2px; background: var(--ink); left: 8px; bottom: -7px; box-shadow: 0 4px 0 -0.5px var(--ink); }
.phone-icon { width: 18px; height: 30px; border-radius: 4px; }
.route-line { height: 1px; flex: 1; background: repeating-linear-gradient(90deg, var(--line) 0 6px, transparent 6px 12px); margin: 0 16px; position: relative; }
.route-line i { position: absolute; top: -4px; left: 0; width: 9px; height: 9px; background: var(--orange); border-radius: 50%; animation: travel 2.8s ease-in-out infinite; }
@keyframes travel { 0% { left: 0; } 50% { left: calc(100% - 9px); } 100% { left: 0; } }
.qr-card { padding: 18px 18px 20px; background: #f9fbff; border: 1px solid var(--line); border-radius: 20px; transform: rotate(1.1deg); }
.qr-heading { display: flex; justify-content: space-between; align-items: center; font-weight: 800; font-size: 14px; }
.secure-tag { padding: 5px 8px; color: var(--success); background: rgba(30, 139, 91, 0.1); border-radius: 999px; font-size: 10px; letter-spacing: 0.04em; }
.qr-wrap { margin: 15px 0; aspect-ratio: 1; border-radius: 12px; background: white; display: grid; place-items: center; border: 1px solid #edf0f4; overflow: hidden; }
.qr-wrap canvas { width: 90% !important; height: 90% !important; object-fit: contain; }
.qr-card p { margin: 0 0 11px; color: var(--muted); font-size: 12px; text-align: center; }
.text-button { width: 100%; border: 0; background: transparent; color: var(--blue); font-size: 12px; font-weight: 750; cursor: pointer; padding: 7px; }
.workbench { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 20px; }
.device-memory { margin-top: 20px; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px; }
.device-memory h2 { font-size: 20px; }
.device-memory p { margin: 8px 0 0; font-size: 13px; color: var(--muted); line-height: 1.7; }
.device-memory-controls { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.device-memory-controls label { font-size: 13px; }
.device-memory-controls select { font: inherit; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); color: var(--ink); background: white; }
.device-memory .device-memory-hint { flex-basis: 100%; font-size: 12px; margin: 0; }
.panel { min-width: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 28px; }
.panel-title, .section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.panel h2, .section-heading h2 { margin: 0; font-size: 26px; letter-spacing: -0.04em; }
.limit, .counter { font-family: "Cascadia Mono", monospace; color: var(--muted); font-size: 11px; padding-top: 8px; }
.dropzone { min-height: 205px; margin-top: 23px; border: 1.5px dashed #aeb9c8; border-radius: 16px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; cursor: pointer; transition: border-color .2s, background .2s, transform .2s; }
.dropzone:hover, .dropzone.is-dragging { border-color: var(--orange); background: #fff8f5; transform: translateY(-2px); }
.dropzone.is-disabled { opacity: .55; pointer-events: none; }
.dropzone input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.drop-symbol { font-family: "Cascadia Mono", monospace; font-size: 33px; color: var(--orange); margin-bottom: 12px; }
.dropzone strong { font-size: 15px; }
.dropzone small { margin-top: 8px; color: var(--muted); }
.upload-queue:empty { display: none; }
.upload-queue { margin-top: 15px; padding: 12px 14px; background: var(--soft-blue); border-radius: 12px; font-size: 12px; }
.progress-track { height: 5px; background: rgba(35, 87, 216, 0.13); border-radius: 99px; margin-top: 9px; overflow: hidden; }
.progress-fill { height: 100%; width: 0; background: var(--blue); transition: width .18s; }
.note-panel textarea { width: 100%; min-height: 205px; resize: vertical; margin-top: 23px; padding: 18px; color: var(--ink); background: #f9fafc; border: 1px solid var(--line); border-radius: 16px; outline: none; line-height: 1.7; }
.note-panel textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 4px rgba(35, 87, 216, 0.1); }
.note-actions { display: flex; align-items: center; justify-content: space-between; gap: 15px; margin-top: 13px; }
.note-actions span { color: var(--muted); font-size: 11px; }
.primary-button { border: 0; border-radius: 11px; padding: 12px 19px; background: var(--ink); color: white; font-weight: 750; cursor: pointer; box-shadow: 0 8px 18px rgba(16, 35, 63, 0.15); }
.primary-button:hover { background: var(--blue); }
.primary-button:disabled { opacity: .55; cursor: wait; }
.shelf-section { margin: 20px 0 70px; padding: 34px; border: 1px solid var(--line); border-radius: var(--radius); background: rgba(255, 255, 255, 0.72); backdrop-filter: blur(12px); }
.icon-button { width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line); background: white; cursor: pointer; font-size: 20px; }
.content-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 30px; margin-top: 30px; }
.content-column { min-width: 0; }
.content-column h3 { margin: 0 0 12px; font-size: 13px; letter-spacing: .02em; }
.content-column h3 span { display: inline-grid; place-items: center; min-width: 22px; height: 22px; margin-left: 6px; color: var(--muted); background: #edf1f6; border-radius: 99px; font-size: 10px; }
.item-list { display: grid; gap: 10px; }
.empty-state { min-height: 132px; border: 1px dashed var(--line); border-radius: 15px; display: grid; place-items: center; color: var(--muted); text-align: center; font-size: 13px; line-height: 1.6; padding: 24px; }
.file-item, .message-item { background: white; border: 1px solid var(--line); border-radius: 15px; overflow: hidden; }
.file-item { display: grid; grid-template-columns: 58px minmax(0, 1fr) auto; align-items: center; gap: 13px; padding: 11px; }
.file-download-hint { margin: 10px 4px 0; color: var(--muted); font-size: 11px; line-height: 1.6; }
.file-thumb { width: 58px; height: 58px; border-radius: 11px; background: var(--soft-blue); display: grid; place-items: center; color: var(--blue); font-family: "Cascadia Mono", monospace; font-size: 11px; font-weight: 750; overflow: hidden; }
.file-thumb img { width: 100%; height: 100%; object-fit: cover; }
.item-main { min-width: 0; }
.item-name { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; font-weight: 750; }
.item-meta { display: block; margin-top: 5px; color: var(--muted); font-size: 10px; }
.item-actions { display: flex; gap: 5px; }
.action-button { border: 0; border-radius: 9px; padding: 8px 10px; background: #f0f3f7; color: var(--ink); text-decoration: none; font-size: 11px; font-weight: 750; cursor: pointer; }
.action-button:hover { background: var(--soft-blue); color: var(--blue); }
.action-button:disabled { opacity: .45; cursor: not-allowed; }
.delete-button:hover { background: #fff0ed; color: var(--orange-dark); }
.message-item { padding: 16px; }
.message-copy { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 13px; line-height: 1.65; max-height: 170px; overflow: auto; }
.message-footer { display: flex; justify-content: space-between; align-items: center; margin-top: 13px; color: var(--muted); font-size: 10px; }
.message-footer button { border: 0; background: transparent; color: var(--blue); font-size: 11px; font-weight: 750; cursor: pointer; }
.message-footer-actions { display: flex; gap: 10px; }
.message-footer button:disabled { opacity: .45; cursor: not-allowed; }
footer { display: flex; justify-content: space-between; border-top: 1px solid var(--line); padding: 22px 0 34px; color: var(--muted); font-size: 11px; }
.toast { position: fixed; left: 50%; bottom: 28px; z-index: 20; transform: translate(-50%, 24px); background: var(--ink); color: white; padding: 12px 17px; border-radius: 11px; box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; font-size: 13px; }
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }
button:focus-visible, a:focus-visible, label:focus-within { outline: 3px solid rgba(35, 87, 216, .28); outline-offset: 3px; }

[hidden] { display: none !important; }
.recovery-panel { margin-bottom: 20px; }
.recovery-panel p { line-height: 1.8; }
.recovery-panel form { display: grid; gap: 12px; }
.recovery-panel input { width: 100%; padding: 12px; border: 1px solid var(--line); border-radius: 8px; }
#recoveryError { color: #9b2f18; }
.download-tasks { margin-bottom: 24px; }
.download-task { padding: 16px; margin: 12px 0; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); overflow-wrap: anywhere; }
.download-task p { font-size: 13px; line-height: 1.7; }
.download-task progress { width: 100%; accent-color: var(--blue); }
.download-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.download-actions button { min-height: 44px; }
@media (max-width: 820px) {
  .page-shell { width: calc(100% - 24px); max-width: 620px; }
  .topbar { height: 70px; }
  .hero { min-height: auto; grid-template-columns: 1fr; padding: 42px 25px 27px; gap: 38px; border-radius: 23px; }
  h1 { font-size: clamp(44px, 13vw, 58px); }
  .lead { margin: 22px 0 25px; font-size: 14px; }
  .qr-card { display: block; width: 100%; max-width: 320px; justify-self: center; }
  .workbench, .content-grid { grid-template-columns: 1fr; }
  .device-memory { align-items: stretch; }
  .device-memory-controls { width: 100%; }
  .device-memory-controls label { flex-basis: 100%; }
  .device-memory-controls select, .device-memory-controls button { flex: 1; white-space: nowrap; }
  .panel { padding: 23px; }
  .shelf-section { padding: 24px 18px; margin-bottom: 45px; }
  .content-grid { gap: 28px; }
  footer { flex-direction: column; gap: 6px; }
}

@media (max-width: 440px) {
  .network-state { max-width: 170px; text-align: right; }
  .hero { padding-left: 20px; padding-right: 20px; }
  .panel-title { align-items: flex-end; }
  .file-item { grid-template-columns: 48px minmax(0, 1fr); }
  .file-thumb { width: 48px; height: 48px; }
  .item-actions { grid-column: 1 / -1; }
  .action-button { flex: 1; text-align: center; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation: none !important; transition: none !important; }
}

/* 2026-09 portability, device control and P2P upgrade */
.recovery-import { margin-top: 16px; display: flex; align-items: center; flex-wrap: wrap; gap: 12px; color: var(--muted); font-size: 13px; }
.compact-input, .shelf-tools input { min-width: 130px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; color: var(--ink); background: white; }
.management-grid { display: grid; grid-template-columns: .9fr 1.1fr; gap: 20px; margin-top: 20px; }
.status-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 22px 0 0; }
.status-grid div { padding: 13px; background: #f8fafc; border: 1px solid var(--line); border-radius: 12px; }
.status-grid dt { color: var(--muted); font-size: 10px; }
.status-grid dd { margin: 5px 0 0; font-weight: 750; font-size: 13px; overflow-wrap: anywhere; }
.device-list { display: grid; gap: 9px; margin-top: 18px; }
.device-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 11px 12px; border: 1px solid var(--line); border-radius: 12px; background: #fafbfd; }
.device-row strong, .device-row small { display: block; }
.device-row small, .muted { color: var(--muted); font-size: 12px; line-height: 1.65; }
.device-row-actions { display: flex; gap: 6px; }
.direct-panel { grid-column: 1 / -1; }
.compact-drop { display: inline-flex; margin-top: 14px; padding: 11px 16px; border: 1px dashed var(--blue); border-radius: 11px; color: var(--blue); font-weight: 750; cursor: pointer; }
.shelf-tools { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.file-select { width: 18px; height: 18px; accent-color: var(--blue); }
.file-item.has-select { grid-template-columns: 22px 58px minmax(0, 1fr) auto; }
.install-ready { animation: softPulse 1.8s ease-in-out infinite; }
@keyframes softPulse { 50% { box-shadow: 0 0 0 5px rgba(35,87,216,.12); } }
@media (max-width: 820px) {
  .management-grid { grid-template-columns: 1fr; }
  .shelf-tools { width: 100%; justify-content: stretch; }
  .shelf-tools input { flex: 1 1 100%; }
  .file-item.has-select { grid-template-columns: 20px 48px minmax(0,1fr); }
  .file-item.has-select .item-actions { grid-column: 1 / -1; }
}

/* Transfer stays primary on every screen; administration opens from the header. */
.topbar-actions { display: flex; align-items: center; gap: 14px; }
.mobile-more-toggle { display: inline-flex; align-items: center; gap: 8px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 11px; background: rgba(255,255,255,.78); color: var(--muted); font-size: 12px; font-weight: 750; cursor: pointer; }
.mobile-more-toggle:hover, .mobile-more-toggle[aria-expanded="true"] { color: var(--blue); border-color: #b8c7ee; background: var(--soft-blue); }
.mobile-more-toggle span:last-child { font-size: 15px; }
main { display: flex; flex-direction: column; }
.workbench { order: 1; margin-top: 0; }
.shelf-section { order: 2; }
.hero { order: 3; display: none; }
.device-memory { order: 4; display: none; }
.management-grid { order: 5; display: none; }
.direct-panel { display: none; }
main.advanced-open .hero { display: grid; min-height: 0; grid-template-columns: 1fr; margin-top: 20px; padding: 24px; }
main.advanced-open .hero-copy { display: none; }
main.advanced-open .qr-card { width: 100%; max-width: 320px; justify-self: center; }
main.advanced-open .device-memory { display: flex; }
main.advanced-open .management-grid { display: grid; }
main.advanced-open .direct-panel { display: block; }

@media (max-width: 820px) {
  .workbench { gap: 12px; }
  .workbench .panel { padding: 18px; border-radius: 17px; }
  .workbench .panel h2 { font-size: 22px; }
  .workbench .panel-kicker { margin-bottom: 6px; }
  .dropzone { min-height: 142px; margin-top: 15px; }
  .drop-symbol { margin-bottom: 7px; }
  .note-panel textarea { min-height: 108px; margin-top: 15px; padding: 14px; }
  .shelf-section { padding: 19px 16px; border-radius: 17px; }
  .shelf-section .section-heading h2 { font-size: 22px; }
  .content-grid { margin-top: 20px; gap: 20px; }
  .empty-state { min-height: 82px; padding: 16px; }
  .file-download-hint { display: none; }
  #downloadSelectedButton:disabled, #deleteSelectedButton:disabled { display: none; }
  .mobile-more-toggle { width: 40px; height: 40px; justify-content: center; padding: 0; }
  .mobile-more-toggle span:first-child { display: none; }
  .topbar-actions { gap: 10px; }
  .network-state { max-width: 150px; }
}
