:root {
  color-scheme: light;
  --bg: #eef4fa;
  --bg-deep: #e3ebf4;
  --surface: rgba(255, 255, 255, 0.9);
  --surface-solid: #ffffff;
  --surface-soft: #f5f8fc;
  --surface-blue: #e9f0f8;
  --ink: #20364f;
  --ink-soft: #3b516d;
  --muted: #586c83;
  --faint: #7a8ca0;
  --line: #d5dfe9;
  --line-strong: #b8c8da;
  --blue: #38618e;
  --blue-strong: #264e7c;
  --blue-soft: #dfe9f5;
  --blue-pale: #f1f5fb;
  --ornament: #9babbc;
  --primary-top: #355574;
  --primary-bottom: #243e5e;
  --cyan: #6abfe5;
  --danger: #9f4157;
  --danger-soft: #fff0f3;
  --success: #28765f;
  --shadow-sm: 0 8px 24px rgba(45, 73, 108, 0.08);
  --shadow-md: 0 22px 60px rgba(36, 65, 101, 0.14);
  --radius-sm: 12px;
  --radius-md: 18px;
  --radius-lg: 26px;
  --font-sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", "Noto Sans Mono CJK SC", monospace;
  --font-display: "Noto Serif SC", "Songti SC", "STSong", "Noto Serif CJK SC", Georgia, serif;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b1425;
  --bg-deep: #111e33;
  --surface: rgba(20, 34, 56, 0.94);
  --surface-solid: #142238;
  --surface-soft: #192b45;
  --surface-blue: #1c304c;
  --ink: #f1f4f8;
  --ink-soft: #d4deeb;
  --muted: #b1bdcc;
  --faint: #8899af;
  --line: #2d405b;
  --line-strong: #52637c;
  --blue: #9ac0e7;
  --blue-strong: #c3d9ef;
  --blue-soft: #263e5b;
  --blue-pale: #172b43;
  --ornament: #c4bbaa;
  --cyan: #69c5e9;
  --danger: #ef8293;
  --danger-soft: #3d2029;
  --success: #69c5a7;
  --shadow-sm: 0 8px 26px rgba(0, 0, 0, 0.18);
  --shadow-md: 0 24px 70px rgba(0, 0, 0, 0.36);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    color-scheme: dark;
    --bg: #0b1425;
    --bg-deep: #111e33;
    --surface: rgba(20, 34, 56, 0.94);
    --surface-solid: #142238;
    --surface-soft: #192b45;
    --surface-blue: #1c304c;
    --ink: #f1f4f8;
    --ink-soft: #d4deeb;
    --muted: #b1bdcc;
    --faint: #8899af;
    --line: #2d405b;
    --line-strong: #52637c;
    --blue: #9ac0e7;
    --blue-strong: #c3d9ef;
    --blue-soft: #263e5b;
    --blue-pale: #172b43;
    --ornament: #c4bbaa;
    --cyan: #69c5e9;
    --danger: #ef8293;
    --danger-soft: #3d2029;
    --success: #69c5a7;
    --shadow-sm: 0 8px 26px rgba(0, 0, 0, 0.18);
    --shadow-md: 0 24px 70px rgba(0, 0, 0, 0.36);
  }
}

:root[data-theme="cream"] {
  color-scheme: light;
  --bg: #f7f3eb;
  --bg-deep: #ece5d9;
  --surface: rgba(255, 252, 246, 0.94);
  --surface-solid: #fffcf6;
  --surface-soft: #f5efe4;
  --surface-blue: #eee9df;
  --ink: #273548;
  --ink-soft: #4c5360;
  --muted: #70675c;
  --faint: #887a66;
  --line: #ddd3c1;
  --line-strong: #b6a68d;
  --blue: #425970;
  --blue-strong: #2d455f;
  --blue-soft: #e4e6e6;
  --blue-pale: #f1ede5;
  --ornament: #aa8b5e;
  --primary-top: #465b72;
  --primary-bottom: #293d52;
  --danger: #9e4c51;
  --danger-soft: #f7e9e5;
  --success: #427260;
  --shadow-sm: 0 5px 18px rgba(95, 77, 48, 0.06);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
  font-family: var(--font-sans);
  -webkit-text-size-adjust: 100%;
}

body {
  min-width: 320px;
  min-height: 100dvh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 5%, color-mix(in srgb, var(--ornament) 12%, transparent), transparent 32rem),
    radial-gradient(circle at 92% 92%, color-mix(in srgb, var(--blue) 7%, transparent), transparent 36rem), var(--bg);
  font-size: 16px;
  line-height: 1.5;
  overflow-x: hidden;
}

button,
input,
textarea,
select {
  font: inherit;
}

button,
a,
input,
textarea,
select {
  -webkit-tap-highlight-color: transparent;
}

button {
  color: inherit;
}

button:not(:disabled),
a {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.52;
}

input,
textarea,
select {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  outline: none;
  color: var(--ink);
  background: var(--surface-solid);
  padding: 0.72rem 0.85rem;
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease,
    background 160ms ease;
}

textarea {
  min-height: 8rem;
  resize: vertical;
  line-height: 1.65;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(53, 121, 201, 0.14);
}

input::placeholder,
textarea::placeholder {
  color: var(--faint);
}

svg {
  width: 1.2rem;
  height: 1.2rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

[hidden] {
  display: none !important;
}

.icon-defs {
  position: fixed;
  width: 0;
  height: 0;
  overflow: hidden;
  pointer-events: none;
}

.ambient {
  position: fixed;
  z-index: -1;
  width: 28rem;
  height: 28rem;
  border-radius: 50%;
  filter: blur(12px);
  opacity: 0.42;
  pointer-events: none;
}

.ambient-one {
  top: -15rem;
  left: -13rem;
  background: rgba(104, 193, 236, 0.22);
}

.ambient-two {
  right: -16rem;
  bottom: -17rem;
  background: rgba(85, 115, 203, 0.17);
}

.primary-button,
.secondary-button,
.ghost-button,
.danger-button,
.small-button,
.text-button {
  min-height: 44px;
  border-radius: 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.48rem;
  border: 1px solid transparent;
  padding: 0.65rem 1rem;
  font-weight: 680;
  text-decoration: none;
  transition:
    transform 150ms ease,
    box-shadow 150ms ease,
    background 150ms ease,
    border-color 150ms ease;
}

.primary-button {
  color: #fff;
  background: linear-gradient(135deg, var(--primary-top), var(--primary-bottom));
  box-shadow: 0 8px 22px rgba(40, 105, 181, 0.22);
}

.primary-button:hover {
  box-shadow: 0 10px 28px rgba(40, 105, 181, 0.3);
  transform: translateY(-1px);
}

.primary-button:active,
.secondary-button:active,
.ghost-button:active,
.small-button:active {
  transform: translateY(0);
}

.secondary-button {
  color: var(--blue-strong);
  border-color: var(--line-strong);
  background: var(--surface-solid);
}

.secondary-button:hover {
  border-color: var(--blue);
  background: var(--blue-pale);
}

.ghost-button {
  border-color: var(--line);
  background: transparent;
  color: var(--ink-soft);
}

.ghost-button:hover {
  background: var(--surface-soft);
  border-color: var(--line-strong);
}

.danger-button {
  color: #fff;
  background: var(--danger);
}

.small-button {
  min-height: 38px;
  border-color: var(--line);
  background: var(--surface-soft);
  color: var(--ink-soft);
  padding: 0.45rem 0.72rem;
  font-size: 0.875rem;
}

.small-button:hover {
  color: var(--blue-strong);
  border-color: var(--blue);
  background: var(--blue-pale);
}

.text-button {
  width: fit-content;
  min-height: 40px;
  margin: 0 auto;
  background: transparent;
  color: var(--blue-strong);
  font-weight: 600;
}

.icon-button {
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 13px;
  color: var(--ink-soft);
  background: var(--surface);
  transition:
    background 150ms ease,
    color 150ms ease,
    border-color 150ms ease,
    transform 150ms ease;
}

.icon-button:hover {
  color: var(--blue-strong);
  border-color: var(--line-strong);
  background: var(--surface-blue);
}

.full-button {
  width: 100%;
}

.lock-screen {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: max(1.25rem, env(safe-area-inset-top)) 1.25rem max(1.25rem, env(safe-area-inset-bottom));
}

.lock-card {
  --lock-spark: var(--cyan);
  width: min(100%, 430px);
  border: 1px solid var(--line);
  border-radius: 32px;
  padding: 1.6rem;
  background: var(--surface);
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
}

:root[data-theme="cream"] .lock-card {
  --lock-spark: var(--ornament);
}

.lock-visual {
  position: relative;
  height: 225px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 24px;
  background:
    radial-gradient(circle at 50% 62%, color-mix(in srgb, var(--lock-spark) 21%, transparent), transparent 42%),
    linear-gradient(180deg, var(--surface-blue), var(--surface-soft));
}

.lock-visual img {
  position: relative;
  z-index: 2;
  width: 210px;
  height: 210px;
  object-fit: contain;
  filter: drop-shadow(0 18px 22px rgba(28, 55, 88, 0.2));
}

.orbit {
  position: absolute;
  border: 1px solid color-mix(in srgb, var(--lock-spark) 40%, var(--line));
  border-radius: 50%;
}

.orbit::before {
  content: "";
  position: absolute;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--lock-spark);
  box-shadow: 0 0 16px color-mix(in srgb, var(--lock-spark) 70%, transparent);
}

.orbit-one {
  width: 250px;
  height: 126px;
  transform: rotate(-8deg);
}

.orbit-one::before {
  top: 17px;
  right: 28px;
}

.orbit-two {
  width: 175px;
  height: 205px;
  transform: rotate(22deg);
}

.orbit-two::before {
  bottom: 26px;
  left: 15px;
}

.lock-copy {
  text-align: center;
  padding: 1.25rem 0 0.9rem;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 660;
  letter-spacing: 0.02em;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 4px rgba(47, 139, 114, 0.12);
}

.lock-copy h1 {
  margin: 0.35rem 0 0;
  font-size: clamp(1.9rem, 6vw, 2.35rem);
  letter-spacing: -0.045em;
}

.lock-copy p {
  margin: 0.4rem 0 0;
  color: var(--muted);
}

.lock-form {
  display: grid;
  gap: 0.85rem;
}

.biometric-unlock-area {
  display: grid;
  gap: 0.72rem;
}

.biometric-unlock-area .secondary-button {
  min-height: 48px;
  border-color: rgba(53, 121, 201, 0.32);
  background: var(--blue-pale);
}

.biometric-unlock-area .secondary-button svg {
  width: 1.35rem;
  height: 1.35rem;
}

.lock-divider {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 0.65rem;
  color: var(--faint);
  font-size: 0.76rem;
}

.lock-divider::before,
.lock-divider::after {
  content: "";
  height: 1px;
  background: var(--line);
}

.field {
  display: grid;
  gap: 0.4rem;
  color: var(--ink-soft);
  font-size: 0.9rem;
  font-weight: 650;
}

.field > span:first-child {
  padding-left: 0.1rem;
}

.field em {
  color: var(--muted);
  font-size: 0.78rem;
  font-style: normal;
  font-weight: 520;
}

.clearable-input-wrap {
  position: relative;
  display: block;
  min-width: 0;
}

.clearable-input-wrap > input,
.clearable-input-wrap > textarea {
  padding-right: 2.8rem;
}

.field-clear-button {
  position: absolute;
  top: 50%;
  right: 4px;
  width: 36px;
  height: 36px;
  min-height: 36px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 9px;
  color: var(--faint);
  background: transparent;
}

.field-clear-button:hover,
.field-clear-button:focus-visible {
  color: var(--blue-strong);
  background: var(--blue-soft);
}

.field-clear-button svg {
  width: 0.95rem;
  height: 0.95rem;
}

.clearable-input-wrap > .field-clear-button {
  transform: translateY(-50%);
}

.clearable-textarea-wrap > .field-clear-button {
  top: 6px;
  transform: none;
}

.password-wrap {
  position: relative;
  display: block;
}

.password-wrap input {
  padding-right: 3.4rem;
}

.field-eye {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 40px;
  height: 40px;
  min-height: 40px;
  border: 0;
  background: transparent;
}

.setup-note,
.smart-result-note {
  display: flex;
  align-items: flex-start;
  gap: 0.7rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--blue-pale);
  padding: 0.8rem 0.9rem;
  color: var(--ink-soft);
  font-size: 0.84rem;
  font-weight: 520;
}

.setup-note svg,
.smart-result-note svg {
  flex: 0 0 1.15rem;
  margin-top: 0.05rem;
  color: var(--blue);
}

.field-error {
  min-height: 1.2rem;
  margin: 0;
  color: var(--danger);
  font-size: 0.82rem;
  font-weight: 580;
}

.app-shell {
  min-height: 100dvh;
}

.topbar {
  position: sticky;
  z-index: 20;
  top: 0;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
  background: color-mix(in srgb, var(--bg) 80%, transparent);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.topbar-inner {
  width: min(100%, 1180px);
  min-height: 74px;
  margin: 0 auto;
  padding: max(0.45rem, env(safe-area-inset-top)) 1.25rem 0.45rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 0.65rem;
}

.brand img {
  width: 48px;
  height: 48px;
  flex: 0 0 48px;
  object-fit: contain;
  filter: drop-shadow(0 5px 8px rgba(38, 83, 131, 0.2));
}

.brand-kicker {
  margin: 0 0 -0.05rem;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 650;
  letter-spacing: 0.08em;
}

.brand h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.2rem;
  line-height: 1.2;
  letter-spacing: 0.035em;
}

.topbar-actions {
  display: flex;
  flex-shrink: 0;
  gap: 0.5rem;
}

.help-nav-button {
  grid-template-rows: 18px 12px;
  align-content: center;
  gap: 1px;
  color: var(--blue-strong);
  font-size: 10px;
  font-weight: 700;
  line-height: 1.2;
  text-decoration: none;
}

.help-nav-button svg { width: 18px; height: 18px; }
.help-nav-button:focus-visible { outline: 2px solid var(--blue-strong); outline-offset: 3px; }

.money-nav-button, #overview-button[aria-pressed="true"] {
  color: #fff;
  background: linear-gradient(145deg, var(--primary-top), var(--primary-bottom));
  border-color: var(--ornament);
}
.money-nav-button > span { font-size: 1.5rem; line-height: 1; font-weight: 700; }
#overview-button[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--surface-solid), 0 0 0 3px var(--ornament); }
.brand-kicker::after { content: " · ✦"; color: var(--ornament); }
.dialog-header h2 { font-family: var(--font-display); }

.theme-choices { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.5rem; margin-top: 0.6rem; }
.theme-choices button { min-width: 0; padding: 0.35rem; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--ink-soft); font-size: 0.72rem; }
.theme-choices button[aria-pressed="true"] { border-color: var(--blue-strong); box-shadow: inset 0 0 0 1px var(--blue-strong); color: var(--blue-strong); }
.palette-preview { display: grid; place-items: center; height: 42px; margin-bottom: 0.3rem; border: 1px solid rgba(130, 144, 165, 0.3); border-radius: 8px; font-size: 1.65rem; }
.palette-ice { color: #45688f; background: linear-gradient(135deg, #f8fcff, #dbe7f5); }
.palette-night { color: #d6c3a4; background: linear-gradient(135deg, #0b1425, #243855); }
.palette-cream { color: #937447; background: linear-gradient(135deg, #fffcf6, #eadfca); }

.main-content {
  width: min(100%, 1180px);
  margin: 0 auto;
  padding: 1.25rem 1.25rem calc(6rem + env(safe-area-inset-bottom));
}

.command-bar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.8rem;
}

.search-box {
  position: relative;
  min-width: 0;
}

.search-box > svg {
  position: absolute;
  left: 0.95rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}

.search-box input {
  min-height: 52px;
  padding-left: 3rem;
  padding-right: 4rem;
  border-color: var(--line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.search-box kbd {
  position: absolute;
  top: 50%;
  right: 0.8rem;
  transform: translateY(-50%);
  border: 1px solid var(--line);
  border-bottom-color: var(--line-strong);
  border-radius: 7px;
  padding: 0.16rem 0.38rem;
  color: var(--muted);
  background: var(--surface-soft);
  font-family: var(--font-sans);
  font-size: 0.72rem;
}

.command-actions {
  display: flex;
  gap: 0.6rem;
}

.command-actions .primary-button,
.command-actions .secondary-button {
  min-height: 52px;
}

.filter-strip {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 0 0.8rem;
}

.group-filters {
  min-width: 0;
  display: flex;
  gap: 0.45rem;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 0.15rem 0.05rem 0.2rem;
}

.group-filters::-webkit-scrollbar {
  display: none;
}

.filter-chip {
  min-height: 36px;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.4rem 0.78rem;
  color: var(--muted);
  background: var(--surface);
  font-size: 0.84rem;
  font-weight: 620;
}

.filter-chip[aria-pressed="true"] {
  border-color: var(--blue);
  color: var(--blue-strong);
  background: var(--blue-soft);
}

.filter-chip .chip-count {
  margin-left: 0.24rem;
  font-variant-numeric: tabular-nums;
  opacity: 0.76;
}

.list-meta {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  color: var(--muted);
  font-size: 0.78rem;
}

.meta-divider {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--faint);
}

.entry-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
  align-items: start;
  gap: 0.65rem;
}

.site-tile {
  min-width: 0;
}

.site-tile-open {
  position: relative;
  width: 100%;
  min-height: 94px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 0.38rem;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--line) 55%, var(--surface-solid));
  border-radius: 20px;
  padding: 0.62rem 0.45rem 0.58rem;
  color: var(--ink);
  background: linear-gradient(145deg, var(--surface-solid), var(--surface));
  box-shadow: 0 4px 14px rgba(38, 76, 125, 0.045), inset 0 1px 0 color-mix(in srgb, var(--surface-solid) 60%, transparent);
  -webkit-touch-callout: none;
  user-select: none;
  touch-action: pan-y;
  transition:
    border-color 150ms ease,
    box-shadow 150ms ease,
    transform 150ms ease,
    background 150ms ease;
}

.site-tile-open:hover {
  border-color: var(--line-strong);
  background: var(--surface-solid);
  box-shadow: 0 10px 24px rgba(47, 79, 117, 0.11);
  transform: translateY(-1px);
}

.site-tile-open:focus-visible {
  outline: 0;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(53, 121, 201, 0.16);
}

.site-tile.is-pinned .site-tile-open {
  border-color: rgba(53, 121, 201, 0.34);
  background: color-mix(in srgb, var(--surface) 82%, var(--blue-pale));
}

.site-tile-initial,
.site-detail-initial {
  display: grid;
  place-items: center;
  color: var(--ink-soft);
  background: var(--blue-soft);
  font-weight: 720;
  line-height: 1;
  text-transform: uppercase;
  user-select: none;
}

.site-tile-initial {
  width: 42px;
  height: 42px;
  border-radius: 15px 15px 15px 6px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.42);
  font-size: 1.34rem;
}

.site-tile-name {
  width: 100%;
  overflow: hidden;
  padding: 0 0.12rem;
  color: var(--ink-soft);
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.84rem;
  font-weight: 660;
  line-height: 1.2;
}

.collection-bar,
.collection-label {
  display: flex;
  align-items: center;
}

.collection-bar {
  justify-content: space-between;
  gap: 0.5rem;
  margin: 0.1rem 0 0.55rem;
  min-height: 32px;
}

.collection-label { gap: 0.45rem; min-width: 0; }
.collection-label h2 { margin: 0; font-size: 0.83rem; font-weight: 750; letter-spacing: 0.04em; }
.collection-label > span:last-child { color: var(--muted); font-size: 0.69rem; white-space: nowrap; }
.collection-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--blue); box-shadow: 0 0 0 4px var(--blue-pale); margin: 0 0.2rem; }
.arrange-button {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  min-height: 34px;
  padding: 0.3rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface);
  color: var(--ink-soft);
  font-size: 0.75rem;
  font-weight: 650;
}
.arrange-button svg { width: 14px; height: 14px; }
.arrange-button[aria-pressed="true"] { color: var(--blue-strong); background: var(--blue-soft); border-color: var(--blue); }
.arrange-hint { margin: 0 0 0.65rem; padding: 0.5rem 0.65rem; border-radius: 11px; color: var(--blue-strong); background: var(--blue-soft); font-size: 0.72rem; }
.is-arranging .site-tile-open { touch-action: none; cursor: grab; border-style: dashed; border-color: color-mix(in srgb, var(--blue) 48%, var(--line)); }
.is-arranging .site-tile-open::after { content: "⠿"; position: absolute; right: 7px; bottom: 4px; color: var(--faint); font-size: 14px; }
.is-drag-source { opacity: 0.24; }
.site-drag-ghost { position: fixed; z-index: 90; pointer-events: none; will-change: transform; opacity: 0.96; }
.site-drag-ghost .site-tile-open { box-shadow: 0 16px 36px rgba(27, 68, 123, 0.26); border-color: var(--blue); }
.site-drag-active, .site-drag-active * { cursor: grabbing !important; user-select: none !important; }
.compatibility-note { margin-top: 0.8rem; border: 1px solid var(--line); padding: 0.75rem 0.85rem; border-radius: 14px; background: var(--surface-soft); color: var(--muted); font-size: 0.77rem; line-height: 1.7; }
.compatibility-note summary { cursor: pointer; color: var(--ink-soft); font-weight: 650; }
.compatibility-note p { margin: 0.6rem 0 0; }
.app-version { color: var(--faint); font-size: 0.72rem; letter-spacing: 0.02em; }

.overview-page { max-width: 1020px; }
.overview-heading { display: flex; justify-content: space-between; align-items: center; gap: 0.65rem; margin-bottom: 0.65rem; }
.overview-heading > div { display: flex; align-items: center; gap: 0.65rem; }
.overview-heading h2 { margin: 0; font: 700 1.2rem var(--font-display); letter-spacing: 0.02em; }
.overview-heading .secondary-button { font-size: 0.78rem; white-space: nowrap; }
.overview-heading{flex-wrap:wrap}
.overview-query-actions{margin-left:auto;gap:0.4rem!important;flex-wrap:wrap;justify-content:flex-end}
.overview-query-actions .secondary-button{padding:0.48rem 0.65rem;min-height:36px}
.bulk-query-targets{max-height:32vh;overflow:auto;display:grid;gap:0.45rem}
.bulk-query-target{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:0.2rem 0.5rem;padding:0.6rem 0.7rem;border:1px solid var(--line);border-radius:10px;background:var(--surface-soft)}
.bulk-query-target strong{overflow-wrap:anywhere;font-size:0.83rem}.bulk-query-target>span{font-size:0.72rem;color:var(--muted)}
.bulk-query-target small{grid-column:1/-1;color:var(--muted);font-size:0.72rem;overflow-wrap:anywhere}
#bulk-query-skipped{padding:0.5rem 0;color:var(--muted);font-size:0.8rem}.bulk-query-skipped-list{padding-left:1.2rem;line-height:1.7}
@media(max-width:420px){.overview-heading .overview-query-actions{gap:0.3rem!important}.overview-query-actions .secondary-button{font-size:0.72rem;padding:0.4rem 0.5rem}}
.overview-metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--surface); }
.overview-metrics > div { min-width: 0; padding: 0.4rem 0.6rem; }
.overview-metrics > div + div { border-left: 1px solid var(--line); }
.overview-metrics span { display: block; color: var(--muted); font-size: 0.66rem; white-space: nowrap; }
.overview-metrics strong { display: block; font-size: 1.2rem; font-weight: 750; line-height: 1.25; margin-top: 0.1rem; font-variant-numeric: tabular-nums; }
.overview-metrics .metric-alert { background: var(--blue-pale); }
.metric-alert strong { color: var(--blue-strong); }
.overview-note { color: var(--muted); font-size: 0.7rem; margin: 0.45rem 0; line-height: 1.6; }
.overview-modes { display: flex; gap: 2px; padding: 3px; border: 1px solid var(--line); background: var(--bg-deep); border-radius: 11px; }
.overview-view-bar { display: flex; align-items: center; justify-content: space-between; gap: 0.4rem; }
.overview-view-bar .overview-modes { flex: 0 0 auto; min-width: 0; }
.overview-view-bar > select { width: 94px; min-height: 36px; padding: 0.4rem; font-size: 0.7rem; }
.overview-filter-details { border: 1px solid var(--line); border-radius: 13px; padding: 0.6rem 0.75rem; margin: 0.65rem 0; background: var(--surface); }
.overview-filter-details > summary { cursor: pointer; font-size: 0.73rem; color: var(--ink-soft); }
.overview-filter-details > summary span { margin-left: 0.3rem; color: var(--muted); font-size: 0.66rem; }
.overview-modes button { flex: 0 0 auto; min-height: 32px; padding: 0.3rem 0.65rem; background: transparent; border: 0; border-radius: 8px; color: var(--muted); font-size: 0.75rem; font-weight: 650; white-space: nowrap; }
.overview-modes button[aria-pressed="true"] { color: var(--blue-strong); background: var(--surface-solid); box-shadow: 0 2px 8px rgba(30, 67, 113, 0.08); }
.overview-search { display: block; margin: 0.8rem 0; }
.overview-controls, .overview-threshold-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.6rem; }
.overview-controls label, .overview-threshold-grid label { min-width: 0; color: var(--muted); font-size: 0.72rem; }
.overview-controls select, .overview-threshold-grid input { width: 100%; margin-top: 0.25rem; padding: 0.6rem 0.55rem; font-size: 0.79rem; min-height: 42px; }
.overview-thresholds { padding: 0.7rem 0.8rem; margin: 0.8rem 0; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; }
.overview-thresholds summary { color: var(--ink-soft); font-size: 0.76rem; cursor: pointer; }
.overview-thresholds summary span { color: var(--muted); font-size: 0.69rem; margin-left: 0.3rem; }
.overview-totals { display: flex; gap: 0.5rem; overflow-x: auto; padding-bottom: 2px; }
.overview-total { flex: 0 0 auto; min-width: 116px; padding: 0.4rem 0.65rem; background: var(--surface-blue); border: 1px solid var(--line); border-radius: 10px; }
.overview-total span { display: block; color: var(--muted); font-size: 0.66rem; }
.overview-total strong { display: block; color: var(--blue-strong); font-size: 0.98rem; font-variant-numeric: tabular-nums; }
.overview-rows { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.4rem; }
.overview-unit-heading { grid-column: 1 / -1; margin: 0.55rem 0 0.1rem; color: var(--muted); font-size: 0.73rem; font-weight: 650; }
.overview-row { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) minmax(76px, auto) 30px; gap: 0.35rem; min-height: 68px; border: 1px solid var(--line); border-radius: 12px; padding: 0.5rem 0.4rem 0.5rem 0.6rem; background: var(--surface); }
.overview-identity { display: flex; align-items: center; gap: 0.45rem; min-width: 0; min-height: 44px; padding: 0; background: transparent; border: 0; text-align: left; }
.overview-identity .site-tile-initial { flex: 0 0 30px; width: 30px; height: 30px; font-size: 1rem; border-radius: 9px 9px 9px 4px; }
.overview-site-copy { display: block; min-width: 0; }
.overview-site-copy strong { display: block; color: var(--ink); font-size: 0.83rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.overview-site-copy small { display: block; color: var(--muted); font-size: 0.64rem; line-height: 1.5; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.overview-amount { align-self: center; max-width: 160px; min-height: 44px; padding: 0; border: 0; background: transparent; text-align: right; }
.overview-amount > strong { display: block; color: var(--ink); font-size: 1rem; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.overview-status { display: inline-block; color: var(--muted); font-size: 0.66rem; }
.overview-status.status-positive, .overview-status.status-unlimited { color: var(--success); }
.overview-status.status-empty, .overview-status.status-low, .overview-status.status-error { color: var(--danger); }
.overview-row.status-empty, .overview-row.status-low { border-color: color-mix(in srgb, var(--danger) 38%, var(--line)); }
.overview-row-menu { position: relative; align-self: center; }
.overview-row-menu > summary { display: grid; place-items: center; width: 30px; min-height: 44px; list-style: none; cursor: pointer; border-radius: 8px; color: var(--muted); }
.overview-row-menu > summary::-webkit-details-marker { display: none; }
.overview-row-menu > summary svg { width: 18px; height: 18px; }
.overview-row-menu[open] { z-index: 21; }
.overview-row-menu[open] > summary, .overview-row-menu > summary:hover { color: var(--blue-strong); background: var(--blue-soft); }
.overview-row-footer { position: absolute; top: calc(100% + 4px); right: 0; z-index: 22; width: 184px; display: flex; flex-direction: column; align-items: stretch; gap: 0.35rem; padding: 0.6rem; border: 1px solid var(--line-strong); border-radius: 12px; background: var(--surface-solid); box-shadow: var(--shadow-md); }
.overview-row-footer > small { min-width: 0; color: var(--muted); font-size: 0.64rem; line-height: 1.5; }
.overview-row-footer .balance-actions { flex-direction: column; align-items: stretch; gap: 0.1rem; }
.overview-row-footer .text-button { min-height: 38px; justify-content: flex-start; font-size: 0.75rem; padding: 0.4rem; }
.overview-row-refresh svg { width: 16px; height: 16px; }
.overview-empty { grid-column: 1 / -1; text-align: center; color: var(--muted); font-size: 0.85rem; padding: 2rem 0; }
.token-balance-details { padding: 0.8rem; margin: 0 0 0.8rem; border: 1px solid var(--line); border-radius: 15px; background: var(--surface-soft); }
.token-balance-details > summary { cursor: pointer; color: var(--ink-soft); font-size: 0.78rem; font-weight: 650; }
.token-balance-details .balance-section { margin: 0.7rem 0 0; }

.activity-dialog { width: min(900px, calc(100% - 1.5rem)); }
.activity-panel { gap: 0.6rem; }
.activity-panel > .dialog-header { position: sticky; top: -1rem; z-index: 2; background: var(--surface-solid); padding: 0.6rem 0; border-bottom: 1px solid var(--line); }
.activity-metrics { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 0.5rem; }
.activity-metrics > div { padding: 0.75rem 0.6rem; background: var(--surface-blue); border: 1px solid var(--line); border-radius: 14px; min-width: 0; }
.activity-metrics span { display: block; color: var(--muted); font-size: 0.7rem; }
.activity-metrics strong { display: block; color: var(--blue-strong); font-size: 1.05rem; margin-top: 0.3rem; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.activity-panel .overview-note { margin: 0.3rem 0; }
.activity-permission { padding: 0.6rem 0.75rem; border: 1px solid var(--line); border-radius: 13px; background: var(--surface-soft); }
.activity-permission > div { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.activity-permission button { font-size: 0.72rem; min-height: 34px; }
.activity-tabs { display: flex; align-self: flex-start; max-width: 100%; overflow-x: auto; padding: 3px; border-radius: 11px; gap: 2px; background: var(--bg-deep); }
.activity-tabs button { flex: 0 0 auto; min-height: 32px; padding: 0.35rem 0.65rem; border: 0; border-radius: 8px; color: var(--muted); background: transparent; font-size: 0.73rem; white-space: nowrap; }
.activity-tabs button[aria-pressed="true"] { color: var(--blue-strong); background: var(--surface-solid); box-shadow: var(--shadow-sm); font-weight: 700; }
.activity-filters { border: 1px solid var(--line); border-radius: 13px; padding: 0.65rem 0.75rem; margin: 0.4rem 0; }
.activity-filters summary { font-size: 0.75rem; color: var(--muted); cursor: pointer; }
.activity-filter-grid, .activity-date-fields { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 0.55rem; }
.activity-filter-grid { margin-top: 0.55rem; }
.activity-date-fields { grid-column: 1 / -1; }
.activity-filters label { display: block; min-width: 0; color: var(--muted); font-size: 0.7rem; }
.activity-filters input, .activity-filters select { margin-top: 0.2rem; min-height: 40px; padding: 0.5rem; font-size: 0.78rem; }
.activity-filters .clearable-input-wrap input { padding-right: 2.5rem; }
.activity-query-row { display: flex; align-items: center; gap: 0.7rem; justify-content: space-between; }
.activity-query-row button { flex-shrink: 0; font-size: 0.75rem; padding: 0.55rem 0.65rem; min-height: 40px; }
.activity-period { display: flex; align-items: center; flex-wrap: wrap; gap: 0.5rem 1rem; background: var(--blue-pale); color: var(--muted); padding: 0.65rem 0.75rem; border-radius: 12px; font-size: 0.72rem; }
.activity-period strong { color: var(--blue-strong); margin-left: 0.3rem; }
.activity-status { margin: 0.25rem 0; color: var(--blue-strong); font-size: 0.75rem; overflow-wrap: anywhere; }
.activity-status:empty { display: none; }
.activity-rows { display: grid; gap: 0.55rem; }
.activity-row { padding: 0.8rem; border: 1px solid var(--line); border-radius: 15px; background: var(--surface); min-width: 0; }
.activity-row-heading, .activity-log-main { display: flex; align-items: baseline; gap: 0.6rem; justify-content: space-between; }
.activity-row-heading { margin-bottom: 0.5rem; color: var(--muted); font-size: 0.68rem; }
.activity-type { flex-shrink: 0; color: var(--blue-strong); }
.log-type-2 .activity-type { color: var(--success); }
.log-type-4 .activity-type { color: var(--danger); }
.activity-log-main strong { font-size: 0.88rem; overflow-wrap: anywhere; min-width: 0; }
.activity-log-main strong:last-child { color: var(--blue-strong); flex-shrink: 0; max-width: 45%; text-align: right; font-variant-numeric: tabular-nums; }
.activity-row p, .activity-row small { margin: 0.4rem 0 0; font-size: 0.72rem; color: var(--muted); line-height: 1.65; overflow-wrap: anywhere; white-space: pre-wrap; }
.activity-main-value { font-size: 0.95rem; }
.activity-content summary { cursor: pointer; font-size: 0.72rem; color: var(--muted); margin-top: 0.45rem; }
.activity-row .activity-content-text { color: var(--ink-soft); }
.activity-pager { display: flex; align-items: center; gap: 0.5rem; justify-content: space-between; padding-top: 0.55rem; }
.activity-pager span { color: var(--muted); text-align: center; font-size: 0.72rem; }
.activity-pager button { min-height: 38px; font-size: 0.72rem; padding: 0.4rem 0.7rem; }
.activity-empty { padding: 1.5rem 0; text-align: center; font-size: 0.8rem; color: var(--muted); }

@media (max-width: 640px) {
  .overview-threshold-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .overview-rows { grid-template-columns: minmax(0, 1fr); }
  .overview-metrics > div { padding: 0.4rem 0.5rem; }
  .topbar-actions { gap: 0.2rem; }
}

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

.site-tile-open.has-balance {
  gap: 0.22rem;
  padding-top: 0.45rem;
  padding-bottom: 0.42rem;
}

.site-tile-open.has-balance .site-tile-initial {
  width: 36px;
  height: 36px;
  font-size: 1.2rem;
}

.site-tile-balance {
  width: 100%;
  overflow: hidden;
  color: var(--blue-strong);
  font-size: 0.75rem;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.balance-refresh-all {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  font-size: 0.78rem;
}

.balance-refresh-all svg {
  width: 0.9rem;
  height: 0.9rem;
}

.balance-section {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.65rem 0.8rem;
  background: var(--blue-pale);
}

.balance-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.35rem;
}

.balance-section-heading { display: flex; align-items: center; justify-content: space-between; gap: 0.65rem; }
.balance-section-heading > .mini-icon-button { flex: 0 0 32px; }

.balance-section-heading h3 {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.85rem;
  white-space: nowrap;
  line-height: 1.4;
}

.balance-panel-actions { display: flex; flex-wrap: wrap; gap: 0.4rem; border-top: 1px solid var(--line); padding-top: 0.55rem; margin-top: 0.6rem; }
.balance-panel-button { display: inline-flex; flex: 1 1 auto; align-items: center; justify-content: center; gap: 0.35rem; min-height: 38px; padding: 0.42rem 0.65rem; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface-solid); color: var(--blue-strong); font-size: 0.76rem; font-weight: 650; line-height: 1.4; white-space: nowrap; }
.balance-panel-button svg { flex: 0 0 16px; width: 16px; height: 16px; }
.balance-panel-button:hover { background: var(--blue-soft); border-color: var(--blue); }
.balance-panel-button:active { transform: translateY(1px); }

.balance-value {
  display: block;
  margin-top: 0.25rem;
  overflow-wrap: anywhere;
  color: var(--blue-strong);
  font-size: 1.65rem;
  line-height: 1.25;
  font-variant-numeric: tabular-nums;
}

.balance-status,
.balance-updated {
  margin: 0.3rem 0 0;
  color: var(--muted);
  font-size: 0.7rem;
  line-height: 1.55;
}

.balance-status.is-error,
.site-tile-balance.is-error {
  color: var(--danger);
}

.balance-form-fields {
  display: grid;
  gap: 0.8rem;
  margin-top: 0.8rem;
}

.balance-form-fields .check-row {
  margin-top: 0;
}

.balance-unit-details {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.7rem;
  font-size: 0.88rem;
}

.balance-unit-details summary {
  cursor: pointer;
}

.balance-unit-details summary span {
  display: block;
  padding-left: 1rem;
  color: var(--muted);
  font-size: 0.76rem;
}

.site-tile-pin {
  position: absolute;
  top: 0.42rem;
  right: 0.45rem;
  width: 19px;
  height: 19px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  color: var(--blue-strong);
  background: var(--blue-pale);
}

.site-tile-pin svg {
  width: 0.72rem;
  height: 0.72rem;
  fill: currentColor;
  stroke-width: 1.45;
}

.tone-0 {
  color: #255f9f;
  background: #dfeeff;
}

.tone-1 {
  color: #5d5899;
  background: #e9e7ff;
}

.tone-2 {
  color: #347567;
  background: #ddf3eb;
}

.tone-3 {
  color: #8a5e45;
  background: #f7e9df;
}

.tone-4 {
  color: #4f647e;
  background: #e5edf5;
}

.tone-5 {
  color: #356f88;
  background: #def1f7;
}

.site-card {
  position: relative;
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease,
    transform 160ms ease;
}

.site-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 1.05rem;
  right: 1.05rem;
  height: 2px;
  border-radius: 0 0 3px 3px;
  background: linear-gradient(90deg, transparent, rgba(71, 154, 226, 0.66), transparent);
  opacity: 0;
}

.site-card.is-pinned::before {
  opacity: 1;
}

.site-card:hover {
  border-color: var(--line-strong);
  box-shadow: 0 12px 34px rgba(47, 79, 117, 0.12);
  transform: translateY(-1px);
}

.card-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 0.75rem;
  padding: 1rem 1rem 0.78rem;
}

.site-identity {
  min-width: 0;
  display: flex;
  align-items: flex-start;
  gap: 0.7rem;
}

.pin-button {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--faint);
  background: var(--surface-soft);
}

.pin-button[aria-pressed="true"] {
  color: var(--blue-strong);
  border-color: rgba(53, 121, 201, 0.35);
  background: var(--blue-soft);
}

.site-title-wrap {
  min-width: 0;
}

.site-title-row {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.site-title-row h2 {
  min-width: 0;
  overflow: hidden;
  margin: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 1.04rem;
  line-height: 1.35;
  letter-spacing: -0.02em;
}

.group-badge {
  max-width: 9rem;
  flex: 0 1 auto;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.16rem 0.5rem;
  color: var(--muted);
  background: var(--surface-soft);
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.7rem;
  font-weight: 620;
}

.site-subtitle {
  margin: 0.22rem 0 0;
  color: var(--muted);
  font-size: 0.76rem;
}

.card-quick-actions {
  display: flex;
  gap: 0.25rem;
}

.card-quick-actions .icon-button {
  width: 36px;
  height: 36px;
  min-height: 36px;
  flex-basis: 36px;
  border: 0;
  border-radius: 10px;
  background: transparent;
}

.endpoint-list {
  display: grid;
  gap: 0.45rem;
  padding: 0 1rem 0.85rem;
}

.endpoint-row {
  min-width: 0;
  display: grid;
  grid-template-columns: 4.5rem minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.45rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.52rem 0.55rem 0.52rem 0.72rem;
  background: var(--surface-soft);
}

.endpoint-label {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.72rem;
  font-weight: 660;
  letter-spacing: 0.02em;
}

.endpoint-value {
  min-width: 0;
  overflow: hidden;
  color: var(--ink-soft);
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--font-mono);
  font-size: 0.78rem;
}

.endpoint-actions {
  display: flex;
  gap: 0.1rem;
}

.mini-icon-button {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 9px;
  color: var(--muted);
  background: transparent;
}

.mini-icon-button:hover {
  color: var(--blue-strong);
  background: var(--blue-soft);
}

.mini-icon-button svg {
  width: 1rem;
  height: 1rem;
}

.token-list {
  display: grid;
  gap: 0.45rem;
  border-top: 1px solid var(--line);
  padding: 0.82rem 1rem;
  background: color-mix(in srgb, var(--surface-soft) 54%, transparent);
}

.token-row {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(4.3rem, 0.5fr) minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.5rem;
}

.token-name {
  min-width: 0;
  overflow: hidden;
  color: var(--ink-soft);
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.8rem;
  font-weight: 650;
}

.token-secret {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--font-mono);
  font-size: 0.77rem;
  letter-spacing: 0.01em;
}

.token-secret.is-revealed {
  color: var(--ink-soft);
  user-select: all;
}

.token-actions {
  display: flex;
  gap: 0.1rem;
}

.card-footer {
  min-height: 50px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  border-top: 1px solid var(--line);
  padding: 0.48rem 0.65rem 0.48rem 0.85rem;
}

.reorder-actions,
.record-actions {
  display: flex;
  align-items: center;
  gap: 0.15rem;
}

.footer-label {
  margin-right: 0.2rem;
  color: var(--faint);
  font-size: 0.7rem;
}

.empty-state {
  min-height: min(58vh, 520px);
  display: grid;
  place-items: center;
  align-content: center;
  text-align: center;
  padding: 2rem 1rem 3rem;
}

.empty-state img {
  width: 170px;
  height: 170px;
  object-fit: contain;
  filter: drop-shadow(0 18px 22px rgba(36, 78, 124, 0.18));
  opacity: 0.94;
}

.empty-state h2 {
  margin: -0.3rem 0 0;
  font-size: 1.3rem;
  letter-spacing: -0.03em;
}

.empty-state p {
  max-width: 31rem;
  margin: 0.35rem 0 1.1rem;
  color: var(--muted);
}

.empty-actions {
  display: flex;
  justify-content: center;
  gap: 0.55rem;
}

.floating-add {
  position: fixed;
  z-index: 18;
  right: 1.1rem;
  bottom: max(1.1rem, env(safe-area-inset-bottom));
  width: 58px;
  height: 58px;
  display: none;
  place-items: center;
  border: 0;
  border-radius: 19px;
  color: #fff;
  background: linear-gradient(145deg, var(--primary-top), var(--primary-bottom));
  box-shadow: 0 14px 32px rgba(33, 103, 187, 0.32);
}

.floating-add svg {
  width: 1.55rem;
  height: 1.55rem;
}

.site-detail-dialog {
  width: min(calc(100% - 2rem), 640px);
}

.site-detail-header {
  align-items: center;
}

.site-detail-heading {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 0.78rem;
}

.site-detail-heading > div {
  min-width: 0;
}

.site-detail-heading h2 {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.site-detail-initial {
  width: 50px;
  height: 50px;
  flex: 0 0 50px;
  border-radius: 16px;
  font-size: 1.58rem;
}

.site-detail-body {
  display: grid;
  gap: 1rem;
}

.site-detail-section {
  min-width: 0;
}

.site-detail-section h3 {
  margin: 0 0 0.5rem;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 720;
  letter-spacing: 0.06em;
}

.base-url-details {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-soft);
}

.base-url-summary {
  min-height: 46px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 0.45rem;
  padding: 0.65rem 0.75rem;
  color: var(--ink-soft);
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  list-style: none;
}

.base-url-summary::-webkit-details-marker {
  display: none;
}

.base-url-summary-hint {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 520;
}

.base-url-summary svg {
  width: 1rem;
  height: 1rem;
  transition: transform 160ms ease;
}

.base-url-details[open] .base-url-summary svg {
  transform: rotate(180deg);
}

.base-url-detail-list {
  border-top: 1px solid var(--line);
  padding: 0.55rem;
}

.detail-endpoint-list {
  padding: 0;
}

.detail-token-list {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.72rem;
}

.dialog-footer.site-detail-footer {
  align-items: center;
  justify-content: space-between;
}

.site-detail-order,
.site-detail-actions {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.site-detail-order > span {
  margin-right: 0.12rem;
  color: var(--muted);
  font-size: 0.74rem;
}

.site-detail-actions {
  gap: 0.45rem;
}

.site-detail-actions .ghost-button,
.site-detail-actions .primary-button {
  min-height: 42px;
  padding: 0.58rem 0.74rem;
}

.site-detail-pin.is-active {
  border-color: rgba(53, 121, 201, 0.35);
  color: var(--blue-strong);
  background: var(--blue-soft);
}

.danger-icon-button {
  color: var(--danger);
  background: var(--danger-soft);
}

dialog {
  width: min(calc(100% - 2rem), 680px);
  max-height: min(90dvh, 860px);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 0;
  color: var(--ink);
  background: var(--surface-solid);
  box-shadow: var(--shadow-md);
}

dialog::backdrop {
  background: rgba(13, 25, 42, 0.48);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

dialog[open] {
  animation: dialog-in 180ms ease-out;
}

@keyframes dialog-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.compact-dialog {
  width: min(calc(100% - 2rem), 520px);
}

.dialog-form {
  max-height: inherit;
  overflow-y: auto;
  padding: 1.25rem;
  overscroll-behavior: contain;
}

.dialog-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.dialog-header h2 {
  margin: 0.08rem 0 0;
  font-size: 1.35rem;
  line-height: 1.3;
  letter-spacing: -0.035em;
}

.dialog-kicker {
  margin: 0;
  color: var(--blue-strong);
  font-size: 0.72rem;
  font-weight: 720;
  letter-spacing: 0.08em;
}

.dialog-close {
  background: var(--surface-soft);
}

.dialog-help {
  margin: -0.35rem 0 1rem;
  color: var(--muted);
  font-size: 0.88rem;
}

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

.field-wide {
  grid-column: 1 / -1;
}

.base-url-section,
.token-section {
  margin-top: 1.15rem;
  border-top: 1px solid var(--line);
  padding-top: 1rem;
}

.section-hint {
  margin: 0.5rem 0 0;
  color: var(--muted);
  font-size: 0.76rem;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.section-heading h3,
.settings-section h3 {
  margin: 0.08rem 0 0;
  font-size: 1rem;
  letter-spacing: -0.02em;
}

.section-heading p {
  margin: 0.12rem 0 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.base-url-editor-list,
.token-editor-list {
  display: grid;
  gap: 0.65rem;
}

.base-url-editor-row,
.token-editor-row {
  display: grid;
  grid-template-columns: minmax(7rem, 0.42fr) minmax(0, 1fr) auto;
  align-items: end;
  gap: 0.55rem;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 0.65rem;
  background: var(--surface-soft);
}

.base-url-editor-row .field,
.token-editor-row .field {
  font-size: 0.8rem;
}

.base-url-editor-row input,
.token-editor-row input {
  min-height: 42px;
}

.token-value-wrap {
  position: relative;
}

.token-value-wrap input {
  padding-right: 5.25rem;
  font-family: var(--font-mono);
  font-size: 0.82rem;
}

.input-action-stack {
  position: absolute;
  top: 4px;
  right: 4px;
  display: flex;
  gap: 0.1rem;
}

.input-action-stack .field-clear-button,
.input-action-stack .mini-icon-button {
  position: static;
  transform: none;
}

.remove-base-url-button,
.remove-token-button {
  margin-bottom: 1px;
  color: var(--danger);
}

.check-row {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  margin-top: 1rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.75rem;
  background: var(--surface-soft);
  cursor: pointer;
}

.check-row input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.custom-check {
  width: 24px;
  height: 24px;
  flex: 0 0 24px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  color: transparent;
  background: var(--surface-solid);
}

.check-row input:checked + .custom-check {
  border-color: var(--blue);
  color: #fff;
  background: var(--blue);
}

.custom-check svg {
  width: 0.9rem;
  height: 0.9rem;
  stroke-width: 2.5;
}

.check-row > span:last-child {
  display: grid;
}

.check-row strong {
  font-size: 0.88rem;
}

.check-row small {
  color: var(--muted);
  font-size: 0.76rem;
}

.dialog-footer {
  position: sticky;
  bottom: -1.25rem;
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
  margin: 1rem -1.25rem -1.25rem;
  border-top: 1px solid var(--line);
  padding: 0.85rem 1.25rem calc(0.85rem + env(safe-area-inset-bottom));
  background: var(--surface-solid);
}

.smart-actions {
  display: flex;
  justify-content: space-between;
  gap: 0.6rem;
  margin-top: 0.85rem;
}

.settings-section {
  display: grid;
  gap: 0.65rem;
  border-top: 1px solid var(--line);
  padding: 1rem 0;
}

.settings-section:first-of-type {
  border-top: 0;
  padding-top: 0;
}

/* Keep the settings header out of the scrolling content. */
#settings-dialog {
  height: min(90dvh, 860px);
  overflow: clip;
}

#settings-dialog > .settings-form {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  height: 100%;
  max-height: 100%;
  min-height: 0;
  overflow: hidden;
  overflow: clip;
  padding: 0;
}

.settings-form > .dialog-header {
  margin: 0;
  padding: 1.25rem;
  border-bottom: 1px solid var(--line);
  background: var(--surface-solid);
}

.settings-form > .dialog-header .dialog-close {
  flex-shrink: 0;
}

.settings-scroll {
  min-height: 0;
  min-width: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 1.25rem;
  padding-bottom: calc(1.25rem + env(safe-area-inset-bottom));
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

.settings-action {
  width: 100%;
  min-height: 62px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.7rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.65rem 0.75rem;
  text-align: left;
  color: var(--ink);
  background: var(--surface-soft);
  text-decoration: none;
}

.lock-manual-link {
  display: block;
  width: fit-content;
  margin: 1rem auto 0;
  color: var(--muted);
  font-size: 0.78rem;
  text-underline-offset: 3px;
}

.settings-action:hover {
  border-color: var(--line-strong);
  background: var(--blue-pale);
}

.settings-action-icon {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  color: var(--blue-strong);
  background: var(--blue-soft);
}

.settings-action > span:nth-child(2) {
  min-width: 0;
  display: grid;
}

.settings-action strong {
  font-size: 0.88rem;
}

.settings-action small {
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.75rem;
}

.settings-chevron {
  color: var(--faint);
}

.group-manager {
  display: grid;
  gap: 0.45rem;
}

.managed-group {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.5rem;
}

.managed-group input {
  min-height: 42px;
}

.managed-group .mini-icon-button {
  color: var(--danger);
}

.inline-add {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.5rem;
}

.inline-add input {
  min-height: 42px;
}

.data-summary p {
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.summary-numbers {
  display: flex;
  gap: 0.75rem;
}

.summary-numbers span {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.55rem 0.75rem;
  color: var(--muted);
  background: var(--surface-soft);
  font-size: 0.8rem;
}

.summary-numbers strong {
  color: var(--ink);
  font-size: 1.05rem;
}

.confirm-dialog {
  width: min(calc(100% - 2rem), 390px);
  text-align: center;
}

.confirm-icon {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  margin: 0 auto 0.8rem;
  border-radius: 17px;
  color: var(--danger);
  background: var(--danger-soft);
}

.confirm-icon svg {
  width: 1.5rem;
  height: 1.5rem;
}

.confirm-dialog h2 {
  margin: 0;
  font-size: 1.2rem;
}

.confirm-dialog p {
  margin: 0.45rem 0 1rem;
  color: var(--muted);
}

.confirm-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.55rem;
}

.toast-region {
  position: fixed;
  z-index: 100;
  left: 50%;
  bottom: max(1rem, env(safe-area-inset-bottom));
  width: min(calc(100% - 2rem), 420px);
  display: grid;
  gap: 0.45rem;
  transform: translateX(-50%);
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 13px;
  padding: 0.7rem 0.9rem;
  color: #fff;
  background: rgba(20, 31, 49, 0.94);
  box-shadow: 0 12px 34px rgba(6, 14, 27, 0.24);
  backdrop-filter: blur(10px);
  font-size: 0.84rem;
  font-weight: 620;
  animation: toast-in 180ms ease-out;
}

.toast.is-error {
  background: rgba(134, 48, 65, 0.96);
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 780px) {
  .entry-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.55rem;
  }

  .list-meta {
    display: none;
  }

  .list-meta.has-balance-query {
    display: flex;
  }

  .list-meta.has-balance-query > span {
    display: none;
  }

  .filter-strip.has-balance-query {
    display: flex;
    gap: 0.4rem;
  }

  .filter-strip.has-balance-query .group-filters {
    flex: 1;
  }

  .filter-strip {
    display: block;
  }
}

@media (max-width: 640px) {
  .topbar-inner {
    min-height: 66px;
    padding-right: 0.9rem;
    padding-left: 0.9rem;
    gap: 0.5rem;
  }

  .brand {
    gap: 0.35rem;
  }

  .brand img {
    width: 36px;
    height: 36px;
    flex-basis: 36px;
  }

  .brand-kicker {
    display: none;
  }

  .brand h1 {
    font-size: 1rem;
    white-space: nowrap;
  }

  .desktop-action {
    display: none;
  }

  .main-content {
    padding: 0.78rem 0.78rem calc(6rem + env(safe-area-inset-bottom));
  }

  .command-bar {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0.5rem;
  }

  .search-box input {
    min-height: 46px;
  }

  .search-box kbd {
    display: none;
  }

  .command-actions {
    display: block;
  }

  #add-site-button {
    display: none;
  }

  .command-actions .secondary-button {
    min-height: 46px;
    padding: 0.58rem 0.72rem;
  }

  .filter-strip {
    padding: 0.68rem 0 0.55rem;
  }

  .filter-chip {
    min-height: 32px;
    padding: 0.32rem 0.68rem;
    font-size: 0.78rem;
  }

  .site-tile-open {
    min-height: 88px;
    border-radius: 16px;
    padding-top: 0.54rem;
    padding-bottom: 0.52rem;
  }

  .floating-add {
    display: grid;
  }

  .site-card:hover {
    transform: none;
  }

  .endpoint-row {
    grid-template-columns: 4rem minmax(0, 1fr) auto;
  }

  .token-row {
    grid-template-columns: minmax(4rem, 0.44fr) minmax(0, 1fr) auto;
  }

  dialog {
    width: 100%;
    max-width: none;
    max-height: 92dvh;
    margin: auto 0 0;
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
    border-radius: 25px 25px 0 0;
  }

  dialog[open] {
    animation: sheet-in 190ms ease-out;
  }

  @keyframes sheet-in {
    from {
      opacity: 0;
      transform: translateY(18px);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }

  .dialog-form {
    padding: 1rem;
  }

  #settings-dialog {
    height: 92dvh;
  }

  .settings-form > .dialog-header {
    padding: 1rem;
  }

  .settings-scroll {
    padding: 1rem;
    padding-bottom: calc(1rem + env(safe-area-inset-bottom));
  }

  .dialog-footer {
    bottom: -1rem;
    margin: 1rem -1rem -1rem;
    padding: 0.75rem 1rem calc(0.75rem + env(safe-area-inset-bottom));
  }

  .site-detail-footer {
    display: flex;
    flex-direction: column-reverse;
    align-items: stretch;
    gap: 0.55rem;
  }

  .site-detail-order {
    justify-content: center;
  }

  .site-detail-actions {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) minmax(0, 1fr);
  }

  .site-detail-actions .ghost-button,
  .site-detail-actions .primary-button {
    justify-content: center;
  }

  .form-grid,
  .settings-grid {
    grid-template-columns: 1fr;
  }

  .field-wide {
    grid-column: auto;
  }

  .base-url-editor-row,
  .token-editor-row {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .base-url-editor-row .base-url-editor-name,
  .token-editor-row .token-editor-name {
    grid-column: 1 / -1;
  }

  .smart-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .empty-actions {
    width: min(100%, 320px);
    display: grid;
    grid-template-columns: 1fr;
  }
}

@media (max-width: 390px) {
  .lock-card {
    padding: 1.1rem;
    border-radius: 26px;
  }

  .lock-visual {
    height: 200px;
  }

  .lock-visual img {
    width: 190px;
    height: 190px;
  }

  .site-title-row {
    display: grid;
    justify-items: start;
    gap: 0.25rem;
  }

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

  .endpoint-label {
    grid-column: 1 / -1;
  }

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

  .token-name {
    grid-column: 1 / -1;
  }
}

@media (max-width: 359px) {
  .topbar-inner { flex-wrap: wrap; justify-content: center; row-gap: 0.45rem; }
  .topbar-inner .brand { flex-basis: 100%; justify-content: center; }
  .topbar-actions { gap: 0.5rem; }
}

@media (max-width: 330px) {
  .entry-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #smart-add-button {
    position: relative;
    width: 46px;
    overflow: hidden;
    padding: 0;
    color: transparent;
    gap: 0;
  }

  #smart-add-button svg {
    position: absolute;
    color: var(--blue-strong);
  }
}

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