/* ---------------------------------------------------------------------------
   Cosmic — design tokens
   --------------------------------------------------------------------------- */
:root {
  --bg: #070a14;
  --bg-elev: #0b1020;
  --bg-panel: #0d1324;
  --bg-panel-2: #111a30;
  --bg-input: #0a0f1d;
  --line: #1c2540;
  --line-strong: #2a365a;
  --text: #eef1ff;
  --text-2: #a4afcc;
  --text-3: #6d7896;
  --accent: #7f93ff;
  --accent-2: #b48cff;
  --accent-soft: rgba(127, 147, 255, 0.16);
  --glow: 0 0 0 3px rgba(127, 147, 255, 0.25);
  --danger: #ff7d8f;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  --radius: 8px;
  --radius-lg: 12px;
  --sidebar-w: 176px;
  --sidebar-w-compact: 60px;
  --topbar-h: 40px;
  --toolbar-h: 46px;
  --status-h: 22px;
  --ease: 160ms cubic-bezier(0.2, 0.7, 0.2, 1);
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: dark;
}

[data-theme="light"] {
  --bg: #eef1f8;
  --bg-elev: #f7f8fc;
  --bg-panel: #ffffff;
  --bg-panel-2: #f2f4fb;
  --bg-input: #ffffff;
  --line: #d9dfef;
  --line-strong: #c1c9e2;
  --text: #121a33;
  --text-2: #4b5674;
  --text-3: #7a849f;
  --accent: #4a5fe6;
  --accent-2: #8a5ce8;
  --accent-soft: rgba(74, 95, 230, 0.12);
  --glow: 0 0 0 3px rgba(74, 95, 230, 0.2);
  --shadow: 0 12px 36px rgba(20, 30, 70, 0.12);
  color-scheme: light;
}

/* ---------------------------------------------------------------------------
   Base
   --------------------------------------------------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  height: 100%;
}
body {
  font-family: var(--font);
  font-size: 13px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
button,
input,
select {
  font: inherit;
  color: inherit;
}
button {
  border: 0;
  background: none;
  cursor: pointer;
  padding: 0;
}
button:disabled {
  cursor: default;
  opacity: 0.4;
}
:focus {
  outline: none;
}
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
h1,
h2,
h3,
p {
  margin: 0;
}
h1 {
  font-size: 22px;
  letter-spacing: -0.4px;
  font-weight: 700;
}
h2 {
  font-size: 14px;
  font-weight: 650;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
.eyebrow {
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: 2px;
  color: var(--text-3);
  margin-bottom: 4px;
}
.muted {
  color: var(--text-3);
  font-size: 12px;
}

/* ---------------------------------------------------------------------------
   Layout
   --------------------------------------------------------------------------- */
.app {
  height: 100%;
  display: flex;
  background:
    radial-gradient(ellipse 60% 50% at 80% -10%, rgba(93, 112, 232, 0.22), transparent 60%),
    radial-gradient(ellipse 40% 40% at -10% 100%, rgba(140, 90, 232, 0.14), transparent 60%),
    var(--bg);
}
.shell {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

/* Sidebar --------------------------------------------------------------- */
.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 8px;
  background: color-mix(in srgb, var(--bg-elev) 88%, transparent);
  border-right: 1px solid var(--line);
  transition: width var(--ease), flex-basis var(--ease);
  overflow: hidden;
}
.sidebar.collapsed {
  width: var(--sidebar-w-compact);
  flex-basis: var(--sidebar-w-compact);
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 36px;
  padding: 0 6px;
  margin-bottom: 8px;
  border-radius: var(--radius);
  white-space: nowrap;
}
.brand:hover {
  background: var(--bg-panel-2);
}
.logo {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  flex: none;
  border-radius: 7px;
  font-size: 15px;
  color: #fff;
  background: linear-gradient(140deg, #4a5ee0, #8a5ce8);
  box-shadow: 0 4px 14px rgba(110, 100, 240, 0.35);
}
.logo.lg {
  width: 40px;
  height: 40px;
  font-size: 20px;
  border-radius: 10px;
}
.brand-word {
  font-size: 12px;
  letter-spacing: 3px;
  font-weight: 800;
  color: var(--text);
}
.main-nav,
.sidebar-bottom {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.sidebar-bottom {
  margin-top: auto;
}
.nav {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  height: 34px;
  padding: 0 9px;
  border-radius: var(--radius);
  color: var(--text-2);
  white-space: nowrap;
  transition: background var(--ease), color var(--ease);
}
.nav-icon {
  width: 22px;
  flex: none;
  text-align: center;
  font-size: 15px;
}
.nav-label {
  font-size: 12.5px;
  font-weight: 550;
  opacity: 1;
  transition: opacity var(--ease);
}
.nav:hover {
  background: var(--bg-panel-2);
  color: var(--text);
}
.nav.active {
  background: var(--accent-soft);
  color: var(--text);
}
.nav.active::before {
  content: "";
  position: absolute;
  left: -8px;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: linear-gradient(var(--accent), var(--accent-2));
}
.nav[aria-pressed="true"] {
  color: var(--accent);
}
.collapse {
  color: var(--text-3);
}
.sidebar.collapsed .brand-word,
.sidebar.collapsed .nav-label {
  opacity: 0;
  width: 0;
  overflow: hidden;
}
.sidebar.collapsed .nav {
  padding: 0;
  justify-content: center;
}
.sidebar.collapsed .brand {
  justify-content: center;
  padding: 0;
}
/* Tooltips when collapsed */
.sidebar.collapsed .nav::after {
  content: attr(data-tip);
  position: absolute;
  left: calc(100% + 10px);
  top: 50%;
  transform: translateY(-50%) translateX(-4px);
  padding: 5px 8px;
  border-radius: 6px;
  background: var(--bg-panel-2);
  border: 1px solid var(--line-strong);
  color: var(--text);
  font-size: 11.5px;
  white-space: nowrap;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--ease), transform var(--ease);
  z-index: 20;
}
.sidebar.collapsed .nav:hover::after,
.sidebar.collapsed .nav:focus-visible::after {
  opacity: 1;
  transform: translateY(-50%) translateX(0);
}
.sidebar.collapsed {
  overflow: visible;
}

/* Top bar / tabs -------------------------------------------------------- */
.topbar {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 8px 0 6px;
  background: color-mix(in srgb, var(--bg-elev) 85%, transparent);
  border-bottom: 1px solid var(--line);
}
.tabs {
  display: flex;
  align-items: center;
  gap: 2px;
  min-width: 0;
  flex: 0 1 auto;
  overflow-x: auto;
  scrollbar-width: none;
  height: 100%;
}
.tabs::-webkit-scrollbar {
  display: none;
}
.tab {
  position: relative;
  display: flex;
  align-items: center;
  gap: 7px;
  height: 30px;
  min-width: 120px;
  max-width: 200px;
  flex: 1 1 160px;
  padding: 0 6px 0 9px;
  border-radius: 6px;
  color: var(--text-2);
  cursor: default;
  user-select: none;
  transition: background var(--ease), color var(--ease);
}
.tab.pinned {
  min-width: 0;
  flex: 0 0 auto;
}
.tab.pinned .tab-title,
.tab.pinned .tab-close {
  display: none;
}
.tab:hover {
  background: var(--bg-panel-2);
  color: var(--text);
}
.tab.active {
  background: var(--bg-panel-2);
  color: var(--text);
  box-shadow: inset 0 -2px 0 var(--accent);
}
.tab-icon {
  width: 14px;
  flex: none;
  font-size: 11px;
  text-align: center;
  color: var(--text-3);
}
.tab.active .tab-icon {
  color: var(--accent);
}
.tab-title {
  flex: 1;
  min-width: 0;
  font-size: 12px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tab-close {
  width: 18px;
  height: 18px;
  flex: none;
  border-radius: 4px;
  color: var(--text-3);
  font-size: 13px;
  line-height: 1;
  opacity: 0;
  transition: opacity var(--ease), background var(--ease);
}
.tab:hover .tab-close,
.tab.active .tab-close,
.tab-close:focus-visible {
  opacity: 1;
}
.tab-close:hover {
  background: var(--line-strong);
  color: var(--text);
}
.tab-spinner,
.spinner {
  display: inline-block;
  width: 10px;
  height: 10px;
  border: 2px solid var(--line-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.top-actions {
  margin-left: auto;
  display: flex;
  gap: 4px;
}

.icon-btn {
  width: 28px;
  height: 28px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 6px;
  color: var(--text-2);
  font-size: 14px;
  transition: background var(--ease), color var(--ease);
}
.icon-btn:hover:not(:disabled) {
  background: var(--bg-panel-2);
  color: var(--text);
}
.icon-btn[aria-pressed="true"] {
  color: var(--accent);
}
.new-tab {
  font-size: 17px;
}

/* Browser toolbar ------------------------------------------------------- */
.browserbar {
  position: relative;
  height: var(--toolbar-h);
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 10px;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--line);
}
.nav-buttons {
  display: flex;
  gap: 2px;
}
.address {
  flex: 1;
  min-width: 0;
  height: 32px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 6px 0 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-input);
  transition: border-color var(--ease), box-shadow var(--ease);
}
.address:focus-within {
  border-color: var(--accent);
  box-shadow: var(--glow);
}
.address-lock {
  color: var(--accent);
  font-size: 12px;
}
.address input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: none;
  font-size: 13px;
  color: var(--text);
}
.address input::placeholder {
  color: var(--text-3);
}
.address-clear {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  color: var(--text-3);
  font-size: 15px;
}
.address-clear:hover {
  background: var(--bg-panel-2);
  color: var(--text);
}
.progress {
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2), var(--accent));
  background-size: 200% 100%;
  animation: progress 1.2s linear infinite;
}

/* Content --------------------------------------------------------------- */
.content {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: auto;
}
.view {
  padding: 22px 28px 32px;
  max-width: 1080px;
  margin: 0 auto;
}
.view[hidden] {
  display: none;
}
.page-view {
  position: absolute;
  inset: 0;
  padding: 0;
  max-width: none;
  margin: 0;
}
.viewports,
.viewport {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}
.viewport {
  background: #fff;
}
.overlay {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 24px;
  text-align: center;
  background: var(--bg);
}
.overlay[hidden] {
  display: none;
}
.loading .spinner {
  width: 26px;
  height: 26px;
  border-width: 3px;
  margin-bottom: 8px;
}
.loading strong {
  font-size: 13px;
}
.loading span {
  color: var(--text-3);
  font-size: 12px;
  max-width: 420px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.fallback-icon {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: var(--bg-panel);
  border: 1px solid var(--line);
  font-size: 20px;
  color: var(--danger);
  margin-bottom: 8px;
}
.fallback h2 {
  font-size: 18px;
}
.fallback p:not(.eyebrow) {
  max-width: 440px;
  color: var(--text-2);
}
.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}
.btn-row.end {
  justify-content: flex-end;
}

/* Buttons --------------------------------------------------------------- */
.primary-btn,
.subtle-btn {
  height: 30px;
  padding: 0 12px;
  border-radius: var(--radius);
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
  transition: background var(--ease), border-color var(--ease), color var(--ease);
}
.primary-btn {
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 4px 14px rgba(110, 100, 240, 0.3);
}
.primary-btn:hover {
  filter: brightness(1.08);
}
.subtle-btn {
  color: var(--text-2);
  background: var(--bg-panel);
  border: 1px solid var(--line);
}
.subtle-btn:hover:not(:disabled) {
  color: var(--text);
  border-color: var(--line-strong);
  background: var(--bg-panel-2);
}
.subtle-btn.danger:hover:not(:disabled) {
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 40%, transparent);
}

/* New-tab page ---------------------------------------------------------- */
.ntp {
  position: relative;
  overflow: hidden;
  padding: 26px 28px 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background:
    radial-gradient(ellipse 50% 80% at 85% 20%, rgba(127, 147, 255, 0.18), transparent 70%),
    radial-gradient(ellipse 40% 70% at 10% 100%, rgba(180, 140, 255, 0.12), transparent 70%),
    var(--bg-panel);
  box-shadow: var(--shadow);
}
.stars {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    radial-gradient(1px 1px at 12% 30%, rgba(255, 255, 255, 0.5), transparent),
    radial-gradient(1px 1px at 28% 72%, rgba(255, 255, 255, 0.35), transparent),
    radial-gradient(1.5px 1.5px at 44% 18%, rgba(200, 210, 255, 0.55), transparent),
    radial-gradient(1px 1px at 61% 58%, rgba(255, 255, 255, 0.35), transparent),
    radial-gradient(1px 1px at 73% 24%, rgba(255, 255, 255, 0.45), transparent),
    radial-gradient(1.5px 1.5px at 86% 66%, rgba(200, 210, 255, 0.5), transparent),
    radial-gradient(1px 1px at 93% 12%, rgba(255, 255, 255, 0.4), transparent),
    radial-gradient(1px 1px at 52% 88%, rgba(255, 255, 255, 0.3), transparent);
}
[data-theme="light"] .stars {
  opacity: 0.35;
}
.ntp > *:not(.stars) {
  position: relative;
}
.ntp-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}
.ntp-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}
.ntp-title {
  font-size: 24px;
  letter-spacing: -0.5px;
}
.ntp-clock {
  text-align: right;
}
.ntp-clock[hidden] {
  display: none;
}
.clock-time {
  display: block;
  font-size: 26px;
  font-weight: 650;
  letter-spacing: -0.5px;
  font-variant-numeric: tabular-nums;
}
.clock-date {
  font-size: 12px;
  color: var(--text-3);
}
.home-search {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 42px;
  padding: 0 5px 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  background: var(--bg-input);
  transition: border-color var(--ease), box-shadow var(--ease);
}
.home-search:focus-within {
  border-color: var(--accent);
  box-shadow: var(--glow);
}
.home-search > span {
  color: var(--text-3);
  font-size: 15px;
}
.home-search input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: none;
  font-size: 14px;
}
.home-search input:focus-visible {
  outline: none;
}
.home-search input::placeholder {
  color: var(--text-3);
}
.ntp-status {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
  font-size: 11.5px;
  color: var(--text-3);
}
.ntp-status b {
  color: var(--text-2);
  font-weight: 650;
}
.ntp-status i {
  font-style: normal;
}
.startup-blank .ntp-head,
.startup-blank .ntp-status,
.startup-blank .section-head,
.startup-blank #homeShortcuts,
.startup-blank .ntp-columns {
  display: none;
}
.startup-blank .ntp {
  background: none;
  border: 0;
  box-shadow: none;
  padding: 18vh 0 0;
  max-width: 640px;
  margin: 0 auto;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 22px 0 10px;
}
.section-actions {
  display: flex;
  gap: 6px;
}
.ntp-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

/* Cards ----------------------------------------------------------------- */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 8px;
}
.card-grid.compact {
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
}
.card-wrap {
  position: relative;
}
.card {
  width: 100%;
  height: 100%;
  min-height: 84px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 12px;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--bg-panel);
  transition: border-color var(--ease), background var(--ease), transform var(--ease), box-shadow var(--ease);
}
.card:hover {
  border-color: var(--line-strong);
  background: var(--bg-panel-2);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
}
.card-icon {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  margin-bottom: 6px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-soft);
}
.card strong {
  font-size: 12.5px;
  font-weight: 600;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.card small {
  font-size: 11px;
  color: var(--text-3);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.card-remove,
.row-remove {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 20px;
  height: 20px;
  border-radius: 5px;
  font-size: 14px;
  line-height: 1;
  color: var(--text-3);
  background: var(--bg-panel);
  border: 1px solid var(--line);
  opacity: 0;
  transition: opacity var(--ease), color var(--ease);
}
.card-wrap:hover .card-remove,
.card-remove:focus-visible,
.row:hover .row-remove,
.row-remove:focus-visible {
  opacity: 1;
}
.card-remove:hover,
.row-remove:hover {
  color: var(--danger);
}
.card-wrap[draggable="true"] .card {
  cursor: grab;
}
.card-wrap.dragging {
  opacity: 0.5;
}
.card-wrap.drop-target .card {
  border-color: var(--accent);
  box-shadow: var(--glow);
}

/* Lists (recent, saved, history) ---------------------------------------- */
.list {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--bg-panel);
  overflow: hidden;
}
.list.grouped {
  border: 0;
  background: none;
  gap: 2px;
  overflow: visible;
}
.group-label {
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text-3);
  margin: 14px 0 6px 2px;
}
.group-label:first-child {
  margin-top: 0;
}
.row {
  position: relative;
  border-bottom: 1px solid var(--line);
}
.list.grouped .row {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-panel);
}
.row:last-child {
  border-bottom: 0;
}
.list.grouped .row:last-child {
  border-bottom: 1px solid var(--line);
}
.row-main {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 34px 9px 12px;
  text-align: left;
  transition: background var(--ease);
}
.row-main:hover {
  background: var(--bg-panel-2);
}
.row-icon {
  width: 22px;
  height: 22px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 6px;
  font-size: 11px;
  color: var(--accent);
  background: var(--accent-soft);
}
.row-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.row-text strong,
.row-text small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.row-text strong {
  font-size: 12.5px;
  font-weight: 600;
}
.row-text small {
  font-size: 11px;
  color: var(--text-3);
}
.row-meta {
  flex: none;
  font-size: 11px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}
.row-remove {
  top: 50%;
  transform: translateY(-50%);
  right: 8px;
}

/* Empty states ---------------------------------------------------------- */
.empty {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 26px 16px;
  text-align: center;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-lg);
  color: var(--text-3);
}
.list .empty {
  border: 0;
}
.empty-icon {
  font-size: 18px;
  color: var(--accent);
  margin-bottom: 4px;
}
.empty strong {
  color: var(--text-2);
  font-size: 12.5px;
}
.empty p {
  font-size: 12px;
  max-width: 320px;
}

/* Panels ---------------------------------------------------------------- */
.panel-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.panel-head .muted {
  margin-top: 4px;
}

/* Settings -------------------------------------------------------------- */
.settings {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 12px;
}
.setting {
  margin: 0;
  padding: 14px 16px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--bg-panel);
  min-width: 0;
}
.setting.wide {
  grid-column: 1 / -1;
}
.setting .muted {
  margin: 8px 0 0;
  font-size: 12px;
}
.setting .muted code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  padding: 1px 4px;
  border-radius: 4px;
  background: var(--bg-panel-2);
}
.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-top: 12px;
  font-size: 12px;
  color: var(--text-2);
}
.field input {
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-input);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  max-width: 460px;
}
.field input:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: var(--glow);
}
.setting legend {
  padding: 0 4px;
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text-3);
}
.choice-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.choice {
  position: relative;
}
.choice input {
  position: absolute;
  opacity: 0;
  inset: 0;
  margin: 0;
  cursor: pointer;
}
.choice > span {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 32px;
  padding: 0 12px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--bg-input);
  color: var(--text-2);
  font-size: 12.5px;
  font-weight: 550;
  transition: border-color var(--ease), color var(--ease), background var(--ease);
}
.choice:hover > span {
  border-color: var(--line-strong);
  color: var(--text);
}
.choice input:checked + span {
  border-color: var(--accent);
  color: var(--text);
  background: var(--accent-soft);
}
.choice input:focus-visible + span {
  box-shadow: var(--glow);
}
.swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  border: 1px solid var(--line-strong);
}
.swatch.dark {
  background: #0b1020;
}
.swatch.light {
  background: #f3f5fb;
}
.toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  color: var(--text-2);
  font-size: 12.5px;
  cursor: pointer;
}
.toggle input {
  appearance: none;
  width: 30px;
  height: 17px;
  margin: 0;
  border-radius: 9px;
  background: var(--line-strong);
  position: relative;
  cursor: pointer;
  transition: background var(--ease);
}
.toggle input::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: #fff;
  transition: transform var(--ease);
}
.toggle input:checked {
  background: var(--accent);
}
.toggle input:checked::after {
  transform: translateX(13px);
}
.toggle input:focus-visible {
  box-shadow: var(--glow);
}
.kv {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 14px;
  margin: 0 0 10px;
  font-size: 12.5px;
}
.kv dt {
  color: var(--text-3);
}
.kv dd {
  margin: 0;
  color: var(--text);
}

/* Status bar ------------------------------------------------------------ */
.statusbar {
  height: var(--status-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 12px;
  font-size: 11px;
  color: var(--text-3);
  background: var(--bg-elev);
  border-top: 1px solid var(--line);
}
.statusbar #status {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.status-right {
  display: flex;
  gap: 6px;
  flex: none;
}

/* Dialog ---------------------------------------------------------------- */
.dialog {
  width: min(420px, calc(100vw - 32px));
  padding: 20px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  background: var(--bg-panel);
  color: var(--text);
  box-shadow: var(--shadow);
}
.dialog::backdrop {
  background: rgba(4, 6, 14, 0.6);
  backdrop-filter: blur(3px);
}
.dialog h2 {
  font-size: 17px;
  margin-bottom: 12px;
}
.dialog label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 10px;
  font-size: 12px;
  color: var(--text-2);
}
.dialog input {
  height: 32px;
  padding: 0 10px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--bg-input);
  color: var(--text);
}
.dialog input:focus {
  border-color: var(--accent);
  box-shadow: var(--glow);
}
.dialog-row {
  display: grid;
  grid-template-columns: 80px 1fr;
  gap: 10px;
}
.form-error {
  color: var(--danger);
  font-size: 12px;
  margin-bottom: 6px;
}

/* Toast ----------------------------------------------------------------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 36px;
  transform: translateX(-50%);
  z-index: 50;
  padding: 8px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--line-strong);
  background: var(--bg-panel-2);
  color: var(--text);
  font-size: 12.5px;
  box-shadow: var(--shadow);
  animation: rise 180ms var(--ease);
}
.toast[hidden] {
  display: none;
}

/* Focus mode ------------------------------------------------------------ */
body.focus .sidebar,
body.focus .topbar,
body.focus .statusbar {
  display: none;
}

/* Animations ------------------------------------------------------------ */
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
@keyframes progress {
  to {
    background-position: -200% 0;
  }
}
@keyframes rise {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(6px);
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
  .tab-spinner,
  .spinner {
    animation: none;
    border-top-color: var(--accent);
  }
  .progress {
    animation: none;
  }
}

/* Responsive ------------------------------------------------------------ */
@media (max-width: 1024px) {
  .view {
    padding: 18px 20px 28px;
  }
}
@media (max-width: 860px) {
  .sidebar {
    width: var(--sidebar-w-compact);
    flex-basis: var(--sidebar-w-compact);
    overflow: visible;
  }
  .sidebar .brand-word,
  .sidebar .nav-label {
    opacity: 0;
    width: 0;
    overflow: hidden;
  }
  .sidebar .nav,
  .sidebar .brand {
    padding: 0;
    justify-content: center;
  }
  .sidebar .nav::after {
    content: attr(data-tip);
    position: absolute;
    left: calc(100% + 10px);
    top: 50%;
    transform: translateY(-50%);
    padding: 5px 8px;
    border-radius: 6px;
    background: var(--bg-panel-2);
    border: 1px solid var(--line-strong);
    color: var(--text);
    font-size: 11.5px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    z-index: 20;
  }
  .sidebar .nav:hover::after,
  .sidebar .nav:focus-visible::after {
    opacity: 1;
  }
  .collapse {
    display: none;
  }
  .ntp-columns {
    grid-template-columns: 1fr;
  }
  .ntp-head {
    flex-direction: column;
  }
  .ntp-clock {
    text-align: left;
  }
}
@media (max-width: 640px) {
  :root {
    --toolbar-h: 44px;
  }
  .app {
    flex-direction: column-reverse;
  }
  .sidebar {
    width: 100%;
    flex: 0 0 auto;
    flex-direction: row;
    align-items: center;
    padding: 4px 8px;
    border-right: 0;
    border-top: 1px solid var(--line);
  }
  .sidebar .brand {
    display: none;
  }
  .main-nav {
    flex: 1;
    flex-direction: row;
    justify-content: space-around;
  }
  .sidebar-bottom {
    flex-direction: row;
    margin: 0;
  }
  .nav.active::before {
    display: none;
  }
  .sidebar .nav::after {
    display: none;
  }
  .statusbar {
    display: none;
  }
  .browserbar {
    padding: 0 6px;
    gap: 4px;
  }
  #homeBtn,
  #openBtn {
    display: none;
  }
  .tab {
    min-width: 96px;
    flex-basis: 120px;
  }
  .view {
    padding: 14px 14px 24px;
  }
  .ntp {
    padding: 18px 16px 16px;
  }
  .ntp-title {
    font-size: 20px;
  }
  .clock-time {
    font-size: 22px;
  }
  .card-grid,
  .card-grid.compact {
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  }
  .panel-head {
    align-items: flex-start;
    flex-direction: column;
  }
  .dialog-row {
    grid-template-columns: 1fr;
  }
}
