:root {
  --bg: #000000;
  --panel: #0a0a12;
  --panel-2: #10101a;
  --line: #1c1c2a;
  --line-2: #2a2a40;
  --text: #f0f0f5;
  --muted: #6a6a82;
  --red: #ff3b30;
  --red-dim: rgba(255,59,48,0.12);
  --amber: #ffd60a;
  --amber-dim: rgba(255,214,10,0.12);
  --accent: #30d158;
  --accent-dim: rgba(48,209,88,0.10);
  --accent-glow: rgba(48,209,88,0.30);
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, sans-serif;
  --radius: 16px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html { scroll-behavior: smooth; }

html, body {
  min-height: 100%;
  font-family: var(--sans);
  background-color: var(--bg);
  background-image: radial-gradient(rgba(255,255,255,0.018) 1px, transparent 1px);
  background-size: 24px 24px;
  color: var(--text);
  -webkit-text-size-adjust: 100%;
}

body { overflow-x: hidden; overscroll-behavior-y: contain; }

::selection { background: var(--accent); color: #000; }

button, label, .toggle-row, .srv-row { touch-action: manipulation; }

button { font-family: var(--mono); background: none; border: none; cursor: pointer; color: inherit; }
button:focus { outline: none; }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

a { color: var(--accent); text-decoration: none; }

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

#app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  max-width: 1440px;
  margin: 0 auto;
}

/* ---------- topbar ---------- */

#topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 24px;
  height: 60px;
  background: rgba(6,6,12,0.88);
  border-bottom: 1px solid rgba(255,255,255,0.06);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  z-index: 10;
  flex-shrink: 0;
  position: sticky;
  top: 0;
}

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

.avatar {
  width: 36px; height: 36px; border-radius: 50%;
  border: 1px solid var(--line-2);
  background: var(--panel-2);
  color: var(--text);
  display: flex; align-items: center; justify-content: center;
  font: 800 15px var(--mono);
  flex: none;
  transition: border-color 0.3s;
}
.avatar:hover { border-color: var(--accent); }

.brand-text { display: flex; align-items: baseline; gap: 8px; white-space: nowrap; min-width: 0; }
.brand-text strong { font-size: 13px; letter-spacing: 0.14em; text-transform: uppercase; font-weight: 700; }
.subtitle { font-size: 10px; color: var(--muted); font-family: var(--mono); max-width: 40vw; overflow: hidden; text-overflow: ellipsis; }

.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; transition: background 0.3s, box-shadow 0.3s; }
.dot.online { background: var(--accent); box-shadow: 0 0 8px var(--accent-dim); animation: pulse 3s ease-in-out infinite; }
.dot.busy { background: var(--red); box-shadow: 0 0 8px var(--red-dim); animation: blink 1.2s infinite; }
@keyframes blink { 50% { opacity: 0.25; } }
@keyframes pulse { 0%,100% { box-shadow: 0 0 6px var(--accent-dim); } 50% { box-shadow: 0 0 14px var(--accent-glow); } }

.controls { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }

.clock { font-family: var(--mono); font-size: 12px; color: var(--muted); letter-spacing: 0.08em; white-space: nowrap; }

.pill {
  appearance: none; -webkit-appearance: none;
  border: 1px solid var(--line-2);
  border-radius: 999px;
  background: var(--panel-2);
  color: var(--text);
  padding: 9px 16px;
  font: 700 10px var(--mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  user-select: none;
  transition: all 0.15s ease;
  display: inline-flex; align-items: center; gap: 6px;
  white-space: nowrap;
}
.pill:hover { background: var(--line); border-color: var(--line-2); }
.pill:active { transform: scale(0.97); }
.pill.primary { background: var(--text); color: #000; border-color: var(--text); font-weight: 800; }
.pill.primary:hover { background: #d8d8dd; }

/* ---------- grid ---------- */

#grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  padding: 20px 24px 40px;
}

/* ---------- cards ---------- */

.card {
  grid-column: span 1;
  background: linear-gradient(170deg, rgba(14,14,22,0.95) 0%, var(--panel) 100%);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: clamp(10px, 1.2vw, 18px);
  padding: clamp(10px, 1.4vw, 20px);
  display: flex;
  flex-direction: column;
  gap: clamp(6px, 1vw, 14px);
  min-width: 0;
  position: relative;
  animation: cardIn 0.4s ease both;
  transition: border-color 0.25s, box-shadow 0.25s, transform 0.25s;
}
.card:nth-child(1) { animation-delay: 0ms; }
.card:nth-child(2) { animation-delay: 40ms; }
.card:nth-child(3) { animation-delay: 80ms; }
.card:nth-child(4) { animation-delay: 120ms; }
.card:nth-child(5) { animation-delay: 160ms; }
.card:nth-child(6) { animation-delay: 200ms; }
.card:nth-child(7) { animation-delay: 240ms; }

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

@media (hover: hover) {
  .card:hover {
    border-color: rgba(255,255,255,0.10);
    box-shadow: 0 8px 32px rgba(0,0,0,0.35);
    transform: translateY(-1px);
  }
}

/* colored accent bar */
.card::before {
  content: "";
  position: absolute;
  top: 0; left: 16px; right: 16px;
  height: 2px;
  border-radius: 0 0 2px 2px;
  background: var(--accent);
  opacity: 0.5;
  transition: background 0.3s, opacity 0.3s, box-shadow 0.3s;
}
.card.warn::before { background: var(--amber); opacity: 0.8; box-shadow: 0 0 10px var(--amber-dim); }
.card.bad::before { background: var(--red); opacity: 0.9; box-shadow: 0 0 12px var(--red-dim); }
.card.bad { border-color: rgba(255,255,255,0.08); }

/* card internals */

.card-head { display: flex; align-items: center; gap: clamp(5px, 0.8vw, 10px); min-width: 0; }

.card-label {
  font-family: var(--mono);
  font-size: clamp(9px, 1vw, 12px);
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.card-dot { width: 7px; height: 7px; border-radius: 50%; flex: none; background: var(--accent); box-shadow: 0 0 6px var(--accent-dim); transition: background 0.3s, box-shadow 0.3s; }
.card.warn .card-dot { background: var(--amber); box-shadow: 0 0 6px var(--amber-dim); }
.card.bad .card-dot { background: var(--red); box-shadow: 0 0 6px var(--red-dim); }

.card-tag {
  font-family: var(--mono);
  font-size: clamp(8px, 0.8vw, 10px);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 999px;
  padding: clamp(2px, 0.3vw, 4px) clamp(6px, 0.8vw, 10px);
  white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
  margin-left: auto;
  transition: color 0.3s, border-color 0.3s;
}
.card-tag.green { color: var(--accent); border-color: var(--accent-dim); }
.card-tag.red { color: #ffb3ba; border-color: var(--red-dim); }
.card-tag.amber { color: var(--amber); border-color: var(--amber-dim); }

.big {
  font-family: var(--mono);
  font-size: clamp(20px, 4vw, 38px);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.02em;
  white-space: nowrap;
  transition: color 0.3s;
}
.big.big-med { font-size: clamp(16px, 3vw, 28px); }
.big .unit { font-size: clamp(10px, 1.2vw, 14px); color: var(--muted); font-weight: 500; letter-spacing: 0.04em; }
.big.warn { color: var(--amber); }
.big.hot { color: var(--red); }

/* flash animation when values update */
@keyframes valFlash { 0% { color: var(--accent); } 100% { color: inherit; } }
.val-flash { animation: valFlash 0.5s ease; }

.spark { width: 100%; height: clamp(28px, 5vw, 50px); display: block; }

.bar {
  height: clamp(4px, 0.6vw, 7px);
  background: var(--panel-2);
  border: 1px solid rgba(255,255,255,0.04);
  border-radius: 999px;
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.6s cubic-bezier(0.4,0,0.2,1), background 0.3s;
  box-shadow: 0 0 8px var(--accent-dim);
}
.bar-fill.warn { background: var(--amber); box-shadow: 0 0 8px var(--amber-dim); }
.bar-fill.hot { background: var(--red); box-shadow: 0 0 8px var(--red-dim); }

.card-meta { font-family: var(--mono); font-size: clamp(8px, 0.8vw, 10px); letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); line-height: 1.7; white-space: normal; overflow-wrap: break-word; }

/* cores */

.cores { display: flex; gap: clamp(2px, 0.3vw, 4px); height: clamp(24px, 4.5vw, 46px); align-items: flex-end; }
.core { flex: 1; height: 100%; background: var(--panel-2); border: 1px solid rgba(255,255,255,0.04); border-radius: 4px; overflow: hidden; display: flex; align-items: flex-end; }
.core-bar { width: 100%; background: linear-gradient(0deg, var(--accent) 0%, rgba(48,209,88,0.5) 100%); border-radius: 3px 3px 0 0; transition: height 0.5s cubic-bezier(0.4,0,0.2,1), background 0.3s; min-height: 1px; }
.card.warn .core-bar { background: linear-gradient(0deg, var(--amber) 0%, rgba(255,214,10,0.5) 100%); }
.card.bad .core-bar { background: linear-gradient(0deg, var(--red) 0%, rgba(255,59,48,0.5) 100%); }

/* disk */

.disk-rows { display: flex; flex-direction: column; gap: clamp(3px, 0.7vw, 7px); margin-top: 2px; }
.disk-row { display: flex; align-items: flex-start; justify-content: space-between; gap: clamp(5px, 1.2vw, 12px); font-family: var(--mono); font-size: clamp(7px, 1.1vw, 11px); color: var(--muted); letter-spacing: 0.04em; padding: clamp(2px, 0.5vw, 5px) 0; border-top: 1px solid rgba(255,255,255,0.04); }
.disk-row:first-child { border-top: none; padding-top: 0; }
.disk-row .name { white-space: normal; overflow-wrap: break-word; text-transform: uppercase; flex: 1; min-width: 0; font-weight: 600; }
.disk-row .pct { color: var(--text); white-space: nowrap; font-weight: 600; }
.disk-row .pct.hot { color: var(--red); }
.disk-row .pct.warn { color: var(--amber); }

/* uptime */

.load-line { margin-top: auto; display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; font-family: var(--mono); font-size: clamp(7px, 1vw, 10px); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); gap: 4px; }
.load-vals { color: var(--text); letter-spacing: 0.06em; font-weight: 600; }

/* system */

.kv { display: flex; flex-direction: column; gap: clamp(4px, 1vw, 9px); }
.kv-row { display: grid; grid-template-columns: minmax(48px, auto) 1fr; gap: clamp(5px, 1.2vw, 12px); align-items: start; font-size: clamp(9px, 1.2vw, 12px); }
.kv-row .k { font-family: var(--mono); font-size: clamp(7px, 1vw, 10px); letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); padding-top: 1px; }
.kv-row .v { font-family: var(--mono); font-size: clamp(8px, 1.2vw, 12px); color: var(--text); white-space: normal; overflow-wrap: break-word; line-height: 1.5; }

/* network */

.net-row { display: flex; gap: clamp(10px, 3vw, 28px); }
.net-col { flex: 1; min-width: 0; }
.net-dir { font-family: var(--mono); font-size: clamp(7px, 1vw, 10px); font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; display: flex; align-items: center; gap: 6px; }
.net-dir.down { color: var(--accent); }
.net-dir.up { color: var(--muted); }
.net-val { font-size: clamp(16px, 4vw, 30px); margin-top: 6px; font-weight: 700; }
.net-val.down { color: var(--accent); }

/* services */

.srv-list { display: flex; flex-direction: column; max-height: 420px; overflow-y: auto; }
.srv-row { display: flex; align-items: flex-start; gap: clamp(5px, 1.2vw, 12px); padding: clamp(5px, 1vw, 10px) clamp(2px, 0.5vw, 5px); border-bottom: 1px solid rgba(255,255,255,0.04); font-family: var(--mono); font-size: clamp(8px, 1.1vw, 11px); min-width: 0; transition: background 0.15s; border-radius: 4px; }
.srv-row:last-child { border-bottom: none; }
.srv-row:hover { background: rgba(255,255,255,0.02); }
.srv-dot { width: clamp(5px, 0.8vw, 8px); height: clamp(5px, 0.8vw, 8px); border-radius: 50%; flex: none; margin-top: 4px; }
.srv-dot.running { background: var(--accent); box-shadow: 0 0 6px var(--accent-dim); }
.srv-dot.stopped { background: var(--red); box-shadow: 0 0 6px var(--red-dim); }
.srv-name { font-weight: 700; color: var(--text); white-space: normal; overflow-wrap: break-word; min-width: 0; }
.srv-status { color: var(--muted); font-size: clamp(7px, 1vw, 10px); white-space: normal; overflow-wrap: break-word; flex: 1; min-width: 0; line-height: 1.5; }

/* ---------- overlays ---------- */

#termOverlay, #tokenOverlay, #settingsOverlay {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(0,0,0,0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex; align-items: center; justify-content: center;
  animation: overlayIn 0.2s ease;
}
@keyframes overlayIn { from { opacity: 0; } }
#termOverlay.hidden, #tokenOverlay.hidden, #settingsOverlay.hidden { display: none; }

.term-panel {
  width: min(960px, 96vw);
  height: min(660px, 92vh);
  display: flex; flex-direction: column;
  background: var(--panel);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 24px 80px rgba(0,0,0,0.5);
}

.mem-head { display: flex; align-items: center; gap: 12px; padding: 14px 18px; border-bottom: 1px solid rgba(255,255,255,0.06); }
.mem-head strong { font-size: 13px; letter-spacing: 0.16em; text-transform: uppercase; }
.mem-count { flex: 1; color: var(--muted); font-family: var(--mono); font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.term-body { flex: 1; overflow: hidden; padding: 12px; background: #000; border-radius: 0 0 20px 20px; }
.term-body .xterm { height: 100%; padding: 4px; }
.term-body .xterm-viewport { background: transparent !important; }
.term-body .xterm textarea { font-size: 16px; }

/* settings */

.settings-panel {
  width: min(440px, 94vw);
  max-height: 86vh;
  display: flex; flex-direction: column;
  background: var(--panel);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 24px 80px rgba(0,0,0,0.5);
}
.settings-body { padding: 20px 22px 24px; overflow-y: auto; }
.settings-group { margin-bottom: 24px; }
.settings-group:last-child { margin-bottom: 0; }
.settings-label { font-family: var(--mono); font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); margin-bottom: 12px; }

.swatches { display: flex; gap: 10px; flex-wrap: wrap; }
.swatch {
  width: 32px; height: 32px; border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
  flex: none;
}
.swatch:hover { transform: scale(1.15); box-shadow: 0 0 12px rgba(255,255,255,0.1); }
.swatch.active { border-color: #fff; box-shadow: 0 0 16px rgba(255,255,255,0.15); }

.custom-color {
  display: flex; align-items: center; gap: 10px; margin-top: 14px;
  font-family: var(--mono); font-size: 9px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted);
}
.custom-color input[type="color"] {
  width: 34px; height: 28px; padding: 0; border: 1px solid var(--line-2); border-radius: 8px; background: var(--panel-2); cursor: pointer;
}

.card-toggles { display: flex; flex-direction: column; gap: 10px; }
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 0; }
.toggle-row .t-name { font-family: var(--mono); font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text); }
.toggle-row .t-desc { font-family: var(--mono); font-size: 9px; color: var(--muted); }
.switch { position: relative; width: 44px; height: 24px; flex: none; cursor: pointer; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .track { position: absolute; inset: 0; background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 999px; transition: background 0.2s, border-color 0.2s; }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: var(--muted); transition: transform 0.2s, background 0.2s; }
.switch input:checked + .track { background: var(--accent-dim); border-color: var(--accent); }
.switch input:checked + .track::after { transform: translateX(20px); background: var(--accent); }

.about-line { font-family: var(--mono); font-size: 9px; color: var(--muted); line-height: 1.8; text-transform: uppercase; letter-spacing: 0.06em; }

/* token prompt */

.token-card {
  width: min(380px, 94vw);
  display: flex; flex-direction: column; align-items: center;
  background: var(--panel);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 24px;
  padding: 40px 32px 28px;
  animation: cardIn 0.3s ease;
  box-shadow: 0 24px 80px rgba(0,0,0,0.5);
}
.token-card .big-avatar { width: 64px; height: 64px; border-radius: 50%; border: 1px solid var(--line-2); background: var(--panel-2); color: var(--text); display: flex; align-items: center; justify-content: center; font: 800 26px var(--mono); margin-bottom: 16px; }
.token-card h2 { font-size: 15px; letter-spacing: 0.2em; text-transform: uppercase; margin-bottom: 4px; }
.login-sub { color: var(--muted); font-size: 10px; font-family: var(--mono); text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 20px; }
.login-label { align-self: flex-start; color: var(--muted); font-size: 10px; font-family: var(--mono); text-transform: uppercase; letter-spacing: 0.1em; margin-bottom: 8px; }
.login-input { width: 100%; background: var(--panel-2); border: 1px solid var(--line-2); color: var(--text); font-size: 16px; font-family: var(--sans); border-radius: 12px; padding: 12px 16px; outline: none; transition: border-color 0.2s; }
.login-input:focus { border-color: var(--accent); }
.login-error { margin-top: 14px; color: #ffb3ba; font-size: 11px; font-family: var(--mono); letter-spacing: 0.04em; text-transform: uppercase; text-align: center; }
.login-error.hidden { display: none; }
.login-btn { margin-top: 20px; width: 100%; justify-content: center; padding: 12px; font-size: 11px; }
.login-hint-btn { margin-top: 10px; background: none; border-color: transparent; color: var(--muted); }
.login-hint-btn:hover { color: var(--text); background: transparent; }

/* toasts */

#toasts { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 100; align-items: center; width: max-content; max-width: 92vw; pointer-events: none; }
.toast { pointer-events: auto; background: var(--panel-2); border: 1px solid var(--line-2); color: var(--text); padding: 10px 20px; border-radius: 12px; font-family: var(--mono); font-size: 11px; letter-spacing: 0.04em; text-transform: uppercase; animation: toastIn 0.25s ease; max-width: 100%; box-shadow: 0 8px 24px rgba(0,0,0,0.4); }
.toast.error { border-color: rgba(255,59,48,0.3); color: #ffb3ba; }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } }

/* keyboard shortcut hint */
.shortcut-hint { position: fixed; bottom: 12px; right: 16px; font-family: var(--mono); font-size: 9px; color: rgba(255,255,255,0.15); letter-spacing: 0.04em; z-index: 5; pointer-events: none; }

/* ---------- scrollbar ---------- */

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.14); }
::-webkit-scrollbar-corner { background: transparent; }

/* ---------- safe areas ---------- */

@supports (padding: max(0px)) {
  #topbar {
    height: calc(60px + env(safe-area-inset-top));
    padding-top: env(safe-area-inset-top);
    padding-left: max(24px, env(safe-area-inset-left));
    padding-right: max(24px, env(safe-area-inset-right));
  }
  #toasts { bottom: max(24px, env(safe-area-inset-bottom)); }
  .settings-body { padding-bottom: max(24px, env(safe-area-inset-bottom)); }
}

/* ---------- responsive ---------- */

@media (max-width: 1199px) {
  #grid { padding: 16px 18px 32px; gap: 14px; }
}

@media (max-width: 899px) {
  #grid { padding: 14px 16px 28px; gap: 12px; }
}

@media (max-width: 700px) {
  #topbar { height: 56px; padding: 0 16px; padding-top: env(safe-area-inset-top); padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
  #grid { padding: 12px; gap: 10px; }
  #grid { padding-left: max(12px, env(safe-area-inset-left)); padding-right: max(12px, env(safe-area-inset-right)); }
  .brand { min-width: 0; }
  .brand-text { min-width: 0; overflow: hidden; }
  .brand-text strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .controls { flex-wrap: nowrap; }
  .clock { display: none; }
  .term-panel { width: 100vw; height: 100dvh; border-radius: 0; border: none; box-shadow: none; }
  .subtitle { display: none; }
  .avatar { width: 32px; height: 32px; font-size: 14px; }
  .pill { padding: 10px 14px; font-size: 9px; }
  .card-tag { max-width: none; white-space: normal; overflow: visible; }
  .srv-list { max-height: 50vh; overscroll-behavior: contain; }
  .term-body { padding: 6px; padding-left: max(6px, env(safe-area-inset-left)); padding-right: max(6px, env(safe-area-inset-right)); padding-bottom: max(6px, env(safe-area-inset-bottom)); }
  .shortcut-hint { display: none; }
  .settings-panel { border-radius: 20px 20px 0 0; max-height: 90vh; margin-top: auto; }
}

@media (max-width: 560px) {
  #grid { padding: 10px; }
}

@media (max-width: 400px) {
  #topbar { padding: 0 12px; gap: 8px; }
  .controls { gap: 6px; }
  .pill { font-size: 9px; padding: 9px 12px; }
  .brand-text strong { font-size: 12px; }
  .card { border-radius: 14px; }
  .net-row { gap: 10px; }
  .settings-body { padding: 14px 16px 18px; }
  .token-card { padding: 28px 24px 22px; }
}

@media (orientation: landscape) and (max-height: 520px) {
  #topbar { height: 48px; padding: 0 14px; }
  #grid { padding: 8px 12px 14px; gap: 8px; }
  .clock { display: none; }
  .term-panel { width: 100vw; height: 100dvh; border-radius: 0; border: none; box-shadow: none; }
}

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