/* =========================================================================
   Oliver 統一登錄 · app.css
   ---------------------------------------------------------------------------
   方向：紙張感（米白 + 深墨），一個強調色 #0f766e，細邊框、極輕陰影，
   不用漸層、不用玻璃、不用發光。所有樣式都在這裡 —— CSP 只允許 'self'，
   沒有任何行內樣式。

   尺度：4px 基準（4 / 8 / 12 / 16 / 24 / 32 / 48），行高 1.6，
   圓角 10–12px，字型只用系統堆疊。
   ========================================================================= */

:root {
  /* 字型 */
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans TC",
    "PingFang TC", "Hiragino Sans TC", "Microsoft JhengHei", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
    "Liberation Mono", monospace;

  /* 間距 */
  --s1: 4px;
  --s2: 8px;
  --s3: 12px;
  --s4: 16px;
  --s5: 24px;
  --s6: 32px;
  --s7: 48px;

  /* 形狀 */
  --radius-sm: 8px;
  --radius: 10px;
  --radius-lg: 12px;

  /* 動態 */
  --dur: 150ms;
  --ease: ease;

  /* 版面 */
  --shell: 1120px;
  --readable: 640px;
}

/* ── 淺色（預設） ─────────────────────────────────────────────────────── */
:root {
  --bg: #faf9f6;
  --surface: #ffffff;
  --surface-2: #f4f2ec;
  --surface-3: #edeae1;
  --border: #e4e0d5;
  --border-strong: #cbc5b5;
  --text: #1a1a18;
  --text-soft: #3d3b34;
  --muted: #6a665b;
  --accent: #0f766e;
  --accent-strong: #0b5f59;
  --accent-soft: #e6f2f0;
  --on-accent: #ffffff;
  --danger: #b3261e;
  --danger-soft: #fbeceb;
  --ok: #15803d;
  --ok-soft: #e9f5ec;
  --warn: #b45309;
  --warn-soft: #fbf1e3;
  --shadow: 0 1px 2px rgba(0, 0, 0, .04);
  color-scheme: light;
}

/* ── 深色 ─────────────────────────────────────────────────────────────── */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14140f;
    --surface: #1c1c16;
    --surface-2: #23231c;
    --surface-3: #2b2b23;
    --border: #2f2f26;
    --border-strong: #46463a;
    --text: #e8e6df;
    --text-soft: #cfcbbf;
    --muted: #9c9788;
    --accent: #5ec9bd;
    --accent-strong: #85dbd1;
    --accent-soft: #17322f;
    --on-accent: #07211e;
    --danger: #f0837a;
    --danger-soft: #331b19;
    --ok: #7cc98d;
    --ok-soft: #16291b;
    --warn: #e0a458;
    --warn-soft: #2e2416;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
    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-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 {
  margin: 0;
  font-weight: 650;
  line-height: 1.3;
  letter-spacing: -.01em;
}

h1 { font-size: 1.375rem; }
h2 { font-size: 1.0625rem; }
h3 { font-size: .9375rem; }

p { margin: 0; }

a {
  color: var(--accent);
  text-decoration: none;
  text-underline-offset: 2px;
}

a:hover {
  text-decoration: underline;
}

code, kbd, samp, pre {
  font-family: var(--font-mono);
  font-size: .875em;
}

hr {
  height: 0;
  margin: var(--s5) 0;
  border: 0;
  border-top: 1px solid var(--border);
}

img, svg {
  max-width: 100%;
}

/* 可見焦點：改顏色，不移除 */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

::selection {
  background: var(--accent-soft);
  color: var(--text);
}

/* ── 頂欄 ─────────────────────────────────────────────────────────────── */
.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.site-header-inner {
  max-width: var(--shell);
  margin: 0 auto;
  padding: var(--s3) var(--s5);
  display: flex;
  align-items: center;
  gap: var(--s4);
  min-height: 60px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
  color: var(--text);
  font-weight: 650;
  font-size: .9375rem;
  letter-spacing: -.01em;
  flex: none;
}

.brand:hover {
  text-decoration: none;
  color: var(--text);
}

.brand img {
  width: 26px;
  height: 26px;
  display: block;
  border-radius: var(--radius-sm);
}

.site-nav {
  display: flex;
  align-items: center;
  gap: var(--s1);
  margin-left: auto;
  min-width: 0;
}

.site-nav a {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 var(--s3);
  border-radius: var(--radius-sm);
  color: var(--text-soft);
  font-size: .875rem;
  font-weight: 550;
  white-space: nowrap;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}

.site-nav a:hover {
  background: var(--surface-2);
  color: var(--text);
  text-decoration: none;
}

.site-nav a[aria-current="page"] {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.site-nav .nav-sep {
  width: 1px;
  height: 20px;
  margin: 0 var(--s1);
  background: var(--border);
  flex: none;
}

.site-nav .nav-user {
  max-width: 14em;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--muted);
  font-weight: 500;
  padding: 0 var(--s2);
}

/* ── 主體 ─────────────────────────────────────────────────────────────── */
.site-main {
  flex: 1 0 auto;
  width: 100%;
  max-width: var(--shell);
  margin: 0 auto;
  padding: var(--s6) var(--s5) var(--s7);
}

/* 置中窄版（登入、授權、錯誤頁） */
.main-center {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100dvh - 232px);
}

.stack {
  display: flex;
  flex-direction: column;
  gap: var(--s5);
  min-width: 0;
}

.stack-tight {
  display: flex;
  flex-direction: column;
  gap: var(--s3);
  min-width: 0;
}

/* ── 頁腳 ─────────────────────────────────────────────────────────────── */
.site-footer {
  border-top: 1px solid var(--border);
  padding: var(--s4) var(--s5);
  color: var(--muted);
  font-size: .8125rem;
}

.site-footer-inner {
  max-width: var(--shell);
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: var(--s2) var(--s4);
  align-items: baseline;
}

.site-footer .foot-tagline {
  margin-left: auto;
}

/* ── flash ────────────────────────────────────────────────────────────── */
.flash {
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}

.flash-inner {
  max-width: var(--shell);
  margin: 0 auto;
  padding: var(--s3) var(--s5);
  display: flex;
  align-items: flex-start;
  gap: var(--s3);
  font-size: .875rem;
  color: var(--text-soft);
}

.flash .flash-mark {
  flex: none;
  width: 8px;
  height: 8px;
  margin-top: .55em;
  border-radius: 50%;
  background: var(--accent);
}

.flash-err {
  background: var(--danger-soft);
}

.flash-err .flash-mark {
  background: var(--danger);
}

.flash-err .flash-inner {
  color: var(--danger);
}

/* ── 卡片 ─────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: var(--s5);
}

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--s4);
  margin-bottom: var(--s4);
}

.card-head > div {
  min-width: 0;
}

.card-head h2 {
  margin-bottom: var(--s1);
}

.card-sub {
  color: var(--muted);
  font-size: .875rem;
}

.card-narrow {
  width: 100%;
  max-width: 420px;
}

.card-plain {
  box-shadow: none;
  background: transparent;
  border: 0;
  padding: 0;
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s4);
  margin-bottom: var(--s3);
}

.section-head h2 {
  font-size: 1rem;
}

.section-head .section-link {
  font-size: .875rem;
}

/* ── 按鈕 ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
  min-height: 40px;
  padding: 0 var(--s4);
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: .9375rem;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease),
    color var(--dur) var(--ease);
}

.btn:hover {
  text-decoration: none;
  background: var(--surface-3);
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}

.btn-primary:hover {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
  color: var(--on-accent);
}

.btn-secondary {
  background: var(--surface);
  border-color: var(--border-strong);
  color: var(--text);
}

.btn-secondary:hover {
  background: var(--surface-2);
}

.btn-quiet {
  background: transparent;
  border-color: transparent;
  color: var(--text-soft);
  font-weight: 550;
}

.btn-quiet:hover {
  background: var(--surface-2);
  color: var(--text);
}

.btn-danger {
  background: var(--surface);
  border-color: var(--border-strong);
  color: var(--danger);
}

.btn-danger:hover {
  background: var(--danger-soft);
  border-color: var(--danger);
}

.btn-sm {
  min-height: 32px;
  padding: 0 var(--s3);
  font-size: .8125rem;
  border-radius: var(--radius-sm);
}

.btn-block {
  width: 100%;
}

.btn:disabled {
  opacity: .55;
  cursor: not-allowed;
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s2);
}

.btn-row-end {
  justify-content: flex-end;
}

.btn-row-center {
  justify-content: center;
}

/* ── 管理台分頁列 ─────────────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: var(--s1);
  overflow-x: auto;
  border-bottom: 1px solid var(--border);
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar {
  display: none;
}

.tabs a {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0 var(--s3);
  margin-bottom: -1px;
  border-bottom: 2px solid transparent;
  color: var(--text-soft);
  font-size: .875rem;
  font-weight: 600;
  white-space: nowrap;
  transition: color var(--dur) var(--ease), border-color var(--dur) var(--ease),
    background var(--dur) var(--ease);
}

.tabs a:hover {
  background: var(--surface-2);
  color: var(--text);
  text-decoration: none;
}

.tabs a[aria-current="page"] {
  border-bottom-color: var(--accent);
  color: var(--accent-strong);
}

/* ── 表單 ─────────────────────────────────────────────────────────────── */
.form {
  display: flex;
  flex-direction: column;
  gap: var(--s4);
}

.field {
  display: flex;
  flex-direction: column;
  gap: var(--s2);
  min-width: 0;
}

.field > label,
.field > .label {
  font-size: .8125rem;
  font-weight: 600;
  color: var(--text-soft);
  letter-spacing: .01em;
}

.hint,
.field .hint {
  display: block;
  font-size: .8125rem;
  color: var(--muted);
  line-height: 1.5;
  font-weight: 400;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"],
input[type="number"],
input[type="url"],
input[type="tel"],
select,
textarea {
  width: 100%;
  min-height: 40px;
  padding: var(--s2) var(--s3);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: .9375rem;
  line-height: 1.4;
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}

textarea {
  min-height: 96px;
  resize: vertical;
  font-family: var(--font-mono);
  font-size: .875rem;
  line-height: 1.55;
}

select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) calc(50% + 1px), calc(100% - 13px) calc(50% + 1px);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: var(--s6);
}

input::placeholder,
textarea::placeholder {
  color: var(--muted);
  opacity: .75;
}

input:hover:not(:disabled),
select:hover:not(:disabled),
textarea:hover:not(:disabled) {
  border-color: var(--muted);
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  outline: 2px solid var(--accent);
  outline-offset: 0;
  background: var(--surface);
}

input:disabled,
select:disabled,
textarea:disabled,
input[readonly] {
  background: var(--surface-2);
  color: var(--muted);
  cursor: default;
}

.field-error {
  font-size: .8125rem;
  color: var(--danger);
}

.form-error {
  display: flex;
  gap: var(--s2);
  padding: var(--s3) var(--s4);
  border: 1px solid var(--danger);
  border-radius: var(--radius);
  background: var(--danger-soft);
  color: var(--danger);
  font-size: .875rem;
  line-height: 1.5;
}

.form-error strong {
  font-weight: 700;
}

.check {
  display: flex;
  align-items: flex-start;
  gap: var(--s2);
  font-size: .875rem;
  color: var(--text-soft);
  cursor: pointer;
}

.check input[type="checkbox"],
.check input[type="radio"] {
  flex: none;
  width: 18px;
  height: 18px;
  min-height: 0;
  margin: .18em 0 0;
  accent-color: var(--accent);
  cursor: pointer;
}

.check .check-text {
  min-width: 0;
}

.check-group {
  display: flex;
  flex-direction: column;
  gap: var(--s2);
  padding: var(--s3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
}

fieldset {
  margin: 0;
  padding: 0;
  border: 0;
  min-width: 0;
}

legend {
  padding: 0;
  font-size: .8125rem;
  font-weight: 600;
  color: var(--text-soft);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--s4);
}

.form-grid .field-span {
  grid-column: 1 / -1;
}

.form-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s3);
  flex-wrap: wrap;
}

.form-note {
  font-size: .875rem;
  color: var(--muted);
}

.form-note a {
  font-weight: 600;
}

/* 密碼規則提示 */
.rules {
  margin: 0;
  padding: 0 0 0 var(--s4);
  color: var(--muted);
  font-size: .8125rem;
  line-height: 1.55;
}

.rules li {
  margin: var(--s1) 0;
}

/* ── 表格 ─────────────────────────────────────────────────────────────── */
.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow);
}

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
}

table.data caption {
  caption-side: top;
  text-align: left;
  padding: var(--s3) var(--s4) 0;
  color: var(--muted);
  font-size: .8125rem;
}

table.data th,
table.data td {
  padding: var(--s3) var(--s4);
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid var(--border);
}

table.data thead th {
  font-size: .6875rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
  background: var(--surface);
  border-bottom: 1px solid var(--border-strong);
}

table.data tbody tr:last-child td {
  border-bottom: 0;
}

table.data tbody tr:hover td {
  background: var(--surface-2);
}

table.data.is-dense th,
table.data.is-dense td {
  padding: var(--s2) var(--s3);
}

table.data td.num,
table.data th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

table.data .cell-actions {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  min-width: 9.5em;
}

table.data .cell-actions .btn,
table.data .cell-actions .disclosure {
  width: 100%;
}

table.data .cell-actions .dim {
  text-align: center;
}

/* 表格內「識別碼 + 複製」同一行 */
.copy-inline {
  display: flex;
  align-items: center;
  gap: var(--s1);
  flex-wrap: wrap;
}

.copy-inline .btn {
  flex: none;
}

/* 表格欄寬下限：讓長字串自己換行，而不是把欄位壓成一行一字 */
table.data td.cell-name {
  min-width: 10em;
}

table.data td.cell-name .badge {
  margin-left: var(--s1);
  vertical-align: 1px;
}

table.data td.cell-device {
  min-width: 12em;
  max-width: 26em;
}

table.data td.cell-uri {
  min-width: 16em;
  max-width: 30em;
}

/* 原始 UA：兩行截斷，完整字串在 title */
.ua-raw {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-top: var(--s1);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: .75rem;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

table.data .cell-form {
  display: inline;
  margin: 0;
}

.mono {
  font-family: var(--font-mono);
  font-size: .8125rem;
  letter-spacing: -.01em;
}

.wrap-anywhere {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.ua {
  display: block;
  max-width: 26em;
  color: var(--text-soft);
  font-size: .8125rem;
  overflow-wrap: anywhere;
}

.timestamp {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  color: var(--text-soft);
}

.dim {
  color: var(--muted);
}

/* ── 徽章 ─────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--s1);
  padding: 2px var(--s2);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--text-soft);
  font-size: .75rem;
  font-weight: 600;
  line-height: 1.5;
  white-space: nowrap;
}

.badge-ok {
  border-color: var(--ok);
  background: var(--ok-soft);
  color: var(--ok);
}

.badge-off {
  border-color: var(--border-strong);
  background: var(--surface-2);
  color: var(--muted);
}

.badge-warn {
  border-color: var(--warn);
  background: var(--warn-soft);
  color: var(--warn);
}

.badge-accent {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.badge-current {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-strong);
}

/* ── 統計卡 ───────────────────────────────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--s4);
}

.stat {
  padding: var(--s4) var(--s5);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow);
  min-width: 0;
}

.stat-label {
  display: block;
  color: var(--muted);
  font-size: .75rem;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.stat-value {
  display: block;
  margin-top: var(--s2);
  font-size: 1.625rem;
  font-weight: 650;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.02em;
}

.stat-value-sm {
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0;
  line-height: 1.5;
  padding-top: var(--s1);
}

/* ── 清單 ─────────────────────────────────────────────────────────────── */
.list {
  margin: 0;
  padding: 0;
  list-style: none;
  border-top: 1px solid var(--border);
}

.list li {
  display: flex;
  align-items: baseline;
  gap: var(--s4);
  padding: var(--s3) 0;
  border-bottom: 1px solid var(--border);
  font-size: .875rem;
}

.list li:last-child {
  border-bottom: 0;
}

.list .item-main {
  min-width: 0;
  flex: 1;
}

.list .item-title {
  font-weight: 550;
  color: var(--text);
  overflow-wrap: anywhere;
}

.list .item-meta {
  margin-left: var(--s2);
  color: var(--muted);
  font-size: .8125rem;
}

.list .item-when {
  flex: none;
  color: var(--muted);
  font-size: .8125rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* 定義清單（帳戶資訊、稽核細節） */
.facts {
  margin: 0;
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: var(--s2) var(--s5);
  font-size: .875rem;
}

.facts dt {
  color: var(--muted);
}

.facts dd {
  margin: 0;
  color: var(--text);
  overflow-wrap: anywhere;
}

/* ── 授權頁 ───────────────────────────────────────────────────────────── */
.consent-client {
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding-bottom: var(--s4);
  border-bottom: 1px solid var(--border);
}

.consent-client-mark {
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: var(--radius);
  border: 1px solid var(--border-strong);
  background: var(--accent-soft);
  color: var(--accent-strong);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 1rem;
  text-transform: uppercase;
  user-select: none;
}

.consent-client-name {
  font-weight: 650;
  font-size: 1rem;
  overflow-wrap: anywhere;
}

.consent-client-id {
  color: var(--muted);
  font-size: .75rem;
  font-family: var(--font-mono);
  overflow-wrap: anywhere;
}

.scope-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--s3);
}

.scope-list li {
  display: flex;
  gap: var(--s3);
  align-items: flex-start;
  font-size: .9375rem;
  color: var(--text-soft);
}

.scope-list .scope-tick {
  flex: none;
  width: 18px;
  height: 18px;
  margin-top: .2em;
  border-radius: 50%;
  border: 1.5px solid var(--accent);
  position: relative;
}

.scope-list .scope-tick::after {
  content: "";
  position: absolute;
  left: 5px;
  top: 3px;
  width: 5px;
  height: 8px;
  border: solid var(--accent);
  border-width: 0 1.5px 1.5px 0;
  transform: rotate(40deg);
}

.scope-list .scope-name {
  display: block;
  font-family: var(--font-mono);
  font-size: .75rem;
  color: var(--muted);
}

.consent-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s3);
}

.consent-note {
  margin-top: var(--s4);
  padding-top: var(--s4);
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: .8125rem;
  line-height: 1.55;
}

/* ── 一次性 secret ────────────────────────────────────────────────────── */
.secret-box {
  border: 1px solid var(--warn);
  border-radius: var(--radius-lg);
  background: var(--warn-soft);
  padding: var(--s4) var(--s5);
}

.secret-box h2 {
  color: var(--warn);
  font-size: .9375rem;
  margin-bottom: var(--s2);
}

.secret-box p {
  font-size: .875rem;
  color: var(--text-soft);
}

.secret-row {
  display: flex;
  align-items: stretch;
  gap: var(--s2);
  margin-top: var(--s3);
  flex-wrap: wrap;
}

.secret-value {
  flex: 1 1 16em;
  min-width: 0;
  display: flex;
  align-items: center;
  padding: var(--s2) var(--s3);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  font-family: var(--font-mono);
  font-size: .8125rem;
  overflow-wrap: anywhere;
  user-select: all;
}

.secret-meta {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: var(--s1) var(--s4);
  margin-top: var(--s3);
  font-size: .8125rem;
}

.secret-meta dt {
  color: var(--muted);
}

.secret-meta dd {
  margin: 0;
  font-family: var(--font-mono);
  overflow-wrap: anywhere;
}

/* 純文字代碼塊（TOTP secret / otpauth URI） */
.code-block {
  display: block;
  padding: var(--s3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  font-family: var(--font-mono);
  font-size: .8125rem;
  line-height: 1.6;
  overflow-wrap: anywhere;
  word-break: break-all;
  user-select: all;
}

.code-block-tall {
  max-height: 9.5em;
  overflow-y: auto;
}

/* ── 分頁 ─────────────────────────────────────────────────────────────── */
.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s4);
  flex-wrap: wrap;
  margin-top: var(--s4);
  font-size: .875rem;
  color: var(--muted);
}

.pager-links {
  display: flex;
  gap: var(--s2);
}

/* ── 工具列 / 篩選 ────────────────────────────────────────────────────── */
.toolbar {
  display: flex;
  align-items: flex-end;
  gap: var(--s3);
  flex-wrap: wrap;
  margin-bottom: var(--s4);
}

.toolbar .field {
  min-width: 12em;
}

.toolbar .field-grow {
  flex: 1 1 16em;
}

.toolbar .btn {
  margin-bottom: 0;
}

.inline-form {
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
  margin: 0;
}

/* <details> 的 inline 展開區 */
.disclosure {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  padding: var(--s2) var(--s3);
  min-width: 0;
  width: 100%;
  margin-top: var(--s2);
}

.disclosure > summary {
  cursor: pointer;
  font-size: .8125rem;
  font-weight: 600;
  color: var(--text-soft);
  list-style: none;
  display: flex;
  align-items: center;
  gap: var(--s2);
  min-height: 26px;
}

.disclosure > summary::-webkit-details-marker {
  display: none;
}

.disclosure > summary::before {
  content: "";
  width: 6px;
  height: 6px;
  border: solid var(--muted);
  border-width: 0 1.5px 1.5px 0;
  transform: rotate(-45deg);
  transition: transform var(--dur) var(--ease);
  flex: none;
}

.disclosure[open] > summary::before {
  transform: rotate(45deg);
}

.disclosure[open] > summary {
  margin-bottom: var(--s3);
}

.disclosure .disclosure-body {
  display: flex;
  flex-direction: column;
  gap: var(--s2);
}

.disclosure input[type="password"] {
  min-height: 34px;
  font-size: .875rem;
}

/* ── 提示條（說明文字區塊） ──────────────────────────────────────────── */
.note {
  padding: var(--s3) var(--s4);
  border-left: 3px solid var(--border-strong);
  background: var(--surface-2);
  border-radius: 0 var(--radius) var(--radius) 0;
  color: var(--text-soft);
  font-size: .875rem;
  line-height: 1.55;
}

.note-lead {
  display: block;
}

.note-accent {
  border-left-color: var(--accent);
  background: var(--accent-soft);
  color: var(--text-soft);
}

.note-warn {
  border-left-color: var(--warn);
  background: var(--warn-soft);
}

/* ── 空狀態 ───────────────────────────────────────────────────────────── */
.empty {
  padding: var(--s6) var(--s4);
  text-align: center;
  color: var(--muted);
  font-size: .875rem;
}

.empty-title {
  display: block;
  color: var(--text-soft);
  font-weight: 600;
  margin-bottom: var(--s1);
}

/* ── 錯誤頁 ───────────────────────────────────────────────────────────── */
.error-page {
  width: 100%;
  max-width: 480px;
  text-align: center;
  padding: var(--s6) 0;
}

.error-code {
  display: block;
  font-size: 3.5rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -.03em;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
}

.error-message {
  margin: var(--s4) 0 var(--s5);
  color: var(--text-soft);
  font-size: .9375rem;
  line-height: 1.6;
  overflow-wrap: anywhere;
}

/* ── 小工具 ───────────────────────────────────────────────────────────── */
.muted { color: var(--muted); }
.small { font-size: .8125rem; }
.strong { font-weight: 650; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.center { text-align: center; }
.hidden { display: none; }
.spacer { flex: 1 1 auto; }
.mt-0 { margin-top: 0; }
.mt-3 { margin-top: var(--s3); }
.mt-4 { margin-top: var(--s4); }
.mt-5 { margin-top: var(--s5); }
.mb-0 { margin-bottom: 0; }
.mb-3 { margin-bottom: var(--s3); }
.mb-4 { margin-bottom: var(--s4); }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* 跳到主要內容：只有鍵盤聚焦時才出現 */
.visually-hidden:focus,
.visually-hidden:focus-visible {
  position: static;
  display: inline-block;
  width: auto;
  height: auto;
  margin: var(--s2);
  padding: var(--s2) var(--s3);
  overflow: visible;
  clip: auto;
  clip-path: none;
  white-space: normal;
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--accent-strong);
  font-size: .875rem;
  font-weight: 600;
}

/* 兩欄：主內容 + 側欄 */
.split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: var(--s5);
  align-items: start;
}

.side-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: var(--s2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.side-nav a {
  display: flex;
  align-items: center;
  min-height: 38px;
  padding: 0 var(--s3);
  border-radius: var(--radius-sm);
  color: var(--text-soft);
  font-size: .875rem;
  font-weight: 550;
}

.side-nav a:hover {
  background: var(--surface-2);
  color: var(--text);
  text-decoration: none;
}

.side-nav a[aria-current="page"] {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

/* 複製按鈕回饋（JS 加上去的 class） */
.copy-btn.is-copied {
  border-color: var(--accent);
  color: var(--accent-strong);
  background: var(--accent-soft);
}

/* ── 響應式：<= 720px ─────────────────────────────────────────────────── */
@media (max-width: 720px) {
  .site-header-inner {
    padding: var(--s2) var(--s4);
    gap: var(--s3);
    min-height: 56px;
    flex-wrap: nowrap;
  }

  .site-header {
    position: static;
  }

  .site-nav {
    gap: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .site-nav::-webkit-scrollbar {
    display: none;
  }

  .site-nav a {
    padding: 0 var(--s2);
    font-size: .8125rem;
    min-height: 34px;
  }

  .site-nav .nav-user {
    display: none;
  }

  .site-nav .nav-sep {
    margin: 0 2px;
  }

  .site-main {
    padding: var(--s5) var(--s4) var(--s6);
  }

  .main-center {
    min-height: 0;
    padding-top: 0;
  }

  .site-footer-inner {
    padding: 0;
  }

  .site-footer .foot-tagline {
    margin-left: 0;
    flex-basis: 100%;
  }

  .stat-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: var(--s3);
  }

  .form-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .split {
    grid-template-columns: minmax(0, 1fr);
  }

  .side-nav {
    flex-direction: row;
    overflow-x: auto;
    padding: var(--s1);
    gap: var(--s1);
  }

  .side-nav a {
    min-height: 34px;
    white-space: nowrap;
  }

  .card {
    padding: var(--s4);
  }

  .consent-actions {
    grid-template-columns: minmax(0, 1fr);
  }

  .facts {
    grid-template-columns: minmax(0, 1fr);
    gap: var(--s1);
  }

  .facts dd {
    margin-bottom: var(--s2);
  }

  .list li {
    flex-wrap: wrap;
    gap: var(--s1) var(--s3);
  }

  .list .item-when {
    flex-basis: 100%;
  }

  .pager {
    justify-content: flex-start;
  }

  .ua {
    max-width: 18em;
  }
}

/* ── 動態偏好 ─────────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: .01ms !important;
    animation-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ── 列印 ─────────────────────────────────────────────────────────────── */
@media print {
  .site-header,
  .site-footer,
  .flash,
  .btn,
  .side-nav {
    display: none !important;
  }

  body {
    background: #fff;
    color: #000;
  }

  .card,
  .table-wrap {
    box-shadow: none;
  }
}
