/* ===== theme.css: shared look of the whole site (Turso-style dark/light). Edit colors here only. ===== */
:root {
  --bg: #0d1318;
  --surface: #121b1f;
  --card: #162129;
  --line: #283945;
  --fg: #ffffff;
  --fg2: #c5cace;
  --fg3: #9ba3a7;
  --accent: #4ff7d1;
  --accent-ink: #0d1318;
  --badge-bg: #0e342d;
  --veil: rgba(5, 9, 12, 0.62);

  --t-blue: #0063b1;
  --t-sky: #2d7d9a;
  --t-teal: #007b73;
  --t-green: #107c10;
  --t-orange: #b34a0c;
  --t-red: #c42b1c;
  --t-pink: #bf0077;
  --t-purple: #744da9;
  --t-violet: #881798;
  --t-slate: #515c6b;
  --t-brown: #6b4f3a;

  --font-ui: 'Inter', 'Vazirmatn', ui-sans-serif, system-ui, 'Segoe UI', Tahoma, sans-serif;
  --gap: 8px;
  --h-head: 56px;
  --h-foot: 44px;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #eef3f4; --surface: #ffffff; --card: #e2ebed; --line: #c9d6da;
    --fg: #0d1318; --fg2: #33444c; --fg3: #566870;
    --accent: #06705f; --accent-ink: #ffffff; --badge-bg: #d3eee8;
    --veil: rgba(13, 19, 24, 0.42);
    color-scheme: light;
  }
}
:root[data-theme="light"] {
  --bg: #eef3f4; --surface: #ffffff; --card: #e2ebed; --line: #c9d6da;
  --fg: #0d1318; --fg2: #33444c; --fg3: #566870;
  --accent: #06705f; --accent-ink: #ffffff; --badge-bg: #d3eee8;
  --veil: rgba(13, 19, 24, 0.42);
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0d1318; --surface: #121b1f; --card: #162129; --line: #283945;
  --fg: #ffffff; --fg2: #c5cace; --fg3: #9ba3a7;
  --accent: #4ff7d1; --accent-ink: #0d1318; --badge-bg: #0e342d;
  --veil: rgba(5, 9, 12, 0.62);
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { scroll-padding-top: calc(var(--h-head) + env(safe-area-inset-top, 0px)); }
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.6;
  padding-inline: 16px;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }
img { max-width: 100%; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---- Fixed header and footer ---- */
.bar { position: fixed; inset-inline: 0; z-index: 30; background: var(--bg); }
.top { top: 0; padding-top: env(safe-area-inset-top, 0px); border-bottom: 1px solid var(--line); }
.top-in {
  height: var(--h-head);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding-inline: 10px;
  max-width: 1280px;
  margin-inline: auto;
}
.top-in > :first-child { justify-self: start; }
.top-in > :last-child { justify-self: end; }
.actions { display: flex; gap: 2px; }
.icon-btn {
  width: 44px; height: 44px;
  display: grid; place-items: center;
  background: transparent; border: 0; border-radius: 9999px;
  color: var(--fg2); cursor: pointer;
  transition: background-color .15s, color .15s;
}
.icon-btn:hover { background: var(--card); color: var(--fg); }
.icon-btn svg { width: 22px; height: 22px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 20px; color: var(--accent); white-space: nowrap; }
.brand svg { width: 22px; height: 22px; flex: none; }

.bot { bottom: 0; border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom, 0px); }
.bot-in {
  height: var(--h-foot);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding-inline: 16px;
  max-width: 1280px; margin-inline: auto;
  font-size: 13px; color: var(--fg2);
}
.bot-in nav { display: flex; gap: 16px; }
.bot-in a:hover { color: var(--accent); }

/* ---- Search panel ---- */
.search {
  position: fixed; inset-inline: 0; z-index: 25;
  top: calc(var(--h-head) + env(safe-area-inset-top, 0px));
  background: var(--surface); border-bottom: 1px solid var(--line);
  padding: 12px 16px;
  transform: translateY(-100%); visibility: hidden;
  transition: transform .22s ease, visibility 0s linear .22s;
}
.search.open { transform: none; visibility: visible; transition: transform .22s ease; }
.search form { max-width: 560px; margin-inline: auto; display: flex; gap: 8px; align-items: center; }
.search input {
  flex: 1; min-width: 0;
  background: var(--card); color: var(--fg);
  border: 1px solid var(--line); border-radius: 9999px;
  padding: 11px 20px; font: inherit; font-size: 16px;
}
.search input::placeholder { color: var(--fg3); }
.search input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ---- Drawer menu ---- */
.scrim {
  position: fixed; inset: 0; z-index: 40; background: var(--veil);
  opacity: 0; visibility: hidden; transition: opacity .2s, visibility 0s linear .2s;
}
.drawer {
  position: fixed; top: 0; bottom: 0; right: 0; z-index: 50;
  width: min(86vw, 320px);
  background: var(--surface); border-left: 1px solid var(--line);
  padding: env(safe-area-inset-top, 0px) 0 env(safe-area-inset-bottom, 0px);
  overflow-y: auto;
  transform: translateX(100%); visibility: hidden;
  transition: transform .24s ease, visibility 0s linear .24s;
}
.menu-open .scrim { opacity: 1; visibility: visible; transition: opacity .2s; }
.menu-open .drawer { transform: none; visibility: visible; transition: transform .24s ease; }
.drawer-head { display: flex; align-items: center; justify-content: space-between; height: var(--h-head); padding-inline: 20px 10px; border-bottom: 1px solid var(--line); }
.drawer-head strong { color: var(--accent); font-size: 18px; font-weight: 800; }
.drawer-body { padding: 12px 12px 24px; display: flex; flex-direction: column; gap: 4px; }
.d-title { margin: 14px 12px 4px; font-size: 12px; font-weight: 600; color: var(--fg3); }
.drawer ul { list-style: none; margin: 0; padding: 0; }
.drawer li a, .drawer li .soon-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 12px; color: var(--fg2); font-size: 15px;
}
.drawer li a:hover { background: var(--card); color: var(--fg); }
.drawer li i { width: 10px; height: 10px; flex: none; }
.drawer li .soon-item { opacity: .55; cursor: default; }
.drawer li .soon-item em { margin-inline-start: auto; font-style: normal; font-size: 11px; color: var(--fg3); }

/* ---- Page area (every page puts its content inside <main class="page">) ---- */
main {
  max-width: 976px; margin-inline: auto;
  padding-block: calc(var(--h-head) + 28px) calc(var(--h-foot) + 40px);
}
main.page { padding-top: calc(var(--h-head) + env(safe-area-inset-top, 0px) + 28px); }
.page-head { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; margin-bottom: 28px; }
.page-head h1 { margin: 0; font-size: clamp(24px, 5.5vw, 32px); line-height: 1.25; font-weight: 700; text-wrap: balance; }
.lead { margin: 0; max-width: 52ch; font-size: 15px; color: var(--fg2); }
.badge {
  display: inline-block; padding: 4px 14px; border-radius: 9999px;
  background: var(--badge-bg); color: var(--accent);
  font-size: 12.5px; font-weight: 600;
}

/* ---- Shared components for tools ---- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 20px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field > label { font-size: 14px; font-weight: 500; color: var(--fg2); }
.field input[type="text"], .field input[type="number"], .field select, .field textarea {
  width: 100%; background: var(--card); color: var(--fg);
  border: 1px solid var(--line); border-radius: 12px;
  padding: 11px 14px; font: inherit; font-size: 16px;
}
.field textarea { min-height: 96px; resize: vertical; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 10px 22px; border: 0; border-radius: 9999px;
  background: var(--accent); color: var(--accent-ink);
  font-size: 14px; font-weight: 600; cursor: pointer;
}
.btn:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; color: var(--fg); border: 1px solid var(--line); font-weight: 500; }
.btn.ghost:hover { background: var(--card); filter: none; }

@media (prefers-reduced-motion: reduce) {
  * { transition-duration: 0s !important; }
}
