/* =========================================================
   Utility Hub — style.css  (dark fintech / pro-tool look)
   1. Theme tokens (dark default, light alternate)
   2. Base
   3. Header bar (logo | filter pills | theme toggle)
   4. Groups & grid (3 / 2 / 1 columns)
   5. Widget card shell
   6. Shared widget controls (fields, buttons, tabs, stats)
   7. Widget-specific styles (scoped with .w-<id>)
   8. Responsive
   ========================================================= */

/* ---------- 1. Theme tokens ---------- */
:root,
[data-theme="dark"] {
  --bg: #0b0f17;
  --bg-glow: radial-gradient(900px 480px at 15% -8%, rgba(79, 140, 255, 0.10), transparent 65%),
             radial-gradient(700px 420px at 95% -5%, rgba(34, 211, 238, 0.06), transparent 65%);
  --surface: #131926;
  --surface-2: #0f1520;
  --surface-3: #1b2333;
  --card-grad: linear-gradient(180deg, rgba(255, 255, 255, 0.025), rgba(255, 255, 255, 0) 40%);
  --border: #1f2838;
  --border-strong: #2c384d;
  --text: #e5e9f0;
  --muted: #8591a7;
  --faint: #5d6880;
  --accent: #4f8cff;
  --accent-2: #22d3ee;
  --accent-weak: rgba(79, 140, 255, 0.12);
  --accent-line: rgba(79, 140, 255, 0.25);
  --accent-glow: 0 0 0 1px rgba(79, 140, 255, 0.35), 0 0 18px -4px rgba(79, 140, 255, 0.45);
  --accent-text: #ffffff;
  --good: #34d399;
  --good-weak: rgba(52, 211, 153, 0.12);
  --bad: #f87171;
  --bad-weak: rgba(248, 113, 113, 0.12);
  --warn: #fbbf24;
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.03) inset, 0 10px 30px -18px rgba(0, 0, 0, 0.8);
  --shadow-hover: 0 1px 0 rgba(255, 255, 255, 0.04) inset, 0 16px 40px -20px rgba(0, 0, 0, 0.9);
  --topbar-bg: rgba(11, 15, 23, 0.72);
  --glass: rgba(255, 255, 255, 0.045);
  --glass-border: rgba(255, 255, 255, 0.09);
  --mini-bg: rgba(255, 255, 255, 0.06);
  --panel-bg: rgba(17, 22, 34, 0.86);
  --panel-solid: #121826;
  --scrim: rgba(4, 7, 12, 0.55);
  color-scheme: dark;
}

[data-theme="light"] {
  --bg: #f4f6fa;
  --bg-glow: radial-gradient(900px 480px at 15% -8%, rgba(79, 140, 255, 0.08), transparent 65%);
  --surface: #ffffff;
  --surface-2: #f5f7fb;
  --surface-3: #e9edf4;
  --card-grad: none;
  --border: #e2e7ef;
  --border-strong: #cdd5e2;
  --text: #0f172a;
  --muted: #5b6477;
  --faint: #8a93a6;
  --accent: #2f6fef;
  --accent-2: #0891b2;
  --accent-weak: rgba(47, 111, 239, 0.1);
  --accent-line: rgba(47, 111, 239, 0.25);
  --accent-glow: 0 0 0 1px rgba(47, 111, 239, 0.35), 0 4px 14px -6px rgba(47, 111, 239, 0.45);
  --accent-text: #ffffff;
  --good: #059669;
  --good-weak: rgba(5, 150, 105, 0.1);
  --bad: #dc2626;
  --bad-weak: rgba(220, 38, 38, 0.08);
  --warn: #d97706;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.05), 0 8px 22px -14px rgba(15, 23, 42, 0.18);
  --shadow-hover: 0 1px 2px rgba(15, 23, 42, 0.06), 0 14px 32px -16px rgba(15, 23, 42, 0.25);
  --topbar-bg: rgba(255, 255, 255, 0.8);
  --glass: rgba(255, 255, 255, 0.75);
  --glass-border: rgba(15, 23, 42, 0.08);
  --mini-bg: rgba(15, 23, 42, 0.04);
  --panel-bg: rgba(248, 250, 253, 0.92);
  --panel-solid: #f8fafd;
  --scrim: rgba(15, 23, 42, 0.28);
  color-scheme: light;
}

:root {
  --radius: 12px;
  --radius-sm: 8px;
  --radius-xs: 6px;
  --gap: 14px;
  --maxw: 1360px;
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, "JetBrains Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

/* ---------- 2. Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 80px; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg-glow), var(--bg);
  background-attachment: fixed;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.skip-link {
  position: absolute; left: 12px; top: -40px; padding: 6px 10px; z-index: 100;
  background: var(--accent); color: var(--accent-text); border-radius: 6px; text-decoration: none;
}
.skip-link:focus { top: 10px; }

/* ---------- 3. Header bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: var(--topbar-bg);
  backdrop-filter: saturate(150%) blur(14px);
  -webkit-backdrop-filter: saturate(150%) blur(14px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: var(--maxw); margin: 0 auto; padding: 10px 20px;
  display: grid; grid-template-columns: 1fr minmax(0, 440px) 1fr; align-items: center; gap: 14px;
}
.topbar-inner > .brand { justify-self: start; }
.topbar-inner > .theme-toggle { justify-self: end; }

/* Search pill + results dropdown */
.search { position: relative; width: 100%; }
.search-icon { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search input {
  width: 100%; height: 34px; padding: 0 64px 0 36px;
  border-radius: 999px; border: 1px solid var(--border); background: var(--surface-2);
  font-size: 13px; outline: none; transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
.search input::placeholder { color: var(--faint); }
.search input::-webkit-search-cancel-button { display: none; }
.search input:focus { border-color: var(--accent); background: var(--surface); box-shadow: 0 0 0 3px var(--accent-weak); }
.search-kbd {
  position: absolute; right: 9px; top: 50%; transform: translateY(-50%);
  font-family: var(--mono); font-size: 10.5px; color: var(--muted); white-space: nowrap;
  padding: 1px 6px; border-radius: 6px; border: 1px solid var(--border-strong); background: var(--surface-3);
  pointer-events: none;
}
.search.open .search-kbd, .search input:not(:placeholder-shown) ~ .search-kbd { display: none; }
.search-results {
  position: absolute; left: 50%; top: calc(100% + 8px); transform: translateX(-50%);
  width: max(100%, 420px); max-width: calc(100vw - 24px); max-height: min(420px, 70vh); overflow-y: auto;
  padding: 6px; border-radius: 16px;
  background: var(--panel-bg); border: 1px solid var(--glass-border);
  backdrop-filter: blur(20px) saturate(140%); -webkit-backdrop-filter: blur(20px) saturate(140%);
  box-shadow: 0 24px 60px -20px rgba(0, 0, 0, 0.75);
  z-index: 60;
}
.sr-item {
  display: grid; grid-template-columns: 30px minmax(0, 1fr) auto; align-items: center; gap: 10px;
  padding: 7px 9px; border-radius: 10px; cursor: pointer;
}
.sr-item.active { background: var(--surface-3); box-shadow: inset 0 0 0 1px var(--border-strong); }
.sr-icon {
  width: 30px; height: 30px; display: grid; place-items: center; border-radius: 9px; color: var(--tint);
  background: color-mix(in srgb, var(--tint) 14%, transparent);
}
.sr-text { display: flex; flex-direction: column; min-width: 0; }
.sr-title { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sr-desc { font-size: 11px; color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sr-group {
  font-size: 10.5px; font-weight: 600; color: var(--muted); white-space: nowrap;
  padding: 2px 8px; border-radius: 999px; border: 1px solid var(--border);
}
.sr-empty { padding: 14px; text-align: center; color: var(--muted); font-size: 12.5px; }
.brand { display: flex; align-items: center; gap: 9px; color: inherit; text-decoration: none; }
.brand-logo {
  width: 28px; height: 28px; display: grid; place-items: center; border-radius: 8px; color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 16px -4px var(--accent);
}
.brand-name { font-weight: 700; font-size: 15px; letter-spacing: -0.01em; }
.brand-accent { color: var(--accent); margin-left: 1px; }
.theme-toggle {
  width: 34px; height: 34px; display: grid; place-items: center;
  border-radius: 9px; border: 1px solid var(--border); background: var(--surface-2); color: var(--muted);
  transition: color 0.15s, border-color 0.15s;
}
.theme-toggle:hover { color: var(--text); border-color: var(--border-strong); }
.theme-icon { display: grid; }
[data-theme="dark"] .theme-icon-dark,
[data-theme="light"] .theme-icon-light { display: none; }

/* ---------- 4. Home screen: clock + folder tiles ---------- */
.home {
  min-height: calc(100vh - 56px);
  min-height: calc(100dvh - 56px);
  max-width: var(--maxw); margin: 0 auto; padding: 6vh 20px 30px;
  display: flex; flex-direction: column; align-items: center;
}
.home-hero { text-align: center; margin-bottom: 22px; }

/* Live forex sessions bar */
.sessions {
  width: min(880px, 100%);
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 5vh;
  border-radius: 16px; border: 1px solid var(--glass-border); background: var(--glass);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  overflow: hidden;
}
.sess { padding: 9px 14px 10px; min-width: 0; border-left: 1px solid var(--glass-border); }
.sess:first-child { border-left: 0; }
.sess-top { display: flex; align-items: center; gap: 7px; min-width: 0; }
.sess-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); flex-shrink: 0; }
.sess.open .sess-dot { background: var(--good); box-shadow: 0 0 0 3px var(--good-weak); animation: sess-pulse 2s ease-in-out infinite; }
.sess-name { font-size: 13px; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sess-state {
  margin-left: auto; font-size: 9.5px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--faint); padding: 1px 6px; border-radius: 999px; border: 1px solid var(--border);
}
.sess.open .sess-state { color: var(--good); border-color: color-mix(in srgb, var(--good) 40%, transparent); background: var(--good-weak); }
.sess-time { margin-top: 4px; font-family: var(--mono); font-size: 12.5px; font-variant-numeric: tabular-nums; color: var(--text); white-space: nowrap; }
.sess:not(.open) .sess-time { color: var(--muted); }
.sess-hours { font-size: 10.5px; color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@keyframes sess-pulse { 50% { box-shadow: 0 0 0 5px transparent; } }
.home-time {
  font-size: clamp(56px, 9vw, 96px); font-weight: 250; letter-spacing: -0.04em; line-height: 1;
  font-variant-numeric: tabular-nums;
}
.home-date { margin-top: 8px; font-size: 15px; color: var(--muted); font-weight: 500; }
.home-zone { margin-top: 3px; font-size: 12.5px; color: var(--faint); font-weight: 500; letter-spacing: 0.01em; }

.folders {
  display: grid;
  grid-template-columns: repeat(4, 200px);
  justify-content: center;
  gap: 34px 32px;
  outline: none;
}
.folder {
  --tint: #4f8cff;
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  padding: 0; border: 0; background: none; color: inherit; border-radius: 40px;
  -webkit-tap-highlight-color: transparent;
}
.folder:focus-visible { outline: none; }
.folder:focus-visible .folder-box { box-shadow: 0 0 0 3px var(--bg), 0 0 0 5px var(--tint); }
.folder-box {
  width: 100%; aspect-ratio: 1 / 1;
  display: flex; flex-direction: column; justify-content: space-between;
  padding: 16px;
  border-radius: 25%; /* One UI-style rounded square */
  background:
    radial-gradient(120% 90% at 0% 0%, color-mix(in srgb, var(--tint) 30%, transparent), transparent 60%),
    var(--glass);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(20px) saturate(140%);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
  box-shadow: 0 20px 40px -24px rgba(0, 0, 0, 0.7), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  transition: transform 0.22s cubic-bezier(.2, .8, .2, 1), box-shadow 0.22s, border-color 0.22s;
}
.folder:hover .folder-box {
  transform: translateY(-4px) scale(1.03);
  border-color: color-mix(in srgb, var(--tint) 55%, transparent);
  box-shadow: 0 26px 50px -22px color-mix(in srgb, var(--tint) 60%, transparent), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}
.folder:active .folder-box { transform: scale(0.96); transition-duration: 0.08s; }
.folder-top { display: flex; align-items: flex-start; justify-content: space-between; }
.folder-badge {
  width: 34px; height: 34px; display: grid; place-items: center; color: var(--tint);
  border-radius: 11px; background: color-mix(in srgb, var(--tint) 24%, transparent);
  border: 1px solid color-mix(in srgb, var(--tint) 35%, transparent);
}
.folder-num {
  font-family: var(--mono); font-size: 11px; font-weight: 600; color: var(--muted);
  padding: 2px 8px; border-radius: 999px; background: var(--glass); border: 1px solid var(--glass-border);
}
.mini-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px 8px; align-content: end; }
.mini { display: flex; flex-direction: column; align-items: center; gap: 3px; min-width: 0; }
.mini-icon {
  width: 100%; max-width: 38px; aspect-ratio: 1 / 1; display: grid; place-items: center;
  color: var(--tint); border-radius: 30%;
  background: var(--mini-bg); border: 1px solid var(--glass-border);
}
.mini-name {
  max-width: 100%; font-size: 9px; line-height: 1.2; font-weight: 600; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.mini-empty { grid-column: 1 / -1; text-align: center; color: var(--faint); font-size: 12px; }
.folder-label { font-size: 14px; font-weight: 650; letter-spacing: -0.005em; text-align: center; }

.home-hint { margin: 6vh 0 0; color: var(--faint); font-size: 12px; text-align: center; }
.home-hint kbd {
  font-family: var(--mono); font-size: 11px; padding: 0 5px; border-radius: 5px;
  border: 1px solid var(--border-strong); background: var(--surface-2);
}
.group-empty {
  border: 1px dashed var(--border-strong); border-radius: var(--radius);
  padding: 18px; text-align: center; color: var(--muted); font-size: 13px; grid-column: 1 / -1;
}
.noscript { padding: 12px; border-radius: var(--radius-sm); background: var(--bad-weak); color: var(--bad); }
.site-footer {
  max-width: var(--maxw); margin: 0 auto; padding: 0 20px 24px;
  text-align: center; color: var(--faint); font-size: 12px;
}

/* ---------- 4b. Folder overlay ---------- */
body.modal-open { overflow: hidden; }
.folder-overlay {
  position: fixed; inset: 0; z-index: 80;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background: rgba(4, 7, 12, 0);
  backdrop-filter: blur(0px); -webkit-backdrop-filter: blur(0px);
  transition: background 0.28s ease, backdrop-filter 0.28s ease, -webkit-backdrop-filter 0.28s ease;
}
.folder-overlay.is-open {
  background: var(--scrim);
  backdrop-filter: blur(18px) saturate(120%); -webkit-backdrop-filter: blur(18px) saturate(120%);
}
.folder-panel {
  --tint: #4f8cff;
  position: relative;
  width: min(1280px, 100%);
  max-height: calc(100vh - 48px); max-height: calc(100dvh - 48px);
  overflow-y: auto; overscroll-behavior: contain;
  padding: 18px 20px 22px;
  border-radius: 32px;
  background:
    radial-gradient(80% 60% at 50% -20%, color-mix(in srgb, var(--tint) 16%, transparent), transparent 70%),
    var(--panel-bg);
  border: 1px solid var(--glass-border);
  box-shadow: 0 40px 120px -30px rgba(0, 0, 0, 0.85), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  opacity: 0;
  transform: scale(0.6);
  transition: transform 0.34s cubic-bezier(.2, .9, .25, 1), opacity 0.22s ease;
  scrollbar-width: thin;
}
.folder-overlay.is-open .folder-panel { opacity: 1; transform: none; }
.folder-head {
  position: sticky; top: -18px; z-index: 2;
  display: flex; align-items: center; justify-content: center; gap: 12px;
  margin: -18px -20px 14px; padding: 18px 64px 14px;
  background: linear-gradient(180deg, var(--panel-solid) 70%, transparent);
}
.folder-head-icon {
  width: 36px; height: 36px; display: grid; place-items: center; color: var(--tint); border-radius: 11px;
  background: color-mix(in srgb, var(--tint) 24%, transparent);
  border: 1px solid color-mix(in srgb, var(--tint) 35%, transparent);
}
.folder-head-text { display: flex; flex-direction: column; line-height: 1.15; }
.folder-title { margin: 0; font-size: 21px; font-weight: 700; letter-spacing: -0.015em; }
.folder-count { font-size: 11.5px; color: var(--muted); }
.folder-close {
  position: absolute; right: 18px; top: 50%; transform: translateY(-50%);
  width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%;
  border: 1px solid var(--glass-border); background: var(--glass); color: var(--muted);
  transition: color 0.15s, background 0.15s;
}
.folder-close:hover { color: var(--text); background: var(--surface-3); }
.folder-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--gap);
  align-items: stretch;
}

/* ---------- 5. Widget card shell ---------- */
.card {
  position: relative;
  display: flex; flex-direction: column;
  background: var(--card-grad), var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.card::before {
  content: ""; position: absolute; left: 14px; right: 14px; top: 0; height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  opacity: 0; transition: opacity 0.2s;
}
.card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-hover); }
.card:hover::before { opacity: 0.7; }

.card-head {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
}
.card-icon {
  width: 26px; height: 26px; display: grid; place-items: center; flex-shrink: 0;
  border-radius: 8px; color: var(--tint, var(--accent));
  background: color-mix(in srgb, var(--tint, var(--accent)) 14%, transparent);
}
.card:focus { outline: none; }
.card:focus-visible { border-color: var(--tint, var(--accent)); }
.card.flash { animation: card-flash 1.6s ease-out; }
@keyframes card-flash {
  0%, 30% { border-color: var(--tint, var(--accent)); box-shadow: 0 0 0 3px color-mix(in srgb, var(--tint, var(--accent)) 35%, transparent), var(--shadow); }
  100% { box-shadow: var(--shadow); }
}
.card-titles { min-width: 0; flex: 1; display: flex; flex-direction: column; }
.card-title { margin: 0; font-size: 13.5px; font-weight: 650; line-height: 1.25; }
.card-desc { margin: 0; font-size: 11.5px; color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-body { flex: 1; display: flex; flex-direction: column; gap: 9px; padding: 10px 12px 12px; min-width: 0; }
.card-error { padding: 10px; border-radius: var(--radius-sm); background: var(--bad-weak); color: var(--bad); font-size: 13px; }

/* ---------- 6. Shared widget controls ---------- */

/* Compact field tiles: tiny label inside the box, value right below it */
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.field {
  display: flex; flex-direction: column; gap: 1px; min-width: 0;
  padding: 5px 9px 4px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.field:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-weak); }
.field.full { grid-column: 1 / -1; }
.field > span, .label {
  font-size: 10px; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.06em; line-height: 1.4;
}
.field .input, .field .select {
  height: 24px; padding: 0; border: 0; border-radius: 0; background: transparent; box-shadow: none;
}
.field .input:focus, .field .select:focus { box-shadow: none; background: transparent; }

/* Standalone inputs (outside a field tile) */
.input, .select, .textarea {
  width: 100%; min-width: 0; height: 32px; padding: 0 10px;
  border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--surface-2); outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input:focus, .select:focus, .textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-weak); }
.input { font-family: var(--mono); font-size: 13.5px; font-variant-numeric: tabular-nums; }
.input::placeholder { color: var(--faint); font-family: var(--font); }
.input.invalid { color: var(--bad); }
.field:has(.input.invalid) { border-color: var(--bad); }
.select { cursor: pointer; font-size: 13px; }
.select option { background: var(--surface); color: var(--text); }
.textarea { height: auto; min-height: 84px; padding: 8px 10px; resize: vertical; line-height: 1.45; font-size: 13px; }

.row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.row.nowrap { flex-wrap: nowrap; }
.grow { flex: 1; min-width: 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 30px; padding: 0 12px;
  border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface-3);
  font-size: 12.5px; font-weight: 600; white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s, transform 0.05s;
}
.btn:hover { border-color: var(--border-strong); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.primary:hover { box-shadow: var(--accent-glow); }
.btn.danger { color: var(--bad); }
.btn.sm { height: 26px; padding: 0 9px; font-size: 12px; }
.btn.icon { width: 30px; padding: 0; }
.btn.success { background: var(--good-weak); border-color: var(--good); color: var(--good); }

/* Segmented control + tabs */
.seg {
  display: inline-flex; padding: 2px; gap: 2px;
  border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--border);
}
.seg button {
  border: 0; background: transparent; padding: 3px 10px; border-radius: 6px;
  font-size: 12px; font-weight: 600; color: var(--muted);
  transition: background 0.15s, color 0.15s;
}
.seg button:hover { color: var(--text); }
.seg button[aria-pressed="true"],
.seg button[aria-selected="true"] { background: var(--surface-3); color: var(--text); box-shadow: inset 0 0 0 1px var(--border-strong); }
.seg.full { display: flex; }
.seg.full button { flex: 1; }

/* Stats / results */
.results { display: grid; grid-template-columns: repeat(auto-fit, minmax(112px, 1fr)); gap: 6px; }
.stat {
  min-width: 0; padding: 5px 9px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.stat .k {
  font-size: 9.5px; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.05em; line-height: 1.35;
}
.stat .v {
  font-family: var(--mono); font-size: 13.5px; font-weight: 600;
  font-variant-numeric: tabular-nums; overflow-wrap: anywhere; line-height: 1.35;
}
.stat.hero {
  grid-column: 1 / -1;
  display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
  padding: 7px 10px;
  background: linear-gradient(90deg, var(--accent-weak), transparent);
  border-color: var(--accent-line);
}
.stat.hero .v { font-size: 19px; font-weight: 700; color: var(--accent); text-align: right; }
.stat.good .v { color: var(--good); }
.stat.bad .v { color: var(--bad); }

.note { font-size: 11.5px; color: var(--faint); margin: 0; line-height: 1.4; }
.msg { font-size: 12px; padding: 6px 9px; border-radius: var(--radius-sm); background: var(--bad-weak); color: var(--bad); }
.msg.info { background: var(--accent-weak); color: var(--accent); }

.bar { display: flex; height: 6px; border-radius: 999px; overflow: hidden; background: var(--surface-3); }
.bar > span { display: block; height: 100%; transition: width 0.3s ease; }
.bar .b-bad { background: var(--bad); }
.bar .b-good { background: var(--good); }
.bar .b-accent { background: linear-gradient(90deg, var(--accent), var(--accent-2)); }
.bar .b-muted { background: var(--border-strong); }
.legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 11px; color: var(--muted); }
.legend i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 5px; vertical-align: middle; }
.mt-auto { margin-top: auto; }
.tab-panel { display: flex; flex-direction: column; gap: 9px; }

/* ---------- 7. Widget-specific styles ---------- */

/* World clock */
.w-world-clock .clock-local {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px 12px; border-radius: var(--radius-sm);
  background: linear-gradient(90deg, var(--accent-weak), transparent);
  border: 1px solid var(--accent-line);
}
.w-world-clock .clock-time {
  font-family: var(--mono); font-size: 28px; font-weight: 700; letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums; line-height: 1.1; white-space: nowrap;
}
.w-world-clock .clock-meta { font-size: 0; text-align: right; } /* font-size 0 hides the " · " separator */
.w-world-clock .clock-meta span { display: block; font-size: 11px; color: var(--muted); line-height: 1.4; }
.w-world-clock .row.between .select { height: 26px; font-size: 12px; }
.w-world-clock .city-list {
  list-style: none; margin: 0; padding: 0;
  display: flex; flex-direction: column;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  overflow-y: auto; max-height: 176px; background: var(--surface-2);
}
.w-world-clock .city {
  display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 8px;
  padding: 5px 6px 5px 10px; border-bottom: 1px solid var(--border);
}
.w-world-clock .city:last-child { border-bottom: 0; }
.w-world-clock .city > div:first-child { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.w-world-clock .city-name { font-weight: 600; font-size: 13px; white-space: nowrap; }
.w-world-clock .city-sub { font-family: var(--mono); font-size: 10.5px; color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.w-world-clock .city-time { font-family: var(--mono); font-weight: 600; font-variant-numeric: tabular-nums; font-size: 13.5px; text-align: right; }
.w-world-clock .city-remove {
  width: 22px; height: 22px; border-radius: 6px; border: 0; background: transparent;
  color: var(--faint); font-size: 15px; line-height: 1;
}
.w-world-clock .city-remove:hover { background: var(--bad-weak); color: var(--bad); }
.w-world-clock .night .city-time::before { content: "☾ "; color: var(--faint); font-size: 11px; }

/* Timer */
.w-timer .timer-display {
  text-align: center; font-family: var(--mono); font-size: 36px; font-weight: 700;
  letter-spacing: -0.02em; font-variant-numeric: tabular-nums; padding: 4px 0 0; line-height: 1.1;
}
.w-timer .timer-display.done { color: var(--bad); animation: uw-pulse 0.9s ease-in-out infinite; }
.w-timer .timer-status { text-align: center; font-size: 10.5px; color: var(--muted); min-height: 15px; text-transform: uppercase; letter-spacing: 0.08em; }
.w-timer .time-inputs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; }
.w-timer .presets { display: grid; grid-template-columns: repeat(6, 1fr); gap: 5px; }
.w-timer .presets .btn { padding: 0; font-family: var(--mono); }
.w-timer .controls { display: flex; gap: 7px; }
.w-timer .controls .btn { flex: 1; }
.w-timer .laps {
  list-style: none; margin: 0; padding: 0; max-height: 110px; overflow-y: auto;
  font-family: var(--mono); font-size: 12px;
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2);
}
.w-timer .laps:empty { display: none; }
.w-timer .laps li { display: flex; justify-content: space-between; padding: 4px 10px; border-bottom: 1px solid var(--border); }
.w-timer .laps li:last-child { border-bottom: 0; }
@keyframes uw-pulse { 50% { opacity: 0.45; } }

/* Risk:Reward */
.w-risk-reward .rr-bar { height: 8px; }

/* Unit converter */
.w-unit-converter .conv-grid { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 6px; }
.w-unit-converter .seg button { padding: 3px 6px; }

/* Password / word counter */
.w-text-tools .pw-out { font-size: 13.5px; letter-spacing: 0.03em; color: var(--accent); }
.w-text-tools .checks { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 10px; }
.w-text-tools .check { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--muted); cursor: pointer; }
.w-text-tools .check:has(input:checked) { color: var(--text); }
.w-text-tools .check input { width: 14px; height: 14px; margin: 0; accent-color: var(--accent); }
.w-text-tools .field strong { font-family: var(--mono); font-size: 12px; }
.w-text-tools .range { width: 100%; height: 18px; margin: 0; accent-color: var(--accent); }
.w-text-tools .strength { height: 4px; }
.w-text-tools .results { grid-template-columns: repeat(3, 1fr); }

/* Date calculator */
.check-inline { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--muted); cursor: pointer; }
.check-inline input { width: 14px; height: 14px; margin: 0; accent-color: var(--accent); }
.field .input[type="date"] { color-scheme: inherit; }
[data-theme="dark"] .field .input[type="date"]::-webkit-calendar-picker-indicator { filter: invert(0.8); }

/* QR code */
.w-qr-code .qr-text { height: auto; min-height: 40px; resize: vertical; padding: 2px 0; line-height: 1.4; font-size: 12.5px; }
.w-qr-code .qr-row { display: grid; grid-template-columns: 148px 1fr; gap: 10px; align-items: start; }
.w-qr-code .qr-preview {
  aspect-ratio: 1 / 1; border-radius: var(--radius-sm); overflow: hidden;
  background: #fff; border: 1px solid var(--border); display: grid; place-items: center;
}
.w-qr-code .qr-preview canvas { width: 100%; height: 100%; image-rendering: pixelated; display: block; }
.w-qr-code .qr-preview.empty canvas { visibility: hidden; }
.w-qr-code .qr-opts { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.w-qr-code .qr-colors { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.w-qr-code .color { width: 100%; height: 22px; padding: 0; border: 0; background: none; cursor: pointer; }
.w-qr-code .color::-webkit-color-swatch-wrapper { padding: 0; }
.w-qr-code .color::-webkit-color-swatch { border: 1px solid var(--border-strong); border-radius: 4px; }

/* 3-column field row */
.fields-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }

/* Label/value ladders (Fibonacci, pivots, reference tables) */
.ladder, .ref-grid { border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); overflow: hidden; }
.lrow { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 4px 10px; border-bottom: 1px solid var(--border); }
.lrow:last-child { border-bottom: 0; }
.lk { font-size: 11.5px; color: var(--muted); }
.lv { font-family: var(--mono); font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }
.lrow.key { background: var(--accent-weak); }
.lrow.key .lk, .lrow.key .lv { color: var(--accent); }
.lrow.ext .lk { color: var(--faint); }
.lrow.res .lv { color: var(--bad); }
.lrow.sup .lv { color: var(--good); }
.lrow.bad .lv { color: var(--bad); }
.ref-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.ref-grid .lrow { flex-direction: column; gap: 0; padding: 4px 6px; border-right: 1px solid var(--border); text-align: center; }
.ref-grid .lrow:nth-child(4n) { border-right: 0; }
.ref-grid .lrow:nth-last-child(-n+4) { border-bottom: 0; }
.ref-grid .lv { font-size: 12px; color: var(--good); }

/* Meeting overlap bars */
.mt-grid { display: flex; flex-direction: column; gap: 4px; }
.mt-row { display: grid; grid-template-columns: 70px minmax(0, 1fr); align-items: center; gap: 8px; }
.mt-name { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mt-bar { display: grid; grid-template-columns: repeat(48, 1fr); gap: 1px; height: 12px; }
.mt-bar i { background: var(--surface-3); border-radius: 2px; }
.mt-bar i.on { background: color-mix(in srgb, var(--tint, var(--accent)) 70%, transparent); }
.mt-bar i.ov { background: var(--good); }
.mt-ov .mt-name { color: var(--good); font-weight: 600; }
.mt-axis .mt-ticks { display: flex; justify-content: space-between; font-family: var(--mono); font-size: 9.5px; color: var(--faint); }

/* Unix */
.unix-now { display: flex; align-items: center; gap: 10px; padding: 6px 6px 6px 10px; border-radius: var(--radius-sm); background: linear-gradient(90deg, var(--accent-weak), transparent); border: 1px solid var(--accent-line); }
.unix-now-v { flex: 1; font-family: var(--mono); font-size: 17px; font-weight: 700; color: var(--accent); font-variant-numeric: tabular-nums; }

/* VAT presets */
.presets-row .btn { flex: 1; font-family: var(--mono); }

/* Image compressor */
.drop {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  padding: 22px 12px; text-align: center; cursor: pointer;
  border: 1.5px dashed var(--border-strong); border-radius: var(--radius); background: var(--surface-2);
  transition: border-color 0.15s, background 0.15s;
}
.drop:hover, .drop.drag { border-color: var(--tint, var(--accent)); background: color-mix(in srgb, var(--tint, var(--accent)) 8%, var(--surface-2)); }
.drop-ico { color: var(--tint, var(--accent)); }
.drop-t { font-size: 13px; font-weight: 600; }
.drop-t u { color: var(--tint, var(--accent)); text-decoration: none; }
.drop-s { font-size: 11px; color: var(--faint); }
.drop.compact { flex-direction: row; padding: 8px 12px; gap: 8px; }
.drop.compact .drop-s { display: none; }
.img-row { display: grid; grid-template-columns: 112px minmax(0, 1fr); gap: 8px; align-items: start; }
.img-prev {
  aspect-ratio: 1 / 1; border-radius: var(--radius-sm); overflow: hidden; border: 1px solid var(--border);
  background: repeating-conic-gradient(var(--surface-3) 0 25%, var(--surface-2) 0 50%) 0 0 / 14px 14px;
  display: grid; place-items: center;
}
.img-prev img { max-width: 100%; max-height: 100%; object-fit: contain; display: block; }
.img-stats { grid-template-columns: 1fr; }
.range { width: 100%; height: 18px; margin: 0; accent-color: var(--accent); }
.field strong { font-family: var(--mono); font-size: 12px; }

/* Text case */
.chip-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 5px; }
.chip-grid .btn { padding: 0 4px; font-size: 11.5px; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.w-text-case .textarea { min-height: 96px; font-family: var(--mono); font-size: 12.5px; }

/* Color */
.clr-top { display: flex; gap: 8px; align-items: stretch; }
.clr-swatch {
  width: 64px; flex-shrink: 0; border-radius: var(--radius-sm); border: 1px solid var(--border-strong);
  cursor: pointer; position: relative; overflow: hidden; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}
.clr-swatch input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.clr-vals { border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); }
.clr-val { display: grid; grid-template-columns: 38px minmax(0, 1fr) auto; align-items: center; gap: 8px; padding: 4px 6px 4px 10px; border-bottom: 1px solid var(--border); }
.clr-val:last-child { border-bottom: 0; }
.clr-val code { font-family: var(--mono); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.clr-shades { display: grid; grid-template-columns: repeat(9, 1fr); gap: 4px; }
.shade { height: 26px; border-radius: 6px; border: 1px solid rgba(255, 255, 255, 0.08); padding: 0; transition: transform 0.12s; }
.shade:hover { transform: translateY(-2px); }
.shade.base { box-shadow: 0 0 0 2px var(--bg), 0 0 0 3px var(--text); }

/* ---------- 8. Responsive ---------- */
@media (max-width: 1100px) {
  .folder-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 960px) {
  .folders { grid-template-columns: repeat(2, 190px); gap: 30px 34px; }
  .home { padding-top: 5vh; }
}
@media (max-width: 760px) {
  .topbar-inner { grid-template-columns: auto minmax(0, 1fr) auto; }
  .brand-name { display: none; }
  /* Sessions stay on one row: compact cells, dot shows open/closed */
  .sess { padding: 8px 8px 9px; text-align: center; }
  .sess-top { justify-content: center; gap: 5px; }
  .sess-state { display: none; }
  .sess-name { font-size: 12px; }
  .sess-time .lbl { display: block; font-family: var(--font); font-size: 9.5px; color: var(--faint); text-transform: uppercase; letter-spacing: 0.05em; margin-top: 2px; }
  .sess-time .val { font-size: 12.5px; }
  .sess-hours { display: none; }
  .sr-group { display: none; }
}
@media (max-width: 720px) {
  .folder-grid { grid-template-columns: minmax(0, 1fr); }
  .folder-overlay { padding: 10px; align-items: flex-end; }
  .folder-panel {
    max-height: calc(100vh - 20px); max-height: calc(100dvh - 20px);
    border-radius: 26px; padding: 14px 12px 16px;
  }
  .folder-head { top: -14px; margin: -14px -12px 10px; padding: 14px 56px 12px; }
  .folder-close { right: 12px; }
  .folder-title { font-size: 18px; }
}
@media (max-width: 480px) {
  .topbar-inner { padding: 8px 14px; }
  .home { padding: 4vh 14px 20px; }
  .home-hero { margin-bottom: 4vh; }
  .folders { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px 16px; width: 100%; max-width: 360px; }
  .folder-box { padding: 12px; }
  .folder-badge { width: 28px; height: 28px; border-radius: 9px; }
  .folder-badge .ico { width: 16px; height: 16px; }
  .mini-grid { gap: 4px 6px; }
  .mini-icon { max-width: 30px; }
  .mini-icon .ico { width: 14px; height: 14px; }
  .mini-name { font-size: 8px; }
  .sess { padding: 7px 4px 8px; }
  .sess-name { font-size: 11px; }
  .sess-time .val { font-size: 11.5px; }
  .search-results { position: fixed; top: 54px; left: 12px; right: 12px; transform: none; width: auto; max-width: none; }
  .folder-label { font-size: 13px; }
  .w-qr-code .qr-row { grid-template-columns: 120px 1fr; }
  .fields-3 { grid-template-columns: 1fr 1fr; }
  .chip-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ref-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ref-grid .lrow:nth-child(2n) { border-right: 0; }
  .ref-grid .lrow:nth-last-child(-n+4) { border-bottom: 1px solid var(--border); }
  .ref-grid .lrow:nth-last-child(-n+2) { border-bottom: 0; }
}
@media (max-width: 380px) {
  .fields { grid-template-columns: 1fr; }
  .w-timer .presets { grid-template-columns: repeat(3, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
