/* Caelune: paper and vermilion. Flat layers, soft depth, no hard outlines. */

:root {
  color-scheme: light;
  --bg: #f4f1ea;
  --bg-deep: #ece8df;
  --well: #e8e3d9;
  --surface: #fbfaf6;
  --surface-hi: #ffffff;
  --hover: rgba(48, 36, 20, 0.05);
  --press: rgba(48, 36, 20, 0.09);
  --ink: #1f1c17;
  --ink-2: #5b564d;
  --ink-3: #8e887d;
  --ink-4: #bdb7ab;
  --sep: rgba(48, 36, 20, 0.07);
  --accent: #d4482b;
  --accent-hi: #e2583a;
  --accent-ink: #fffaf5;
  --accent-soft: rgba(212, 72, 43, 0.1);
  --accent-softer: rgba(212, 72, 43, 0.055);
  --star: #e09c14;
  --ok: #2c9a6a;
  --mark: rgba(224, 156, 20, 0.28);
  --shadow-lift: 0 1px 1px rgba(60, 40, 20, 0.03), 0 8px 28px -10px rgba(60, 40, 20, 0.14);
  --shadow-float: 0 2px 8px rgba(60, 40, 20, 0.06), 0 22px 56px -14px rgba(60, 40, 20, 0.28);
  --shadow-knob: 0 1px 2px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.08);
  --scrim: rgba(32, 24, 14, 0.26);
  --r-s: 10px;
  --r-m: 14px;
  --r-l: 22px;
  --r-xl: 30px;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --spring: cubic-bezier(0.34, 1.5, 0.64, 1);
  --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI Variable Text", "Segoe UI", "PingFang SC", "HarmonyOS Sans SC",
    "MiSans", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", "Noto Sans CJK SC", "Noto Sans SC", system-ui, sans-serif;
  --font-serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Songti SC", "Noto Serif CJK SC", "Source Han Serif SC",
    "Noto Serif SC", STSong, "SimSun", Georgia, serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas, monospace;
  --font-read: var(--font-serif);
  --st: env(safe-area-inset-top, 0px);
  --sb: env(safe-area-inset-bottom, 0px);
  --sl: env(safe-area-inset-left, 0px);
  --sr: env(safe-area-inset-right, 0px);
  --tabbar-h: 62px;
}

:root[data-font="sans"] { --font-read: var(--font-ui); }

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121214;
  --bg-deep: #0c0c0e;
  --well: #0a0a0b;
  --surface: #1b1b1f;
  --surface-hi: #232328;
  --hover: rgba(255, 246, 230, 0.06);
  --press: rgba(255, 246, 230, 0.1);
  --ink: #eeebe5;
  --ink-2: #aaa59c;
  --ink-3: #78736b;
  --ink-4: #4d4a45;
  --sep: rgba(255, 246, 230, 0.07);
  --accent: #ee6446;
  --accent-hi: #f47657;
  --accent-ink: #1a0c08;
  --accent-soft: rgba(238, 100, 70, 0.15);
  --accent-softer: rgba(238, 100, 70, 0.08);
  --star: #f2b33a;
  --mark: rgba(242, 179, 58, 0.3);
  --shadow-lift: 0 1px 0 rgba(255, 255, 255, 0.025) inset, 0 10px 30px -12px rgba(0, 0, 0, 0.6);
  --shadow-float: 0 1px 0 rgba(255, 255, 255, 0.04) inset, 0 24px 64px -12px rgba(0, 0, 0, 0.75);
  --scrim: rgba(0, 0, 0, 0.5);
}
@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] {
    color-scheme: dark;
    --bg: #121214;
    --bg-deep: #0c0c0e;
    --well: #0a0a0b;
    --surface: #1b1b1f;
    --surface-hi: #232328;
    --hover: rgba(255, 246, 230, 0.06);
    --press: rgba(255, 246, 230, 0.1);
    --ink: #eeebe5;
    --ink-2: #aaa59c;
    --ink-3: #78736b;
    --ink-4: #4d4a45;
    --sep: rgba(255, 246, 230, 0.07);
    --accent: #ee6446;
    --accent-hi: #f47657;
    --accent-ink: #1a0c08;
    --accent-soft: rgba(238, 100, 70, 0.15);
    --accent-softer: rgba(238, 100, 70, 0.08);
    --star: #f2b33a;
    --mark: rgba(242, 179, 58, 0.3);
    --shadow-lift: 0 1px 0 rgba(255, 255, 255, 0.025) inset, 0 10px 30px -12px rgba(0, 0, 0, 0.6);
    --shadow-float: 0 1px 0 rgba(255, 255, 255, 0.04) inset, 0 24px 64px -12px rgba(0, 0, 0, 0.75);
    --scrim: rgba(0, 0, 0, 0.5);
  }
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.55 var(--font-ui);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
button:disabled { cursor: default; }
input, textarea { border: 0; outline: 0; background: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 8px; }
::selection { background: var(--accent-soft); }
svg.i { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.noscript { padding: 40px; text-align: center; color: var(--ink-2); }

.boot { height: 100dvh; display: grid; place-items: center; }
.boot img { border-radius: 18px; animation: breathe 1.6s var(--ease) infinite alternate; }
@keyframes breathe { from { opacity: 0.55; transform: scale(0.96); } to { opacity: 1; transform: scale(1); } }

/* ---------- controls ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 42px; padding: 0 18px; border-radius: 999px;
  background: var(--hover); color: var(--ink); font-weight: 560; letter-spacing: 0.01em; white-space: nowrap;
  transition: background 0.2s var(--ease), transform 0.2s var(--ease), color 0.2s, box-shadow 0.2s, opacity 0.2s;
}
.btn:hover { background: var(--press); }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.45; transform: none; }
.btn.primary { background: var(--accent); color: var(--accent-ink); box-shadow: 0 6px 18px -8px var(--accent); }
.btn.primary:hover { background: var(--accent-hi); }
.btn.soft { background: var(--accent-soft); color: var(--accent); }
.btn.soft:hover { background: var(--accent-soft); filter: saturate(1.2); }
.btn.ghost { background: transparent; }
.btn.ghost:hover { background: var(--hover); }
.btn.danger { color: var(--accent); }
.btn.block { width: 100%; height: 48px; }
.btn .i { width: 18px; height: 18px; }
.btn kbd { font: 500 11px/1 var(--font-mono); opacity: 0.6; margin-left: 2px; }

.icon-btn {
  position: relative; display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 999px; color: var(--ink-2);
  transition: background 0.2s var(--ease), color 0.2s, transform 0.2s var(--ease);
}
.icon-btn:hover { background: var(--hover); color: var(--ink); }
.icon-btn:active { transform: scale(0.92); background: var(--press); }
.icon-btn:disabled { opacity: 0.35; background: none; transform: none; }
.icon-btn.on { color: var(--accent); }
.icon-btn.star.on { color: var(--star); }
.icon-btn.star.on svg { fill: currentColor; animation: pop 0.45s var(--spring); }
.icon-btn.sm { width: 34px; height: 34px; }
.icon-btn.sm .i { width: 18px; height: 18px; }
.icon-btn[data-tip]:hover::after {
  content: attr(data-tip); position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%);
  padding: 5px 9px; border-radius: 8px; background: var(--ink); color: var(--bg); font-size: 12px; font-weight: 500;
  white-space: nowrap; pointer-events: none; animation: fade-in 0.15s 0.4s both; z-index: 5;
}
@media (hover: none) { .icon-btn[data-tip]:hover::after { display: none; } }
@keyframes pop { 0% { transform: scale(0.6); } 60% { transform: scale(1.18); } 100% { transform: scale(1); } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.field {
  display: flex; align-items: center; gap: 10px; height: 46px; padding: 0 16px; border-radius: 999px;
  background: var(--well); color: var(--ink-3); transition: background 0.2s, box-shadow 0.2s;
}
.field:focus-within { background: var(--surface-hi); box-shadow: 0 0 0 2px var(--accent-soft); color: var(--ink-2); }
.field input { flex: 1; min-width: 0; height: 100%; color: var(--ink); }
.field input::placeholder { color: var(--ink-3); }
.field.code input { font: 600 18px/1 var(--font-mono); letter-spacing: 0.12em; text-transform: uppercase; }

.seg { position: relative; display: inline-flex; padding: 4px; border-radius: 999px; background: var(--well); isolation: isolate; }
.seg button {
  position: relative; z-index: 1; height: 34px; padding: 0 16px; border-radius: 999px; color: var(--ink-2); font-weight: 540; font-size: 14px;
  white-space: nowrap; transition: color 0.25s var(--ease);
}
.seg button[aria-pressed="true"] { color: var(--ink); }
.seg .ind {
  position: absolute; z-index: 0; top: 4px; bottom: 4px; left: 0; width: 0; border-radius: 999px; background: var(--surface-hi);
  box-shadow: var(--shadow-knob); transition: transform 0.4s var(--ease-out), width 0.4s var(--ease-out);
}
.seg.accent button[aria-pressed="true"] { color: var(--accent); }

.switch { position: relative; width: 48px; height: 28px; border-radius: 999px; background: var(--ink-4); transition: background 0.25s var(--ease); flex: none; }
.switch::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff;
  box-shadow: var(--shadow-knob); transition: transform 0.35s var(--spring);
}
.switch[aria-checked="true"] { background: var(--accent); }
.switch[aria-checked="true"]::after { transform: translateX(20px); }

/* ---------- app shell ---------- */

.app { display: grid; grid-template-columns: 1fr; height: 100dvh; overflow: hidden; }
.main { position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.topbar {
  display: flex; align-items: center; gap: 10px; flex: none;
  padding: calc(var(--st) + 10px) calc(var(--sr) + 14px) 6px calc(var(--sl) + 18px);
}
.brand { display: flex; align-items: baseline; gap: 8px; }
.brand img { align-self: center; }
.wordmark { font-family: var(--font-serif); font-weight: 600; font-size: 21px; letter-spacing: 0.015em; color: var(--ink); }
.brand-sub { font-size: 12.5px; font-weight: 560; color: var(--ink-3); letter-spacing: 0.08em; }
.brand img { width: 30px; height: 30px; border-radius: 9px; }
.topbar .spacer { flex: 1; }
.views { position: relative; flex: 1; min-height: 0; }
.view {
  position: absolute; inset: 0; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain;
  padding: 8px calc(var(--sr) + 16px) calc(var(--tabbar-h) + var(--sb) + 28px) calc(var(--sl) + 16px);
  scrollbar-width: thin; scrollbar-color: var(--ink-4) transparent;
}
.view-inner { max-width: 1180px; margin: 0 auto; }
.view.enter { animation: view-in 0.42s var(--ease-out); }
@keyframes view-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.sync-chip {
  display: inline-flex; align-items: center; gap: 7px; height: 30px; padding: 0 12px 0 10px; border-radius: 999px;
  background: var(--hover); color: var(--ink-2); font-size: 12.5px; font-weight: 520; transition: background 0.2s;
}
.sync-chip:hover { background: var(--press); }
.sync-chip .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); transition: background 0.3s; }
.sync-chip[data-state="syncing"] .dot { background: var(--star); animation: blink 1s infinite alternate; }
.sync-chip[data-state="pending"] .dot { background: var(--star); }
.sync-chip[data-state="offline"] .dot, .sync-chip[data-state="error"] .dot { background: var(--ink-3); }
@keyframes blink { from { opacity: 0.35; } to { opacity: 1; } }

.tabbar {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; justify-content: center; gap: 6px;
  padding: 8px calc(var(--sr) + 12px) calc(var(--sb) + 8px) calc(var(--sl) + 12px);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  -webkit-backdrop-filter: saturate(1.6) blur(18px); backdrop-filter: saturate(1.6) blur(18px);
  transition: transform 0.35s var(--ease);
}
.tab {
  flex: 1; max-width: 140px; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 0 4px;
  border-radius: 16px; color: var(--ink-3); font-size: 11.5px; font-weight: 560; transition: color 0.2s, background 0.2s;
}
.tab .pill { display: grid; place-items: center; width: 54px; height: 30px; border-radius: 999px; transition: background 0.3s var(--ease); }
.tab[aria-current="page"] { color: var(--accent); }
.tab[aria-current="page"] .pill { background: var(--accent-soft); }
.tab:active .pill { transform: scale(0.94); }

.rail { display: none; }

@media (max-width: 899px) {
  .app.typing .tabbar { transform: translateY(110%); }
}

@media (min-width: 900px) {
  .app { grid-template-columns: 92px 1fr; }
  .topbar, .tabbar { display: none; }
  .rail {
    display: flex; flex-direction: column; align-items: center; gap: 4px;
    padding: calc(var(--st) + 22px) 0 22px calc(var(--sl));
  }
  .rail .logo { width: 44px; height: 44px; border-radius: 13px; margin-bottom: 22px; box-shadow: 0 8px 20px -10px var(--accent); }
  .rail .tab { flex: none; width: 76px; padding: 6px 0 8px; font-size: 12px; }
  .rail .tab .pill { width: 52px; height: 34px; }
  .rail .tab:hover:not([aria-current="page"]) { color: var(--ink-2); }
  .rail .tab:hover:not([aria-current="page"]) .pill { background: var(--hover); }
  .rail .grow { flex: 1; }
  .rail .sync-chip { flex-direction: column; height: auto; width: 68px; padding: 8px 4px; gap: 5px; border-radius: 14px; font-size: 11px; text-align: center; line-height: 1.25; }
  .view { padding: calc(var(--st) + 30px) calc(var(--sr) + 36px) 48px 12px; }
}

/* ---------- translate view ---------- */

.lang-bar { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 6px; margin: 4px 0 12px; }
.lang-pill {
  display: flex; flex-direction: column; align-items: center; justify-content: center; min-width: 0; height: 52px; padding: 0 12px;
  border-radius: 18px; transition: background 0.2s var(--ease), transform 0.2s var(--ease);
}
.lang-pill:hover { background: var(--hover); }
.lang-pill:active { transform: scale(0.98); }
.lang-pill .name { display: flex; align-items: center; gap: 4px; font-weight: 640; font-size: 16px; max-width: 100%; }
.lang-pill .name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lang-pill .name .i { width: 16px; height: 16px; color: var(--ink-3); }
.lang-pill .sub { font-size: 12px; color: var(--accent); font-weight: 540; height: 16px; line-height: 16px; animation: fade-in 0.3s; }
.lang-pill .sub:empty { display: none; }
.swap-btn {
  width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; color: var(--ink-2); background: var(--surface);
  box-shadow: var(--shadow-lift); transition: transform 0.5s var(--ease-out), color 0.2s, background 0.2s;
}
.swap-btn:hover { color: var(--accent); }
.swap-btn.spin { transform: rotate(180deg); }
.swap-btn:disabled { opacity: 0.4; }

.panes { display: grid; grid-template-columns: 1fr; gap: 12px; }
.pane { position: relative; display: flex; flex-direction: column; min-width: 0; border-radius: var(--r-l); transition: box-shadow 0.3s var(--ease), background 0.3s; }
.pane-in { background: var(--surface); box-shadow: var(--shadow-lift); }
.pane-in:focus-within { box-shadow: var(--shadow-lift), 0 0 0 2px var(--accent-softer); }
.pane-out { background: var(--bg-deep); }
.pane textarea, .pane .out {
  width: 100%; min-height: 168px; padding: 20px 22px 8px; font-size: 18px; line-height: 1.62; letter-spacing: 0.005em;
}
.pane textarea { flex: 1 0 auto; resize: none; display: block; max-height: 52dvh; overflow-y: auto; color: var(--ink); }
.pane textarea::placeholder { color: var(--ink-4); }
.pane .out { font-family: var(--font-read); white-space: pre-wrap; word-break: break-word; overflow-wrap: anywhere; color: var(--ink); flex: 1; }
.pane .out.placeholder { color: var(--ink-4); font-family: var(--font-ui); }
.pane .out .chunk { animation: chunk-in 0.5s var(--ease-out); }
@keyframes chunk-in { from { opacity: 0; filter: blur(2px); } to { opacity: 1; filter: none; } }
.pane .out.streaming::after {
  content: ""; display: inline-block; width: 2px; height: 1.05em; margin-left: 2px; vertical-align: -0.15em; border-radius: 2px;
  background: var(--accent); animation: caret 0.9s steps(2) infinite;
}
@keyframes caret { 50% { opacity: 0; } }
.pane .out.error { color: var(--ink-2); font-family: var(--font-ui); font-size: 15px; }
.skeleton { display: grid; gap: 12px; padding: 6px 0; }
.skeleton i {
  display: block; height: 14px; border-radius: 7px;
  background: linear-gradient(90deg, var(--well) 0%, var(--surface-hi) 50%, var(--well) 100%); background-size: 200% 100%;
  animation: shimmer 1.3s linear infinite;
}
.skeleton i:nth-child(2) { width: 82%; }
.skeleton i:nth-child(3) { width: 56%; }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }

.pane-meta { display: flex; align-items: center; gap: 8px; padding: 14px 22px 0; min-height: 34px; font-size: 12.5px; color: var(--ink-3); font-weight: 520; }
.pane-meta .tag { display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 9px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); }
.pane-foot { display: flex; align-items: center; gap: 2px; padding: 8px 10px 10px 12px; min-height: 58px; }
.pane-foot .grow { flex: 1; }
.count { font-size: 12px; color: var(--ink-3); font-variant-numeric: tabular-nums; padding: 0 8px; white-space: nowrap; }
.count.over { color: var(--accent); font-weight: 600; }
.go-btn { min-width: 96px; }
.go-btn .stop { display: none; }
.go-btn.busy .stop { display: inline; }
.go-btn.busy .go { display: none; }
.listening { color: var(--accent) !important; background: var(--accent-soft) !important; }
.listening::before { content: ""; position: absolute; inset: -3px; border-radius: inherit; border: 2px solid var(--accent); opacity: 0; animation: ring 1.4s var(--ease-out) infinite; }
@keyframes ring { 0% { transform: scale(0.85); opacity: 0.6; } 100% { transform: scale(1.35); opacity: 0; } }

.tone-row { display: flex; align-items: center; gap: 12px; margin: 16px 0 6px; overflow-x: auto; scrollbar-width: none; padding: 2px 2px 4px; }
.tone-row::-webkit-scrollbar { display: none; }
.tone-row .label { font-size: 13px; color: var(--ink-3); font-weight: 540; flex: none; }

.recent { margin-top: 30px; }
.sec-head { display: flex; align-items: baseline; justify-content: space-between; margin: 0 4px 12px; }
.sec-head h2 { margin: 0; font-size: 15px; font-weight: 660; color: var(--ink-2); letter-spacing: 0.02em; }
.link-btn { display: inline-flex; align-items: center; gap: 2px; color: var(--accent); font-size: 13.5px; font-weight: 560; padding: 4px 6px; border-radius: 8px; }
.link-btn:hover { background: var(--accent-softer); }
.link-btn .i { width: 16px; height: 16px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.card {
  text-align: left; display: flex; flex-direction: column; gap: 6px; padding: 14px 16px 16px; border-radius: 18px; background: var(--surface);
  transition: transform 0.25s var(--ease), box-shadow 0.25s var(--ease), background 0.2s; min-width: 0;
}
.card:hover { box-shadow: var(--shadow-lift); transform: translateY(-1px); }
.card:active { transform: scale(0.99); }
.card .src { color: var(--ink-2); font-size: 13.5px; }
.card .tgt { font-family: var(--font-read); font-size: 15.5px; color: var(--ink); }
.clamp2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; word-break: break-word; }
.meta-line { display: flex; align-items: center; gap: 8px; font-size: 11.5px; color: var(--ink-3); font-weight: 520; }
.meta-line .lp { display: inline-flex; align-items: center; gap: 3px; }
.meta-line .lp .i { width: 12px; height: 12px; }
.meta-line .grow { flex: 1; }
.meta-line .st { color: var(--accent); }
.meta-line .star-mark { color: var(--star); }
.meta-line .star-mark .i { width: 13px; height: 13px; fill: currentColor; }

.offline-bar {
  display: flex; align-items: center; gap: 10px; margin: 0 0 12px; padding: 10px 16px; border-radius: 14px;
  background: var(--accent-softer); color: var(--ink-2); font-size: 13.5px; animation: view-in 0.4s var(--ease-out);
}
.offline-bar .i { color: var(--accent); width: 18px; height: 18px; }

@media (min-width: 760px) {
  .panes { grid-template-columns: 1fr 1fr; }
  .pane textarea, .pane .out { min-height: 300px; font-size: 20px; padding: 22px 26px 8px; }
  .pane-meta { padding: 16px 26px 0; }
  .lang-bar { margin-top: 0; }
}

/* ---------- history ---------- */

.hist-head { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin: 4px 0 16px; }
.hist-head h1 { margin: 0 auto 0 4px; font-size: 26px; font-weight: 720; letter-spacing: 0.01em; }
.hist-tools { display: flex; align-items: center; gap: 10px; width: 100%; }
.hist-tools .field { flex: 1; }
@media (min-width: 760px) {
  .hist-tools { width: auto; flex: 1; justify-content: flex-end; }
  .hist-tools .field { max-width: 360px; }
}
.hist-stats { margin: -6px 4px 14px; font-size: 12.5px; color: var(--ink-3); }
.group-h {
  position: sticky; top: -8px; z-index: 2; margin: 18px 0 8px; padding: 8px 6px; font-size: 12.5px; font-weight: 640; color: var(--ink-3);
  letter-spacing: 0.04em; background: linear-gradient(var(--bg) 70%, transparent);
}
.group-h:first-child { margin-top: 0; }
@media (min-width: 900px) { .group-h { top: -30px; padding-top: 14px; } }
.list { display: flex; flex-direction: column; gap: 8px; }
.item {
  position: relative; border-radius: 18px; background: var(--surface); overflow: hidden;
  transition: box-shadow 0.25s var(--ease), background 0.2s, transform 0.25s var(--ease);
}
.item:hover { box-shadow: var(--shadow-lift); }
.item.leaving { animation: leave 0.32s var(--ease) forwards; }
@keyframes leave { to { opacity: 0; transform: translateX(24px); height: 0; margin: -4px 0; padding: 0; } }
.item-main { display: grid; gap: 6px; width: 100%; padding: 14px 18px 14px; text-align: left; }
.item .src { color: var(--ink-2); font-size: 14px; }
.item .tgt { font-family: var(--font-read); font-size: 16.5px; line-height: 1.55; color: var(--ink); }
.item.open .src, .item.open .tgt { -webkit-line-clamp: unset; display: block; white-space: pre-wrap; }
.item.open .tgt { margin-top: 2px; }
.item mark { background: var(--mark); color: inherit; border-radius: 3px; padding: 0 1px; }
.item-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; padding: 0 10px 10px; animation: fade-in 0.25s; }
.item-actions .grow { flex: 1; }
.item.trashed .tgt, .item.trashed .src { opacity: 0.65; }
.empty { display: grid; place-items: center; gap: 12px; padding: 70px 20px; text-align: center; color: var(--ink-3); }
.empty .art { width: 84px; height: 84px; border-radius: 28px; display: grid; place-items: center; background: var(--surface); box-shadow: var(--shadow-lift); color: var(--ink-4); }
.empty .art .i { width: 36px; height: 36px; stroke-width: 1.4; }
.empty p { margin: 0; font-size: 14.5px; }
.more-sentinel { height: 40px; }

/* ---------- settings ---------- */

.settings h1 { margin: 4px 4px 18px; font-size: 26px; font-weight: 720; }
.settings-grid { display: grid; gap: 22px; max-width: 760px; }
.group h3 { margin: 0 6px 8px; font-size: 12.5px; font-weight: 640; color: var(--ink-3); letter-spacing: 0.05em; }
.group-body { border-radius: 20px; background: var(--surface); overflow: hidden; }
.row {
  position: relative; display: flex; align-items: center; gap: 14px; width: 100%; min-height: 58px; padding: 10px 18px; text-align: left;
}
.row + .row::before { content: ""; position: absolute; top: 0; left: 18px; right: 18px; height: 1px; background: var(--sep); }
button.row { transition: background 0.2s; }
button.row:hover { background: var(--hover); }
.row .ic { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 11px; background: var(--accent-softer); color: var(--accent); flex: none; }
.row .ic .i { width: 18px; height: 18px; }
.row .txt { flex: 1; min-width: 0; display: grid; gap: 1px; }
.row .t { font-weight: 560; }
.row .d { font-size: 12.5px; color: var(--ink-3); line-height: 1.45; }
.row .val { color: var(--ink-3); font-size: 14px; display: flex; align-items: center; gap: 2px; white-space: nowrap; }
.row .val .i { width: 16px; height: 16px; }
.row.stack { flex-wrap: wrap; row-gap: 10px; }
.row.stack .txt { flex: 1 0 auto; min-width: max-content; }
.row.stack .seg { margin-left: auto; flex: none; }
.code-box {
  display: flex; align-items: center; gap: 10px; padding: 12px 14px 12px 18px; margin: 4px 18px 16px; border-radius: 16px; background: var(--well);
}
.code-box code { flex: 1; min-width: 0; font: 600 17px/1.3 var(--font-mono); letter-spacing: 0.1em; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.code-box code.masked { letter-spacing: 0.06em; color: var(--ink-3); }
@media (max-width: 520px) { .code-box code { font-size: 15px; letter-spacing: 0.04em; } }
.meter { height: 8px; border-radius: 99px; background: var(--well); overflow: hidden; margin-top: 6px; }
.meter i { display: block; height: 100%; border-radius: inherit; background: var(--accent); transition: width 0.8s var(--ease-out); }
.about-foot { text-align: center; color: var(--ink-3); font-size: 12px; padding: 8px 0 20px; }

/* ---------- sheets, menus, toasts ---------- */

.layer { position: fixed; inset: 0; z-index: 60; display: flex; align-items: flex-end; justify-content: center; }
.scrim { position: absolute; inset: 0; background: var(--scrim); opacity: 0; transition: opacity 0.35s var(--ease); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
.sheet {
  position: relative; display: flex; flex-direction: column; width: 100%; max-width: 560px; max-height: calc(100dvh - var(--st) - 24px);
  background: var(--surface); border-radius: var(--r-xl) var(--r-xl) 0 0; box-shadow: var(--shadow-float);
  padding-bottom: var(--sb); transform: translateY(100%); transition: transform 0.45s var(--ease-out); touch-action: pan-y;
}
.layer.open .scrim { opacity: 1; }
.layer.open .sheet { transform: none; }
.layer.closing .sheet { transition-duration: 0.28s; transition-timing-function: var(--ease); }
.sheet .grip { display: grid; place-items: center; height: 22px; flex: none; cursor: grab; }
.sheet .grip::before { content: ""; width: 38px; height: 5px; border-radius: 99px; background: var(--ink-4); }
.sheet-head { display: flex; align-items: center; gap: 8px; padding: 2px 14px 10px 22px; flex: none; }
.sheet-head h2 { flex: 1; margin: 0; font-size: 18px; font-weight: 680; }
.sheet-body { overflow-y: auto; padding: 0 22px 22px; overscroll-behavior: contain; }
.sheet-body p { margin: 0 0 14px; color: var(--ink-2); font-size: 14.5px; }
.sheet-actions { display: flex; gap: 10px; padding: 6px 22px 22px; flex: none; }
.sheet-actions .btn { flex: 1; height: 48px; }
@media (min-width: 700px) {
  .layer { align-items: center; padding: 24px; }
  .sheet { border-radius: var(--r-xl); transform: translateY(18px) scale(0.97); opacity: 0; transition: transform 0.4s var(--ease-out), opacity 0.3s var(--ease); padding-bottom: 0; }
  .layer.open .sheet { opacity: 1; }
  .sheet .grip { height: 14px; }
  .sheet .grip::before { display: none; }
}

.lang-list { display: grid; gap: 2px; margin-top: 10px; }
.lang-list h4 { margin: 14px 6px 6px; font-size: 12px; font-weight: 640; color: var(--ink-3); letter-spacing: 0.05em; }
.lang-opt { display: flex; align-items: center; gap: 12px; height: 50px; padding: 0 14px; border-radius: 14px; text-align: left; transition: background 0.15s; }
.lang-opt:hover, .lang-opt.kb { background: var(--hover); }
.lang-opt .n { font-weight: 560; }
.lang-opt .nat { color: var(--ink-3); font-size: 13px; flex: 1; }
.lang-opt .i { color: var(--accent); opacity: 0; }
.lang-opt[aria-selected="true"] { background: var(--accent-softer); }
.lang-opt[aria-selected="true"] .n { color: var(--accent); }
.lang-opt[aria-selected="true"] .i { opacity: 1; }
.sheet .field { position: sticky; top: 0; z-index: 1; }

.menu {
  position: fixed; z-index: 70; min-width: 210px; padding: 6px; border-radius: 18px; background: var(--surface-hi); box-shadow: var(--shadow-float);
  transform-origin: top right; animation: menu-in 0.22s var(--ease-out);
}
@keyframes menu-in { from { opacity: 0; transform: scale(0.94) translateY(-4px); } to { opacity: 1; transform: none; } }
.menu button { display: flex; align-items: center; gap: 12px; width: 100%; height: 44px; padding: 0 14px; border-radius: 12px; text-align: left; font-weight: 520; font-size: 14.5px; }
.menu button:hover { background: var(--hover); }
.menu button.danger { color: var(--accent); }
.menu button .i { width: 18px; height: 18px; color: var(--ink-3); }
.menu button.danger .i { color: var(--accent); }
.menu hr { border: 0; height: 1px; background: var(--sep); margin: 4px 10px; }

.toasts { position: fixed; z-index: 80; left: 0; right: 0; bottom: calc(var(--tabbar-h) + var(--sb) + 14px); display: grid; justify-items: center; gap: 8px; pointer-events: none; padding: 0 16px; }
@media (min-width: 900px) { .toasts { bottom: 28px; left: 92px; } }
.toast {
  display: flex; align-items: center; gap: 12px; max-width: 520px; min-height: 46px; padding: 8px 8px 8px 18px; border-radius: 16px;
  background: var(--ink); color: var(--bg); font-size: 14px; font-weight: 520; box-shadow: var(--shadow-float); pointer-events: auto;
  animation: toast-in 0.45s var(--spring);
}
.toast:not(:has(button)) { padding-right: 18px; }
.toast.out { animation: toast-out 0.25s var(--ease) forwards; }
.toast button { height: 32px; padding: 0 12px; border-radius: 10px; color: var(--accent-hi); font-weight: 650; }
.toast button:hover { background: rgba(255, 255, 255, 0.08); }
:root[data-theme="dark"] .toast button:hover { background: rgba(0, 0, 0, 0.06); }
.toast .i { width: 18px; height: 18px; }
@keyframes toast-in { from { opacity: 0; transform: translateY(14px) scale(0.96); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(8px) scale(0.98); } }

/* ---------- full screen states ---------- */

.state { min-height: 100dvh; display: grid; place-items: center; padding: calc(var(--st) + 24px) 24px calc(var(--sb) + 24px); }
.state-card { width: 100%; max-width: 420px; display: grid; gap: 16px; text-align: center; justify-items: center; }
.state-card img { width: 76px; height: 76px; border-radius: 22px; box-shadow: 0 16px 36px -16px var(--accent); }
.state-card h1 { margin: 6px 0 0; font-size: 22px; }
.state-card p { margin: 0; color: var(--ink-2); }
.state-card .btn { width: 100%; height: 48px; }
.state-card .field { width: 100%; }

/* ---------- install gate ---------- */

.gate { min-height: 100dvh; display: grid; padding: calc(var(--st) + 20px) calc(var(--sr) + 20px) calc(var(--sb) + 28px) calc(var(--sl) + 20px); overflow-x: hidden; }
.gate-wrap { width: 100%; max-width: 1080px; margin: 0 auto; display: grid; gap: 40px; align-content: center; }
.gate-hero { display: grid; gap: 40px; align-items: center; }
.gate-copy { display: grid; gap: 18px; justify-items: start; animation: view-in 0.7s var(--ease-out) both; }
.gate-brand { display: flex; align-items: baseline; gap: 10px; }
.gate-brand img { align-self: center; margin-right: 2px; }
.gate-brand .wordmark { font-size: 26px; }
.gate-brand .brand-sub { font-size: 13.5px; }
.gate-brand img { width: 44px; height: 44px; border-radius: 13px; box-shadow: 0 10px 24px -12px var(--accent); }
.gate h1 { margin: 6px 0 0; font-size: clamp(34px, 6.4vw, 60px); line-height: 1.08; letter-spacing: -0.01em; font-weight: 760; }
.gate h1 em { font-style: normal; color: var(--accent); font-family: var(--font-serif); font-weight: 700; }
.gate .lead { margin: 0; font-size: 17px; color: var(--ink-2); max-width: 30em; line-height: 1.7; }
.install-box { display: grid; gap: 14px; width: 100%; max-width: 440px; margin-top: 8px; }
.install-box .btn.primary { height: 54px; font-size: 16.5px; padding: 0 28px; justify-self: start; }
.install-box .btn.primary .i { width: 20px; height: 20px; }
.install-note { display: flex; align-items: center; gap: 10px; color: var(--ink-2); font-size: 14px; }
.install-note .i { color: var(--ok); }
.steps { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; counter-reset: s; }
.steps li { counter-increment: s; display: flex; align-items: center; gap: 14px; padding: 12px 16px; border-radius: 16px; background: var(--surface); font-size: 14.5px; }
.steps li::before { content: counter(s); display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 13px; flex: none; }
.steps li .i { width: 18px; height: 18px; color: var(--accent); margin-left: auto; }
.steps li b { font-weight: 640; color: var(--ink); }

.device {
  position: relative; justify-self: center; width: min(340px, 86vw); aspect-ratio: 9 / 17.5; border-radius: 46px; padding: 12px;
  background: linear-gradient(160deg, #2a2724, #141312); box-shadow: 0 50px 90px -40px rgba(60, 30, 10, 0.55), 0 0 0 1px rgba(255, 255, 255, 0.04) inset;
  animation: float-in 0.9s 0.1s var(--ease-out) both;
}
@keyframes float-in { from { opacity: 0; transform: translateY(30px) rotate(-2deg); } to { opacity: 1; transform: none; } }
.device .screen { position: relative; height: 100%; border-radius: 35px; overflow: hidden; background: var(--bg); display: flex; flex-direction: column; padding: 46px 14px 14px; gap: 10px; }
.device .island { position: absolute; top: 12px; left: 50%; width: 92px; height: 26px; transform: translateX(-50%); border-radius: 20px; background: #0d0c0b; z-index: 2; }
.device .mini-bar { display: flex; align-items: center; justify-content: space-between; padding: 0 6px; font-size: 13px; font-weight: 640; }
.device .mini-bar span:nth-child(2) { color: var(--ink-3); }
.device .mini-in, .device .mini-out { border-radius: 20px; padding: 16px; font-size: 15px; line-height: 1.6; min-height: 120px; }
.device .mini-in { background: var(--surface); box-shadow: var(--shadow-lift); }
.device .mini-out { background: var(--bg-deep); font-family: var(--font-serif); font-size: 16px; flex: 1; }
.device .mini-out.typing::after { content: ""; display: inline-block; width: 2px; height: 1em; margin-left: 2px; vertical-align: -0.12em; background: var(--accent); animation: caret 0.9s steps(2) infinite; }
.device .mini-tag { display: inline-block; margin-bottom: 6px; padding: 2px 8px; border-radius: 99px; background: var(--accent-soft); color: var(--accent); font: 600 11px/1.6 var(--font-ui); }
.device .mini-chips { display: flex; gap: 6px; }
.device .mini-chips i { flex: 1; height: 26px; border-radius: 99px; background: var(--well); }
.device .mini-chips i:first-child { background: var(--surface-hi); box-shadow: var(--shadow-knob); }

.feats { display: grid; grid-template-columns: 1fr; gap: 10px; }
.feat { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; padding: 18px 20px; border-radius: 20px; background: var(--surface); animation: view-in 0.7s var(--ease-out) both; }
.feat:nth-child(2) { animation-delay: 0.08s; }
.feat:nth-child(3) { animation-delay: 0.16s; }
.feat .ic { grid-row: span 2; display: grid; place-items: center; width: 42px; height: 42px; border-radius: 14px; background: var(--accent-soft); color: var(--accent); }
.feat b { font-weight: 660; }
.feat span { color: var(--ink-3); font-size: 13.5px; }
.gate-foot { text-align: center; font-size: 12px; color: var(--ink-3); }

@media (min-width: 860px) {
  .gate-hero { grid-template-columns: 1.15fr 1fr; gap: 56px; }
  .feats { grid-template-columns: repeat(3, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
}
