:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --text: #172033;
  --muted: #687386;
  --subtle: #98a2b3;
  --line: #e4e9f1;
  --primary: #3157d5;
  --primary-dark: #2547ba;
  --primary-soft: #edf1ff;
  --success: #16805d;
  --danger: #c33f4a;
  --shadow: 0 10px 36px rgba(34, 54, 98, 0.07);
  --radius: 18px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; color: var(--text); background: var(--bg); font: 16px/1.55 Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif; }
button, input, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
svg { width: 1.25rem; height: 1.25rem; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.skip-link { position: fixed; left: 12px; top: -60px; z-index: 1001; padding: 10px 14px; color: white; background: var(--primary); border-radius: 8px; }
.skip-link:focus { top: 12px; }

.app-shell { min-height: 100dvh; }
.sidebar { position: fixed; inset: 0 auto 0 0; z-index: 40; display: flex; width: 260px; flex-direction: column; padding: 30px 20px 24px; border-right: 1px solid var(--line); background: rgba(255,255,255,.94); backdrop-filter: blur(16px); }
.brand { display: flex; align-items: center; gap: 12px; margin: 0 8px 36px; color: var(--text); text-decoration: none; }
.brand-mark { display: grid; width: 42px; height: 42px; place-items: center; color: white; border-radius: 13px; background: var(--primary); box-shadow: 0 8px 20px rgba(49,87,213,.24); }
.brand-mark svg { width: 24px; height: 24px; }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 16px; letter-spacing: .01em; }
.brand small { margin-top: -1px; color: var(--subtle); font-size: 10px; letter-spacing: .14em; text-transform: uppercase; }
.nav-label { margin: 0 13px 10px; color: var(--subtle); font-size: 11px; font-weight: 700; letter-spacing: .12em; }
.tool-nav { display: flex; flex-direction: column; gap: 6px; }
.tool-nav a { display: flex; min-height: 48px; align-items: center; gap: 12px; padding: 9px 12px; color: #586477; border-radius: 12px; font-size: 14px; font-weight: 550; text-decoration: none; transition: color .18s ease, background .18s ease, transform .18s ease; }
.tool-nav a:hover { color: var(--text); background: var(--surface-soft); transform: translateX(2px); }
.tool-nav a.active { color: var(--primary); background: var(--primary-soft); }
.nav-icon { display: grid; width: 30px; height: 30px; place-items: center; }
.tool-nav a.active .nav-icon { color: var(--primary); }
.privacy-note { display: flex; align-items: flex-start; gap: 10px; margin-top: auto; padding: 15px; color: var(--success); border: 1px solid #d9eee6; border-radius: 14px; background: #f3fbf8; }
.privacy-note svg { flex: 0 0 auto; margin-top: 1px; }
.privacy-note strong, .privacy-note span { display: block; }
.privacy-note strong { font-size: 12px; }
.privacy-note span { color: #617f75; font-size: 10px; line-height: 1.45; }

.main-content { min-height: 100dvh; margin-left: 260px; padding: 42px clamp(30px, 5vw, 80px) 28px; }
.topbar { display: flex; max-width: 1050px; align-items: center; justify-content: space-between; margin: 0 auto 28px; }
.eyebrow { margin: 0 0 3px; color: var(--primary); font-size: 10px; font-weight: 750; letter-spacing: .18em; }
h1 { margin: 0; font-size: clamp(28px, 3vw, 38px); line-height: 1.2; letter-spacing: -.035em; }
.local-badge { display: flex; align-items: center; gap: 8px; padding: 8px 12px; color: #5f6c7f; border: 1px solid var(--line); border-radius: 999px; background: rgba(255,255,255,.66); font-size: 12px; font-weight: 600; }
.local-badge span { width: 7px; height: 7px; border-radius: 50%; background: #26a77a; box-shadow: 0 0 0 4px rgba(38,167,122,.12); }
.mobile-menu { display: none !important; }

.tool-page { display: none; max-width: 1050px; margin: 0 auto; animation: page-in .24s ease-out; }
.tool-page.active { display: block; }
@keyframes page-in { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }
.page-intro { display: flex; min-height: 50px; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
.page-intro p { max-width: 660px; margin: 0; color: var(--muted); }
.two-column { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 20px; }
.card { padding: clamp(22px, 3vw, 30px); border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.wide-card { max-width: 820px; }
.card-heading { display: flex; align-items: center; gap: 13px; margin-bottom: 26px; }
.card-heading h2 { margin: 0 0 2px; font-size: 18px; line-height: 1.35; }
.card-heading p { margin: 0; color: var(--muted); font-size: 12px; }
.step { display: grid; width: 42px; height: 42px; flex: 0 0 auto; place-items: center; color: var(--primary); border-radius: 12px; background: var(--primary-soft); font-size: 11px; font-weight: 800; letter-spacing: .05em; }
label, .editor-label { display: block; margin-bottom: 8px; color: #445066; font-size: 12px; font-weight: 700; }
input, textarea { width: 100%; color: var(--text); border: 1px solid #dce2eb; border-radius: 11px; outline: none; background: #fbfcfe; transition: border-color .18s ease, box-shadow .18s ease, background .18s ease; }
input { min-height: 48px; padding: 0 14px; }
textarea { min-height: 160px; padding: 14px; resize: vertical; }
input:focus, textarea:focus { border-color: #6d89e5; background: white; box-shadow: 0 0 0 3px rgba(49,87,213,.11); }
::placeholder { color: #abb3c1; }
.input-with-action { position: relative; }
.input-with-action input { padding-right: 65px; }
.inside, .input-with-action > .text-button { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); }
.primary-button, .secondary-button, .danger-button, .text-button, .icon-button { display: inline-flex; min-height: 44px; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 10px; font-weight: 650; transition: transform .15s ease, background .15s ease, box-shadow .15s ease; }
.primary-button { padding: 0 20px; color: white; background: var(--primary); box-shadow: 0 5px 14px rgba(49,87,213,.2); }
.primary-button:hover { background: var(--primary-dark); }
.primary-button:active, .secondary-button:active { transform: scale(.98); }
.secondary-button { padding: 0 15px; color: #40506a; border: 1px solid var(--line); background: var(--surface); }
.secondary-button:hover { background: var(--surface-soft); }
.danger-button { padding: 0 16px; color: white; background: var(--danger); }
.text-button { min-height: 38px; padding: 0 10px; color: var(--primary); background: transparent; font-size: 12px; }
.text-button:hover { background: var(--primary-soft); }
.icon-button { width: 44px; padding: 0; color: var(--muted); background: transparent; }
.icon-button:hover { background: var(--surface-soft); }
.full { width: 100%; margin-top: 14px; }
.compact { min-height: 40px; padding-inline: 16px; }
.result-box { min-height: 94px; margin-top: 18px; padding: 16px; overflow-wrap: anywhere; border: 1px dashed #d8deea; border-radius: 12px; background: var(--surface-soft); }
.result-box.tall { min-height: 120px; }
.result-placeholder { color: var(--subtle); font-size: 13px; }
.result-title { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; color: var(--muted); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; }
.result-main { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }
.result-detail { margin-top: 6px; color: var(--muted); font-size: 12px; }
.result-list { display: grid; gap: 8px; }
.result-row { display: flex; justify-content: space-between; gap: 15px; }
.result-row span { color: var(--muted); font-size: 12px; }
.result-row strong { text-align: right; font-size: 13px; font-variant-numeric: tabular-nums; }

.drop-zone { display: flex; min-height: 210px; align-items: center; justify-content: center; flex-direction: column; gap: 7px; margin: 0; color: var(--muted); border: 1.5px dashed #cbd4e3; border-radius: 14px; background: var(--surface-soft); cursor: pointer; transition: border-color .18s, background .18s; }
.drop-zone:hover, .drop-zone.dragging { border-color: var(--primary); background: var(--primary-soft); }
.drop-zone svg { width: 30px; height: 30px; margin-bottom: 5px; color: var(--primary); }
.drop-zone strong { color: var(--text); font-size: 14px; }
.drop-zone span { font-size: 11px; }
.qr-actions { display: flex; justify-content: center; margin-top: 14px; }
.camera-wrap { margin-top: 18px; }
.camera-wrap video { display: block; width: 100%; max-height: 420px; margin-bottom: 10px; border-radius: 12px; background: #0e1320; object-fit: cover; }
.qr-generator-card { margin-top: 20px; }
.qr-generator-layout { display: grid; grid-template-columns: minmax(0, 1fr) 280px; align-items: start; gap: 28px; }
.qr-generator-form textarea { min-height: 150px; }
.qr-output { display: flex; align-items: center; flex-direction: column; gap: 14px; }
.qr-preview { display: grid; width: 280px; min-height: 280px; place-items: center; padding: 20px; border: 1px dashed #d8deea; border-radius: 14px; background: var(--surface-soft); }
.qr-preview canvas, .qr-preview img { display: block; max-width: 100%; height: auto; }
.qr-output .secondary-button { width: 100%; }
.totp-card > label:not(:first-of-type) { margin-top: 16px; }
.field-hint { margin: 7px 0 16px; color: var(--muted); font-size: 11px; }
.totp-display { margin-top: 24px; padding: 22px; text-align: center; border-radius: 14px; background: var(--primary-soft); }
.totp-label { display: block; color: var(--muted); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .1em; }
.totp-code { min-height: 54px; margin: 6px 0 12px; padding: 0; color: var(--primary); border: 0; background: transparent; font: 750 clamp(30px,6vw,44px)/1 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .12em; }
.countdown-row { display: flex; align-items: center; gap: 12px; }
.countdown-track { height: 5px; flex: 1; overflow: hidden; border-radius: 10px; background: rgba(49,87,213,.14); }
.countdown-track span { display: block; height: 100%; transform-origin: left; background: var(--primary); }
#countdownText { min-width: 38px; color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.history-card { margin-top: 20px; }
.history-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.history-heading h2 { margin: 0 0 2px; font-size: 18px; }
.history-heading p { margin: 0; color: var(--muted); font-size: 12px; }
.danger-text { color: var(--danger); }
.danger-text:hover { color: var(--danger); background: #fff1f2; }
.totp-history { display: grid; gap: 10px; }
.history-empty { padding: 26px 16px; color: var(--subtle); border: 1px dashed #d8deea; border-radius: 12px; background: var(--surface-soft); font-size: 13px; text-align: center; }
.history-item { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 14px; padding: 13px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-soft); }
.history-account { min-width: 0; }
.history-account strong, .history-account span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-account strong { font-size: 13px; }
.history-account span { color: var(--muted); font-size: 11px; }
.history-code { min-width: 108px; min-height: 44px; padding: 0 10px; color: var(--primary); border: 0; border-radius: 9px; background: var(--primary-soft); font: 750 17px/1 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .06em; font-variant-numeric: tabular-nums; }
.history-actions { display: flex; gap: 4px; }
.history-actions .icon-button { width: 44px; height: 44px; }
.history-actions .delete-record { color: var(--danger); }
.segmented { display: inline-flex; margin-bottom: 22px; padding: 4px; border-radius: 11px; background: #eef1f6; }
.segmented button { min-width: 84px; min-height: 38px; padding: 0 15px; color: var(--muted); border: 0; border-radius: 8px; background: transparent; font-size: 13px; font-weight: 650; }
.segmented button.active { color: var(--text); background: white; box-shadow: 0 2px 7px rgba(34,54,98,.1); }
.editor-label { display: flex; align-items: center; justify-content: space-between; }
.editor-label .text-button { min-height: 30px; }
.editor-card > .primary-button { margin: 14px 0 18px; }
.inline-message { min-height: 20px; margin: 10px 0 0; color: var(--danger); font-size: 12px; }
.inline-message.success { color: var(--success); }
.editor-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 20px; }
.button-group { display: flex; flex-wrap: wrap; gap: 8px; }
.code-editor-wrap { display: grid; min-height: 390px; grid-template-columns: 48px minmax(0,1fr); overflow: hidden; border: 1px solid #dce2eb; border-radius: 12px; background: #fbfcfe; }
.code-editor-wrap:focus-within { border-color: #6d89e5; box-shadow: 0 0 0 3px rgba(49,87,213,.11); }
.line-numbers { padding: 15px 12px; overflow: hidden; color: #a1a9b8; border-right: 1px solid var(--line); background: #f4f6fa; font: 12px/1.65 ui-monospace, SFMono-Regular, Menlo, monospace; text-align: right; white-space: pre; }
.code-editor { min-height: 390px; padding: 14px 16px; border: 0; border-radius: 0; background: transparent; font: 13px/1.65 ui-monospace, SFMono-Regular, Menlo, monospace; resize: vertical; }
.code-editor:focus { box-shadow: none; background: transparent; }
footer { display: flex; max-width: 1050px; justify-content: space-between; gap: 15px; margin: 44px auto 0; padding-top: 20px; color: var(--subtle); border-top: 1px solid var(--line); font-size: 11px; }
.toast { position: fixed; left: 50%; bottom: 26px; z-index: 1000; padding: 11px 16px; color: white; border-radius: 10px; background: #202a3d; box-shadow: 0 10px 30px rgba(0,0,0,.18); font-size: 13px; opacity: 0; pointer-events: none; transform: translate(-50%, 12px); transition: opacity .2s, transform .2s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.scrim { position: fixed; inset: 0; z-index: 30; background: rgba(17,24,39,.35); backdrop-filter: blur(2px); }

:focus-visible { outline: 3px solid rgba(49,87,213,.38); outline-offset: 2px; }
@media (max-width: 850px) {
  .sidebar { transform: translateX(-100%); transition: transform .22s ease; }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; padding: 26px 20px; }
  .mobile-menu { display: inline-flex !important; flex: 0 0 auto; margin-right: 12px; }
  .topbar { justify-content: flex-start; }
  .local-badge { margin-left: auto; }
  .two-column { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .main-content { padding: 20px 14px; }
  .topbar { margin-bottom: 18px; }
  .eyebrow, .local-badge { display: none; }
  h1 { font-size: 25px; }
  .page-intro { align-items: flex-start; flex-direction: column; margin-bottom: 16px; }
  .card { padding: 20px 16px; border-radius: 15px; }
  .card-heading { margin-bottom: 21px; }
  .editor-toolbar, footer { align-items: flex-start; flex-direction: column; }
  .editor-toolbar .button-group:last-child { width: 100%; justify-content: space-between; }
  .code-editor-wrap { grid-template-columns: 38px minmax(0,1fr); }
  .line-numbers { padding-inline: 8px; }
  .totp-code { letter-spacing: .07em; }
  .history-item { grid-template-columns: minmax(0, 1fr) auto; gap: 10px; }
  .history-code { grid-column: 1; grid-row: 2; width: 100%; }
  .history-actions { grid-column: 2; grid-row: 1 / span 2; flex-direction: column; }
  .qr-generator-layout { grid-template-columns: 1fr; }
  .qr-preview { width: min(280px, 100%); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
