/* Component look for every personal-tool web app (gallery variant B, "Console").
   Needs tokens.css and ds-core.css first, and Geist + Geist Mono loaded. */
:root {
  --font: "Geist", "Inter", system-ui, -apple-system, sans-serif;
  --mono: "Geist Mono", ui-monospace, "SF Mono", monospace;
  --h: 34px;
  --r: 8px;
  --card: 10px;
  --shadow-card: 0 1px 2px rgb(0 0 0 / 0.12);
  --shadow-pop: 0 10px 28px rgb(0 0 0 / 0.22), 0 0 0 1px var(--border);
  --ring: 0 0 0 3px color-mix(in srgb, var(--accent) 35%, transparent);
}
body {
  font: 400 13px/20px var(--font);
}
:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}
a { color: var(--accent); text-decoration: none; }
/* Only plain text links underline; classed links (nav items, rows, tiles) have their own hover. */
a:not([class]):hover { text-decoration: underline; text-underline-offset: 2px; }
code { font: 400 0.95em/1 var(--mono); }
.num, .chip-pct, .dp-day, .dp-value, .progress-head .num { font-family: var(--mono); }

.t-display { font: 600 28px/32px var(--font); letter-spacing: -0.02em; }
.t-title { font: 600 15px/20px var(--font); }
.t-body { font: 400 13px/20px var(--font); }
.t-small { font: 400 12px/16px var(--font); color: var(--muted); }
.t-label { font: 600 11px/16px var(--font); letter-spacing: 0.06em; text-transform: uppercase; color: var(--faint); }
.t-mono { font: 500 13px/20px var(--mono); }
.t-mega { font: 500 40px/44px var(--mono); letter-spacing: -0.02em; }

/* Buttons */
.btn {
  height: var(--h); padding: 0 14px; border-radius: var(--r);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font-weight: 500; box-shadow: var(--shadow-card); transition: background-color 0.12s, border-color 0.12s, color 0.12s;
}
.btn:hover { background: var(--surface-hi); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 600; }
.btn-primary:hover { background: color-mix(in srgb, var(--accent) 88%, var(--text)); }
.btn-subtle { border-color: transparent; background: transparent; box-shadow: none; color: var(--muted); }
.btn-subtle:hover { color: var(--text); }
.btn-danger { color: var(--red); border-color: color-mix(in srgb, var(--red) 55%, var(--surface)); background: transparent; }
.btn-danger:hover { background: var(--red); border-color: var(--red); color: var(--on-accent); }
.btn-icon { width: var(--h); padding: 0; }
.btn-small { height: 28px; padding: 0 10px; font-size: 12px; }
.btn:disabled { opacity: 0.45; box-shadow: none; }

.spinner {
  width: 16px; height: 16px; border-radius: 50%; flex: none;
  background: conic-gradient(from 0deg, transparent 10%, currentColor);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 2px), #000 calc(100% - 1.5px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 2px), #000 calc(100% - 1.5px));
  animation: ds-spin 0.8s linear infinite;
}
.spinner-lg { width: 28px; height: 28px; color: var(--accent); }
@keyframes ds-spin { to { transform: rotate(360deg); } }

/* Fields */
.field-label { font: 500 12px/16px var(--font); color: var(--muted); }
.input, .select-trigger, .dp-trigger {
  height: var(--h); width: 100%; padding: 0 10px; border-radius: var(--r);
  border: 1px solid var(--border); background: var(--sunk); color: var(--text); text-align: left;
  box-shadow: inset 0 1px 2px rgb(0 0 0 / 0.12); outline: none;
}
.input:focus, .select-trigger:focus-visible, .dp-trigger:focus-visible, .is-open > .select-trigger, .is-open > .dp-trigger {
  border-color: var(--accent); box-shadow: var(--ring);
}
.input[aria-invalid="true"] { border-color: var(--red); box-shadow: 0 0 0 3px color-mix(in srgb, var(--red) 25%, transparent); }
.input::placeholder { color: var(--faint); }
.field-msg { font-size: 12px; color: var(--red); }
.field-msg .ico { width: 14px; height: 14px; }
.select-trigger .ico, .dp-trigger .ico { color: var(--faint); }
.dp-value { flex: 1; }
.datepicker:not([data-value]) .dp-value, .datepicker[data-value=""] .dp-value { color: var(--faint); font-family: var(--font); }
.select-filter .select-trigger, .datepicker-filter .dp-trigger { width: auto; background: var(--surface); box-shadow: var(--shadow-card); }

.listbox, .menu, .dp-pop { padding: 6px; background: var(--surface); border-radius: var(--r); box-shadow: var(--shadow-pop); }
.listbox { min-width: 200px; }
.option, .menu-item { height: 32px; padding: 0 10px; border: 0; border-radius: 6px; background: none; }
.option.is-active, .menu-item:hover, .menu-item:focus-visible { background: var(--surface-hi); box-shadow: none; }
.option[aria-selected="true"] { font-weight: 600; }
.option-check { color: var(--accent); }
.menu { min-width: 200px; }
.menu-item .ico { color: var(--faint); }
.menu-item-danger, .menu-item-danger .ico { color: var(--red); }
.menu-sep { height: 1px; margin: 6px -6px; background: var(--border); }

/* Date picker */
.dp-pop { padding: 10px; }
.dp-head { padding: 0 0 6px; }
.dp-foot { padding-top: 8px; }
.dp-month { font-weight: 600; }
.dp-nav { width: 28px; height: 28px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: var(--muted); }
.dp-grid th { height: 26px; font: 500 11px/1 var(--font); color: var(--faint); }
.dp-grid td { padding: 1px; }
.dp-day { width: 32px; height: 30px; border: 0; border-radius: 6px; background: none; font-size: 12px; }
.dp-day:hover { background: var(--surface-hi); }
.dp-day.is-outside { color: var(--faint); opacity: 0.6; }
.dp-day.is-today { color: var(--accent); font-weight: 600; text-decoration: underline 2px; text-underline-offset: 4px; }
.dp-day.is-selected { background: var(--accent); color: var(--on-accent); text-decoration: none; font-weight: 600; }
.dp-foot button { height: 28px; padding: 0 10px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); font-size: 12px; }

/* Switch, checks */
.switch { width: 36px; height: 20px; border: 1px solid var(--border-strong); border-radius: 10px; background: var(--sunk); transition: background-color 0.15s; }
.switch-thumb { top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: var(--muted); transition: transform 0.15s, background-color 0.15s; }
.switch[aria-checked="true"] { background: var(--accent); border-color: var(--accent); }
.switch[aria-checked="true"] .switch-thumb { transform: translateX(16px); background: var(--on-accent); }
.check { min-height: 28px; }
.check input { width: 16px; height: 16px; border: 1px solid var(--border-strong); border-radius: 4px; background: var(--sunk); }
.check input[type="radio"] { border-radius: 50%; }
.check input:checked { background: var(--accent); border-color: var(--accent); }
.check input[type="checkbox"]:checked::before { width: 9px; height: 5px; border: solid var(--on-accent); border-width: 0 0 2px 2px; transform: translateY(-1px) rotate(-45deg); }
.check input[type="radio"]:checked::before { width: 6px; height: 6px; border-radius: 50%; background: var(--on-accent); }

/* Chips: pill with a dot */
.chip { height: 22px; padding: 0 9px 0 8px; gap: 6px; border-radius: 999px; font-size: 12px; font-weight: 500; background: var(--surface-hi); color: var(--muted); }
.chip::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.chip-green { background: var(--green-tint); color: var(--green); }
.chip-yellow { background: var(--yellow-tint); color: var(--yellow); }
.chip-red { background: var(--red-tint); color: var(--red); }
.chip-cyan { background: var(--cyan-tint); color: var(--cyan); }
.chip-purple { background: var(--purple-tint); color: var(--purple); }
.chip-orange { background: var(--orange-tint); color: var(--orange); }

.banner { padding: 10px 12px; border-radius: var(--r); border: 1px solid var(--border); background: var(--surface); }
.banner-info .ico { color: var(--accent); }
.banner-warning { border-color: color-mix(in srgb, var(--yellow) 35%, var(--yellow-tint)); background: var(--yellow-tint); }
.banner-warning .ico { color: var(--yellow); }
.banner-error { border-color: color-mix(in srgb, var(--red) 35%, var(--red-tint)); background: var(--red-tint); }
.banner-error .ico { color: var(--red); }

/* Toast: top right, tone dot, countdown */
.toast-region { top: 56px; right: 16px; }
.toast {
  position: relative; overflow: hidden; width: 360px; padding: 12px 10px 12px 14px; border-radius: var(--card);
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-pop);
  transform: translateX(16px); opacity: 0; transition: transform 0.2s, opacity 0.2s;
}
.toast::before { content: ""; flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.toast::after {
  content: ""; position: absolute; left: 0; bottom: 0; height: 2px; width: 100%; background: var(--accent); opacity: 0.6;
  transform-origin: left; animation: ds-count var(--toast-duration) linear forwards;
}
.toast.is-paused::after { animation-play-state: paused; }
@keyframes ds-count { to { transform: scaleX(0); } }
.toast-success::before { background: var(--green); }
.toast-error::before { background: var(--red); }
.toast.is-in { transform: none; opacity: 1; }
.toast.is-out { opacity: 0; transform: translateX(16px); }
.toast-message { flex: 1; }
.toast-action { height: 28px; padding: 0 10px; border: 1px solid var(--border-strong); border-radius: 6px; background: var(--surface-hi); font-weight: 600; font-size: 12px; }
.toast-close { color: var(--faint); }

/* Dialog: header, body, sunk footer band */
dialog.dialog { width: 460px; border-radius: 12px; background: var(--surface); box-shadow: var(--shadow-pop); }
dialog.dialog-form { width: 540px; }
dialog.dialog::backdrop { background: rgb(10 12 16 / 0.6); backdrop-filter: blur(2px); }
dialog.dialog[open] { animation: ds-in 0.16s cubic-bezier(0.2, 0.8, 0.2, 1); }
@keyframes ds-in { from { opacity: 0; transform: scale(0.96); } }
.dialog-body { display: grid; gap: 16px; padding: 22px 22px 20px; }
.dialog-title { margin: 0; font: 600 16px/22px var(--font); }
.dialog-text { margin: 0; color: var(--muted); line-height: 20px; }
.dialog-foot { padding: 12px 22px; background: var(--sunk); border-top: 1px solid var(--border); }
.dialog-x { margin: -6px -8px 0 0; }

/* Empty, tabs, loading */
.empty { padding: 40px 16px; border-radius: var(--card); background: var(--surface); border: 1px solid var(--border); }
.empty .ico { width: 28px; height: 28px; color: var(--faint); stroke-width: 1.25; }
.empty-title { color: var(--muted); }
.tabs { gap: 0; border-bottom: 1px solid var(--border); }
.tab { white-space: nowrap; height: 34px; padding: 0 12px; border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px; background: none; color: var(--muted); font-weight: 500; }
.tab[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }

.is-loading .skel {
  border-radius: 4px;
  background: linear-gradient(90deg, var(--surface-hi) 0%, color-mix(in srgb, var(--surface-hi) 50%, var(--border-strong)) 50%, var(--surface-hi) 100%) 0 0 / 200% 100%;
  animation: ds-shimmer 1.3s linear infinite;
}
@keyframes ds-shimmer { from { background-position: 200% 0; } to { background-position: 0 0; } }
.page-progress { position: absolute; top: 0; left: 0; right: 0; height: 2px; overflow: hidden; z-index: 2; }
.page-progress span { position: absolute; inset: 0; background: var(--accent); animation: ds-load 1.2s ease-out forwards; transform-origin: left; }
@keyframes ds-load { from { transform: scaleX(0.05); } to { transform: scaleX(0.9); } }
.loading-line { color: var(--muted); font-size: 12px; padding: 8px 18px 0; }
.progress-head { font-size: 12px; }
.progress-head .num { color: var(--muted); }
.progress { height: 6px; border-radius: 3px; background: var(--sunk); box-shadow: inset 0 0 0 1px var(--border); }
.progress > span { background: linear-gradient(90deg, var(--accent), var(--cyan)); border-radius: 3px; }

/* Table */
.table-wrap { border: 1px solid var(--border); border-radius: var(--card); background: var(--surface); box-shadow: var(--shadow-card); }
.table th { height: 36px; padding: 0 12px; font: 600 11px/1 var(--font); letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); border-bottom: 1px solid var(--border);
  background: var(--sunk); box-shadow: 1px 0 0 var(--sunk); }  /* the shadow hides seams between fractional-width cells */
.table td { height: 44px; padding: 0 12px; border-bottom: 1px solid var(--border); font-size: 13px; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-hi); }
.table th:first-child, .table td:first-child { padding-left: 16px; }

/* App shell: top bar, icon rail, scrolling main */
.app {
  display: grid; height: 100dvh;
  grid-template: "bar bar" calc(52px + env(safe-area-inset-top)) "nav main" minmax(0, 1fr) / 64px minmax(0, 1fr);
}
.app-bar {
  grid-area: bar; display: flex; align-items: center; gap: 10px;
  padding: env(safe-area-inset-top) calc(14px + env(safe-area-inset-right)) 0 calc(20px + env(safe-area-inset-left));
  background: var(--chrome); border-bottom: 1px solid var(--border);
}
.nav-toggle { display: none; }
.app-name { white-space: nowrap; font-weight: 600; letter-spacing: -0.01em; }
.app-name::before { content: ""; display: inline-block; width: 10px; height: 10px; margin-right: 10px; border-radius: 3px; background: var(--accent); }
.app-bar-end { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.search { position: relative; display: flex; align-items: center; }
.search .ico { position: absolute; left: 10px; color: var(--faint); pointer-events: none; }
.search-input { width: 260px; padding-left: 32px; }
.app-nav {
  grid-area: nav; display: grid; align-content: start; justify-items: center; gap: 6px;
  padding: 14px 0 calc(14px + env(safe-area-inset-bottom)) env(safe-area-inset-left);
  background: var(--chrome); border-right: 1px solid var(--border);
}
.nav-item { position: relative; display: grid; place-items: center; width: 40px; height: 40px; border-radius: var(--card); color: var(--muted); }
.nav-item .ico { width: 18px; height: 18px; }
.nav-item:hover { background: var(--surface-hi); color: var(--text); }
.nav-item.is-current { background: var(--accent-tint); color: var(--accent); }
.nav-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.nav-count {
  position: absolute; top: 2px; right: 0; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px;
  background: var(--surface-hi); font: 400 10px/16px var(--mono); color: var(--muted);
}
.app-main {
  grid-area: main; position: relative; overflow: auto;
  padding: 0 calc(20px + env(safe-area-inset-right)) calc(20px + env(safe-area-inset-bottom)) 20px;
}
.page-head { display: flex; align-items: baseline; gap: 10px; padding: 22px 0 14px; }
.page-title { margin: 0; font: 600 22px/28px var(--font); letter-spacing: -0.02em; }
.page-count { color: var(--faint); font: 400 12px/16px var(--mono); }
.page-new { margin-left: auto; align-self: center; }
.app-main > .banner { margin-bottom: 14px; }
.toolbar { display: flex; gap: 8px; margin-bottom: 14px; }

@media (max-width: 900px) {
  .app { position: relative; grid-template: "bar" calc(52px + env(safe-area-inset-top)) "main" minmax(0, 1fr) / minmax(0, 1fr); }
  .app-nav { display: none; }
  .app.nav-open .app-nav { display: grid; position: absolute; top: calc(52px + env(safe-area-inset-top)); bottom: 0; left: 0; z-index: 5; width: calc(64px + env(safe-area-inset-left)); }
  .nav-toggle { display: inline-flex; }
  .search-input { width: 160px; }
  .app-main { padding-left: calc(20px + env(safe-area-inset-left)); }
}

@media (max-width: 640px) {
  .search { display: none; }
  .app-main { padding: 0 calc(12px + env(safe-area-inset-right)) calc(12px + env(safe-area-inset-bottom)) calc(12px + env(safe-area-inset-left)); }
  .toolbar { overflow-x: auto; }
  .toast-region { left: 12px; right: 12px; top: auto; bottom: 12px; }
  .toast { width: auto; }
  dialog.dialog { margin: auto 0 0; width: 100vw; max-width: 100vw; border-radius: 16px 16px 0 0; }
  .field-row { grid-template-columns: 1fr; }
}
