/* NanoShare — follows the NanoHash site tokens (website/nh.css) */
:root {
  --ink: #13235a;
  --ink-2: #1d3175;
  --text: #2b3553;
  --muted: #5b6784;
  --bg: #f5f7fb;
  --surface: #ffffff;
  --sunken: #eef2f8;
  --line: #e3e8f1;
  --lime: #d9ff5b;
  --lime-soft: #f3ffd0;
  --on-lime: #13235a;
  --accent: #2a78f0;
  --danger: #c4312b;
  --danger-soft: #fdecec;
  --radius: 12px;
  --radius-lg: 20px;
  --shadow: 0 1px 2px rgba(19, 35, 90, .06), 0 18px 40px -12px rgba(19, 35, 90, .18);
  --font: "Inter", "Noto Sans Thai", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Consolas, monospace;
  --ease: cubic-bezier(.23, 1, .32, 1);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink: #e8edff;
    --ink-2: #c9d3f5;
    --text: #cfd6ea;
    --muted: #97a2c0;
    --bg: #0d1330;
    --surface: #151d42;
    --sunken: #1b2550;
    --line: #28336a;
    --lime-soft: #26311a;
    --accent: #7fb0ff;
    --danger: #ff8a80;
    --danger-soft: #3a1a22;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 18px 40px -12px rgba(0, 0, 0, .55);
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100dvh; display: flex; flex-direction: column;
  background: var(--bg); color: var(--text);
  font: 400 16px/1.6 var(--font);
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
}
:lang(th) body { line-height: 1.75; }
h1, h2 { margin: 0; color: var(--ink); text-wrap: balance; }
p { margin: 0; text-wrap: pretty; }
a { color: var(--accent); }
button, input { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 6px; }
[hidden] { display: none !important; }

.nh-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: 16px; top: -60px; z-index: 50; padding: 10px 16px; border-radius: 8px; background: var(--ink); color: var(--bg); font-weight: 600; text-decoration: none; }
.skip:focus { top: 12px; }

/* ---------- Header / footer ---------- */
.top { display: flex; align-items: center; justify-content: space-between; gap: 16px; max-width: 1080px; width: 100%; margin: 0 auto; padding: 20px 24px; }
.brand { display: inline-flex; align-items: baseline; gap: 8px; color: var(--ink); text-decoration: none; }
.brand-mark { align-self: center; width: 22px; height: 22px; border-radius: 7px; background: var(--lime); box-shadow: inset 0 0 0 5px var(--ink); }
.brand-name { font-weight: 700; font-size: 19px; letter-spacing: -.01em; }
.brand-by { color: var(--muted); font-size: 13px; }
.lang { min-height: 40px; padding: 0 14px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--ink); font-size: 14px; font-weight: 500; cursor: pointer; }

.foot { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 24px; margin-top: auto; padding: 32px 24px; color: var(--muted); font-size: 14px; text-align: center; }
.lock { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #3ba55c; vertical-align: middle; margin-right: 2px; }

/* ---------- Layout ---------- */
main { width: 100%; max-width: 1080px; margin: 0 auto; padding: 8px 24px 24px; outline: none; }
.view { animation: rise .32s var(--ease) both; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.hero { max-width: 720px; margin: 24px auto 40px; text-align: center; }
.hero h1 { font-size: clamp(32px, 5vw, 52px); line-height: 1.12; letter-spacing: -.025em; }
:lang(th) .hero h1 { line-height: 1.35; letter-spacing: 0; }
.hero p { margin-top: 16px; color: var(--muted); font-size: 18px; }

.panes { display: grid; grid-template-columns: 1.55fr 1fr; gap: 24px; align-items: start; }
.card { background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow); padding: 24px; }
.card.narrow { max-width: 640px; margin: 24px auto 0; padding: 32px; }
.card.center { text-align: center; }
.card.center .btn { margin-top: 24px; }
.h-sm { font-size: 28px; line-height: 1.25; letter-spacing: -.015em; }
:lang(th) .h-sm { letter-spacing: 0; line-height: 1.45; }
.muted { color: var(--muted); }
.row { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 24px; }

/* ---------- Drop zone ---------- */
.drop {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  min-height: 300px; padding: 32px 16px; border: 2px dashed var(--line); border-radius: 14px;
  background: var(--sunken); color: var(--ink); text-align: center; cursor: pointer;
  transition: background-color .15s var(--ease), border-color .15s var(--ease);
}
.drop:focus-within { outline: 2px solid var(--accent); outline-offset: 3px; }
.drop.is-over, .drop:hover { border-color: var(--ink); background: var(--lime-soft); }
.drop-icon { display: grid; place-items: center; width: 72px; height: 72px; margin-bottom: 12px; border-radius: 20px; background: var(--lime); color: var(--on-lime); transition: transform .2s var(--ease); }
.drop.is-over .drop-icon { transform: translateY(-4px); }
.drop-hint { font-size: 22px; font-weight: 600; }
.drop-or { color: var(--muted); }
.drop-hint--touch { display: none; }
@media (hover: none) and (pointer: coarse) { .drop-hint--mouse, .drop-or { display: none; } .drop-hint--touch { display: inline; } }
.drop-pick { color: var(--accent); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
.drop-limit { margin-top: 8px; color: var(--muted); font-size: 14px; }
.picked .drop, .has-files .drop { min-height: 140px; }
.has-files .drop-icon { width: 48px; height: 48px; margin-bottom: 4px; }
.has-files .drop-icon svg { width: 32px; height: 32px; }
.has-files .drop-hint { font-size: 18px; }

/* ---------- File lists ---------- */
.files { margin: 20px 0 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.file { display: grid; grid-template-columns: 40px 1fr auto; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--radius); background: var(--sunken); }
.file-ico { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; background: var(--surface); color: var(--ink); font-size: 11px; font-weight: 700; letter-spacing: .02em; text-transform: uppercase; }
.file-main { min-width: 0; }
.file-name { overflow: hidden; color: var(--ink); font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.file-size { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.file-actions { display: flex; gap: 6px; }
.file .meter { margin-top: 6px; }
.icon-btn { display: grid; place-items: center; width: 40px; height: 40px; border: 0; border-radius: 10px; background: transparent; color: var(--muted); cursor: pointer; }
.icon-btn:hover { background: var(--surface); color: var(--danger); }

.meter { height: 6px; margin-top: 16px; overflow: hidden; border-radius: 99px; background: var(--sunken); }
.file .meter { background: var(--surface); height: 4px; }
.meter span { display: block; width: 0; height: 100%; border-radius: inherit; background: var(--ink); transition: width .2s linear; }
.meter.is-over span { background: var(--danger); }
.meter--big { height: 10px; margin-top: 24px; }
.meter--big span { background: linear-gradient(90deg, var(--ink), var(--accent)); }
.meter-text { margin-top: 8px; color: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums; }

.check { display: flex; gap: 12px; align-items: flex-start; margin-top: 16px; cursor: pointer; }
.check input { width: 20px; height: 20px; margin: 3px 0 0; accent-color: var(--ink); }
.check small { display: block; color: var(--muted); font-size: 13px; }

/* ---------- Buttons & fields ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 22px; border: 0; border-radius: var(--radius);
  font-weight: 600; white-space: nowrap; flex-shrink: 0; cursor: pointer; text-decoration: none;
  transition: transform .1s var(--ease), background-color .15s var(--ease), opacity .15s;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; pointer-events: none; }
.btn--primary { background: var(--lime); color: var(--on-lime); }
.btn--primary:hover { background: #cdf53f; }
.btn--dark { width: 100%; margin-top: 12px; background: var(--ink); color: var(--bg); }
.btn--ghost { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 1px var(--line); }
.btn--ghost:hover { background: var(--sunken); }
.btn--danger { background: transparent; color: var(--danger); box-shadow: inset 0 0 0 1px var(--line); }
.btn--danger:hover { background: var(--danger-soft); }
.btn--small { min-height: 40px; padding: 0 14px; font-size: 14px; background: var(--sunken); color: var(--ink); }
.btn--small:hover { background: var(--line); }

.receive h2 { font-size: 22px; }
.receive .muted { margin-top: 4px; }
.receive form { margin-top: 20px; }
.field-label { display: block; margin-bottom: 6px; color: var(--ink); font-size: 14px; font-weight: 600; }
.field { width: 100%; min-height: 52px; padding: 0 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--sunken); color: var(--ink); font-family: var(--mono); font-size: 17px; }
.field:focus { border-color: var(--ink); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 30%, transparent); }
.field--link { min-height: 40px; font-size: 13px; }

.msg { margin-top: 8px; font-size: 14px; }
.msg--err { color: var(--danger); }
.msg:empty { display: none; }

/* ---------- Result ---------- */
.pill { display: inline-flex; align-items: center; gap: 8px; margin-bottom: 12px; padding: 4px 12px; border-radius: 999px; background: var(--lime); color: var(--on-lime); font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill--burn { margin: 20px 0 0; background: var(--danger-soft); color: var(--danger); }
.pill.is-expired { background: var(--danger-soft); color: var(--danger); }

.ways { display: grid; grid-template-columns: 1fr auto; grid-template-areas: "code qr" "link qr"; gap: 20px 24px; margin-top: 24px; }
.way--code { grid-area: code; }
.way--qr { grid-area: qr; }
.way--link { grid-area: link; }
.way-label { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; color: var(--muted); font-size: 14px; }
.num { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--ink); color: var(--bg); font-size: 12px; font-weight: 700; }
.code-box, .link-box { display: flex; gap: 8px; align-items: center; }
.code {
  flex: 1; min-width: 0; padding: 12px 16px; border-radius: var(--radius); background: var(--sunken);
  color: var(--ink); font-family: var(--mono); font-size: clamp(18px, 2.4vw, 24px); font-weight: 700; line-height: 1.4; overflow-wrap: anywhere;
}
.qr { width: 176px; height: 176px; padding: 8px; border-radius: var(--radius); background: #fff; }
.qr svg { display: block; width: 100%; height: 100%; }

/* ---------- Receive ---------- */
.notice { margin-top: 16px; padding: 12px 16px; border-radius: var(--radius); background: var(--danger-soft); color: var(--danger); font-size: 14px; }
.files--recv .btn--small { min-width: 64px; }

/* ---------- Viewer ---------- */
.viewer { width: min(1000px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); padding: 0; border: 0; border-radius: var(--radius-lg); background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.viewer[open] { display: flex; flex-direction: column; animation: pop .2s var(--ease) both; }
.viewer::backdrop { background: rgba(8, 12, 32, .6); }
@keyframes pop { from { opacity: 0; transform: scale(.97); } to { opacity: 1; transform: none; } }
.viewer-bar { display: flex; align-items: center; gap: 8px; padding: 12px 12px 12px 20px; border-bottom: 1px solid var(--line); }
.viewer-title { flex: 1; min-width: 0; overflow: hidden; font-size: 16px; text-overflow: ellipsis; white-space: nowrap; }
.viewer-body { flex: 1; min-height: 0; overflow: auto; display: grid; place-items: center; background: var(--sunken); }
.pv--image { max-width: 100%; max-height: calc(100dvh - 120px); object-fit: contain; }
.pv--pdf { width: 100%; height: calc(100dvh - 120px); border: 0; background: #fff; }
.pv--video { max-width: 100%; max-height: calc(100dvh - 120px); }
.pv--audio { width: min(480px, 90%); margin: 48px 0; }
.pv--text { align-self: stretch; justify-self: stretch; margin: 0; padding: 20px; color: var(--text); font: 13px/1.6 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; }

/* ---------- Overlay & toast ---------- */
.overlay { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; padding: 16px; background: color-mix(in srgb, var(--ink) 82%, transparent); pointer-events: none; }
.overlay p { padding: 28px 40px; border: 3px dashed var(--lime); border-radius: var(--radius-lg); color: var(--lime); font-size: 28px; font-weight: 700; }
.toast { position: fixed; left: 50%; bottom: 24px; z-index: 60; padding: 10px 18px; border-radius: 999px; background: var(--ink); color: var(--bg); font-size: 14px; font-weight: 500; opacity: 0; transform: translate(-50%, 8px); transition: opacity .2s var(--ease), transform .2s var(--ease); pointer-events: none; }
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }

/* ---------- P2P ---------- */
.notice--info { margin-top: 20px; background: var(--sunken); color: var(--text); }
.files--peers:empty { display: none; }
.pill--wait::before { animation: pulse 1.2s ease-in-out infinite; }
.pill.is-live { background: #d7f5df; color: #1f6b3a; }
@keyframes pulse { 50% { opacity: .25; } }
.spinner { width: 44px; height: 44px; margin: 8px auto 20px; border: 4px solid var(--sunken); border-top-color: var(--ink); border-radius: 50%; animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.card.center .muted { margin-top: 8px; }
@media (prefers-color-scheme: dark) { .pill.is-live { background: #173a26; color: #8fe0a8; } }

/* ---------- Folders, messages, speed ---------- */
.drop-folder { margin-top: 10px; text-align: center; }
.link-btn { min-height: 32px; padding: 4px 8px; border: 0; background: none; color: var(--accent); font-weight: 600; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.field-label--msg { margin-top: 18px; }
.field--area { min-height: 64px; padding: 12px 16px; font-family: var(--font); font-size: 15px; line-height: 1.5; resize: vertical; }
.msgbox { margin-top: 18px; padding: 14px 16px; border-radius: var(--radius); background: var(--sunken); }
.msgbox .way-label { margin-bottom: 6px; }
.msgbox-body { max-height: 240px; overflow: auto; color: var(--ink); white-space: pre-wrap; overflow-wrap: anywhere; }
.row--tight { margin-top: 10px; }
#recv-speed:empty { display: none; }
.file-path { color: var(--muted); font-weight: 400; }
/* ---------- Inbox & push ---------- */
.inbox-cta { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line); }
.inbox-cta .muted { font-size: 14px; margin-bottom: 8px; }
.btn--block { width: 100%; }
.qr--big { width: 220px; height: 220px; }
.drop--compact { min-height: 120px; margin-top: 18px; }
/* ---------- My devices ---------- */
.devices { margin-top: 24px; }
.devices-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.devices-head h2 { font-size: 20px; }
#devices-empty { margin-top: 6px; }
#device-list:empty { display: none; }
.devices-me { margin-top: 14px; color: var(--muted); font-size: 14px; }
.dot { display: inline-block; width: 8px; height: 8px; margin-right: 6px; border-radius: 50%; background: var(--line); vertical-align: middle; }
.dot.is-on { background: #3ba55c; }
.auto-toggle { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; cursor: pointer; }
.auto-toggle input { width: 16px; height: 16px; accent-color: var(--ink); }
.knock { width: min(440px, calc(100vw - 32px)); }
.knock-body { padding: 24px; }
.knock-body .h-sm { margin-top: 8px; }
/* ---------- Small screens ---------- */
@media (max-width: 820px) {
  .panes { grid-template-columns: 1fr; }
  .drop { min-height: 220px; }
}
@media (max-width: 560px) {
  .top { padding: 16px; }
  main { padding: 0 16px 16px; }
  .hero { margin: 8px auto 24px; }
  .hero p { font-size: 16px; }
  .card, .card.narrow { padding: 20px; }
  .ways { grid-template-columns: 1fr; grid-template-areas: "code" "qr" "link"; }
  .qr { justify-self: start; }
  .link-box, .code-box { flex-wrap: wrap; }
  .code { flex: 1 1 100%; font-size: 20px; }
  .field--link { flex: 1 1 100%; }
  .file { grid-template-columns: 36px 1fr; }
  .file-ico { width: 36px; height: 36px; }
  .file-actions { grid-column: 1 / -1; justify-content: flex-end; }
  .row .btn { flex: 1 1 auto; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
