/* ==========================================================================
   Doodle.cat — styles
   Dark glass UI, cyan/blue/green accents. Single stylesheet, no build step.
   ========================================================================== */

:root {
  --bg-0: #070b14;
  --bg-1: #0b1220;
  --bg-2: #0f1a2e;
  --glass: rgba(255, 255, 255, 0.045);
  --glass-2: rgba(255, 255, 255, 0.08);
  --stroke: rgba(255, 255, 255, 0.10);
  --stroke-2: rgba(255, 255, 255, 0.18);
  --text: #e6edf7;
  --muted: #8b9bb4;
  --muted-2: #5f6f8a;
  --cyan: #22d3ee;
  --blue: #3b82f6;
  --green: #34d399;
  --amber: #fbbf24;
  --red: #f87171;
  --accent: linear-gradient(135deg, #22d3ee 0%, #3b82f6 100%);
  --accent-2: linear-gradient(135deg, #34d399 0%, #22d3ee 100%);
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --glow: 0 0 0 3px rgba(34, 211, 238, 0.18);
  --nav-h: 64px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg-0);
  min-height: 100vh;
  line-height: 1.5;
  overflow-x: hidden;
}
body::before {
  /* subtle grid + glow backdrop */
  content: '';
  position: fixed; inset: 0; z-index: -1;
  background:
    radial-gradient(900px 500px at 15% -10%, rgba(34, 211, 238, 0.14), transparent 60%),
    radial-gradient(800px 500px at 90% 10%, rgba(59, 130, 246, 0.16), transparent 60%),
    radial-gradient(700px 400px at 50% 110%, rgba(52, 211, 153, 0.10), transparent 60%),
    linear-gradient(180deg, var(--bg-1), var(--bg-0));
}
body::after {
  content: '';
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background-image:
    linear-gradient(rgba(255,255,255,0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.025) 1px, transparent 1px);
  background-size: 40px 40px;
  mask-image: linear-gradient(180deg, rgba(0,0,0,0.9), transparent 70%);
  -webkit-mask-image: linear-gradient(180deg, rgba(0,0,0,0.9), transparent 70%);
}

a { color: var(--cyan); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: inherit; }
img { max-width: 100%; display: block; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.container { width: min(1200px, calc(100% - 40px)); margin: 0 auto; }

/* ---------------------------------------------------------------- navbar */
.nav {
  position: sticky; top: 0; z-index: 50;
  height: var(--nav-h);
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  background: rgba(7, 11, 20, 0.65);
  border-bottom: 1px solid var(--stroke);
}
.nav .container { display: flex; align-items: center; height: 100%; gap: 16px; }
.brand { display: flex; align-items: center; gap: 12px; color: var(--text); font-weight: 700; letter-spacing: -0.01em; font-size: 20px; }
.brand:hover { text-decoration: none; }
.brand svg { width: 38px; height: 38px; filter: drop-shadow(0 0 10px rgba(34,211,238,0.45)); }
.brand .dot { color: var(--cyan); }
.nav-links { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.nav-links a {
  color: var(--muted); font-weight: 500; font-size: 14px; padding: 8px 12px; border-radius: 10px;
  transition: color .2s, background .2s;
}
.nav-links a:hover { color: var(--text); background: var(--glass); text-decoration: none; }
.nav-links a.active { color: var(--text); background: var(--glass-2); box-shadow: inset 0 0 0 1px var(--stroke); }
.lang-toggle {
  display: inline-flex; border: 1px solid var(--stroke-2); border-radius: 999px; overflow: hidden; margin-left: 8px;
}
.lang-toggle button {
  background: transparent; border: 0; color: var(--muted); padding: 5px 10px; font-size: 12px; font-weight: 600; cursor: pointer; letter-spacing: .04em;
}
.lang-toggle button.active { background: var(--glass-2); color: var(--text); }
.status-pill {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted);
  padding: 5px 10px; border: 1px solid var(--stroke); border-radius: 999px; background: var(--glass);
  font-family: var(--mono);
}
.status-pill i { width: 8px; height: 8px; border-radius: 50%; background: var(--muted-2); box-shadow: 0 0 8px transparent; transition: all .3s; }
.status-pill.ok i { background: var(--green); box-shadow: 0 0 8px var(--green); }
.status-pill.bad i { background: var(--red); box-shadow: 0 0 8px var(--red); }
.status-pill.warn i { background: var(--amber); box-shadow: 0 0 8px var(--amber); }
.nav-burger { display: none; margin-left: auto; background: var(--glass); border: 1px solid var(--stroke); color: var(--text); border-radius: 10px; width: 40px; height: 40px; cursor: pointer; }

/* ------------------------------------------------------------------ views */
.view { display: none; padding-bottom: 80px; }
.view.active { display: block; animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ------------------------------------------------------------------ hero */
.hero { padding: 88px 0 48px; text-align: center; position: relative; }
.hero h1 {
  font-size: clamp(36px, 6vw, 64px); font-weight: 800; letter-spacing: -0.03em; line-height: 1.05;
  background: linear-gradient(90deg, #fff 0%, #a5f3fc 45%, #93c5fd 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero p.lead { color: var(--muted); font-size: clamp(16px, 2vw, 19px); max-width: 640px; margin: 18px auto 34px; }
.hero-cat { width: 128px; height: 128px; margin: 0 auto 18px; filter: drop-shadow(0 0 24px rgba(34,211,238,0.35)); animation: float 6s ease-in-out infinite; }
@keyframes float { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
.eyebrow {
  display: inline-flex; align-items: center; gap: 8px; font-size: 12px; letter-spacing: .12em; text-transform: uppercase;
  color: var(--cyan); background: rgba(34,211,238,0.08); border: 1px solid rgba(34,211,238,0.25); padding: 6px 12px; border-radius: 999px; margin-bottom: 20px;
  font-family: var(--mono);
}

/* ------------------------------------------------------------ search box */
.searchbar {
  display: flex; gap: 10px; max-width: 760px; margin: 0 auto;
  background: var(--glass); border: 1px solid var(--stroke-2); border-radius: 18px; padding: 8px;
  backdrop-filter: blur(14px); box-shadow: var(--shadow);
  transition: box-shadow .25s, border-color .25s;
}
.searchbar:focus-within { border-color: rgba(34,211,238,0.6); box-shadow: var(--shadow), var(--glow); }
.searchbar input {
  flex: 1; min-width: 0; background: transparent; border: 0; outline: 0; color: var(--text); font-size: 17px; padding: 12px 14px; font-family: inherit;
}
.searchbar input::placeholder { color: var(--muted-2); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 20px; border-radius: 12px; border: 1px solid transparent; font-weight: 600; font-size: 15px; cursor: pointer;
  transition: transform .15s, box-shadow .2s, background .2s, opacity .2s; white-space: nowrap; color: var(--text);
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--accent); color: #041018; box-shadow: 0 6px 20px rgba(34,211,238,0.25); }
.btn-primary:hover:not(:disabled) { box-shadow: 0 8px 26px rgba(34,211,238,0.4); transform: translateY(-1px); }
.btn-green { background: var(--accent-2); color: #041018; box-shadow: 0 6px 20px rgba(52,211,153,0.25); }
.btn-ghost { background: var(--glass); border-color: var(--stroke-2); }
.btn-ghost:hover:not(:disabled) { background: var(--glass-2); }
.btn-sm { padding: 8px 14px; font-size: 13px; border-radius: 10px; }
.btn svg { width: 18px; height: 18px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 18px; }
.chip {
  background: var(--glass); border: 1px solid var(--stroke); color: var(--muted); border-radius: 999px; padding: 7px 14px; font-size: 13px; cursor: pointer;
  transition: all .2s; display: inline-flex; align-items: center; gap: 6px; font-family: inherit;
}
.chip:hover { color: var(--text); border-color: var(--stroke-2); background: var(--glass-2); transform: translateY(-1px); }
.chip.on { color: #041018; background: var(--accent); border-color: transparent; font-weight: 600; }
.chip .n { font-family: var(--mono); font-size: 11px; opacity: .8; }
.chip.off { opacity: .45; text-decoration: line-through; }

/* --------------------------------------------------------------- features */
.features { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 18px; margin-top: 64px; }
.card {
  background: var(--glass); border: 1px solid var(--stroke); border-radius: var(--radius); padding: 24px;
  backdrop-filter: blur(12px); transition: transform .2s, border-color .2s;
}
.card:hover { border-color: var(--stroke-2); transform: translateY(-2px); }
.card .ic {
  width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; margin-bottom: 14px;
  background: rgba(34,211,238,0.1); border: 1px solid rgba(34,211,238,0.3); color: var(--cyan);
}
.card .ic svg { width: 22px; height: 22px; }
.card h3 { font-size: 17px; margin-bottom: 6px; font-weight: 700; }
.card p { color: var(--muted); font-size: 14px; }

.section-title { font-size: 22px; font-weight: 700; margin: 56px 0 14px; letter-spacing: -0.01em; }
.section-title small { color: var(--muted); font-weight: 500; font-size: 14px; margin-left: 10px; }
.topics { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.topic {
  background: var(--glass); border: 1px solid var(--stroke); border-radius: 14px; padding: 14px; text-align: left; color: var(--text); cursor: pointer;
  display: flex; align-items: center; gap: 10px; font-size: 14px; font-weight: 500; transition: all .2s; font-family: inherit;
}
.topic:hover { border-color: rgba(34,211,238,0.5); background: var(--glass-2); transform: translateY(-2px); }
.topic span.e { font-size: 22px; }

/* ----------------------------------------------------------- search view */
.toolbar { position: sticky; top: var(--nav-h); z-index: 40; padding: 14px 0 10px; background: linear-gradient(180deg, rgba(7,11,20,0.92), rgba(7,11,20,0.75) 80%, transparent); }
.toolbar .searchbar { max-width: none; padding: 6px; }
.toolbar .searchbar input { font-size: 15px; padding: 9px 12px; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 10px; }
.filters .sep { width: 1px; height: 22px; background: var(--stroke-2); margin: 0 4px; }
.range { display: inline-flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); background: var(--glass); border: 1px solid var(--stroke); padding: 5px 10px; border-radius: 999px; }
.range input { accent-color: var(--cyan); width: 90px; }
.range b { font-family: var(--mono); color: var(--text); font-weight: 500; min-width: 34px; }
.seg { display: inline-flex; border: 1px solid var(--stroke); border-radius: 999px; overflow: hidden; background: var(--glass); }
.seg button { background: transparent; border: 0; color: var(--muted); font-size: 12px; padding: 6px 11px; cursor: pointer; font-family: inherit; }
.seg button.on { background: var(--glass-2); color: var(--text); }

.meta-line { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; color: var(--muted); font-size: 13px; margin: 14px 0 16px; min-height: 22px; }
.meta-line .tag { font-family: var(--mono); font-size: 12px; background: var(--glass); border: 1px solid var(--stroke); padding: 2px 8px; border-radius: 6px; }
.meta-line .tag.ok { border-color: rgba(52,211,153,0.4); color: var(--green); }
.meta-line .tag.bad { border-color: rgba(248,113,113,0.4); color: var(--red); }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.tile {
  position: relative; background: #fff; border-radius: 14px; overflow: hidden; border: 1px solid var(--stroke); cursor: pointer;
  transition: transform .2s, box-shadow .2s, border-color .2s; aspect-ratio: 1 / 1.2;
}
.tile:hover { transform: translateY(-4px); border-color: rgba(34,211,238,0.6); box-shadow: 0 12px 30px rgba(34,211,238,0.18); }
.tile img { width: 100%; height: 100%; object-fit: contain; background: #fff; padding: 8px; }
.tile .badge {
  position: absolute; top: 8px; left: 8px; font-size: 11px; font-family: var(--mono); background: rgba(7,11,20,0.8); color: var(--text);
  padding: 3px 7px; border-radius: 6px; border: 1px solid var(--stroke-2); backdrop-filter: blur(6px);
}
.tile .score { position: absolute; top: 8px; right: 8px; font-size: 11px; font-family: var(--mono); padding: 3px 7px; border-radius: 6px; background: rgba(52,211,153,0.18); color: #052e1e; border: 1px solid rgba(52,211,153,0.6); font-weight: 700; }
.tile .score.mid { background: rgba(251,191,36,0.2); color: #3b2604; border-color: rgba(251,191,36,0.7); }
.tile .cap {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 22px 10px 8px; font-size: 12px; color: #e6edf7;
  background: linear-gradient(180deg, transparent, rgba(7,11,20,0.9)); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tile .cap small { display: block; color: var(--muted); font-size: 11px; }

.empty { text-align: center; padding: 60px 20px; color: var(--muted); }
.empty h3 { color: var(--text); margin-bottom: 8px; }
.loader { display: none; text-align: center; padding: 40px; color: var(--muted); }
.loader.active { display: block; }
.spinner { width: 42px; height: 42px; border-radius: 50%; border: 3px solid var(--stroke-2); border-top-color: var(--cyan); animation: spin .9s linear infinite; margin: 0 auto 12px; }
@keyframes spin { to { transform: rotate(360deg); } }
.loader .steps { font-family: var(--mono); font-size: 12px; margin-top: 6px; }
.more { display: flex; justify-content: center; margin-top: 24px; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); opacity: 0; pointer-events: none; z-index: 200;
  background: rgba(15,26,46,0.95); border: 1px solid var(--stroke-2); color: var(--text); padding: 12px 18px; border-radius: 12px; font-size: 14px; box-shadow: var(--shadow); transition: all .25s; max-width: min(90vw, 520px); }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { border-color: rgba(248,113,113,0.5); }
.toast.ok { border-color: rgba(52,211,153,0.5); }

/* ------------------------------------------------------------ AI studio */
.ai-layout { display: grid; grid-template-columns: 380px 1fr; gap: 20px; margin-top: 28px; }
.panel { background: var(--glass); border: 1px solid var(--stroke); border-radius: var(--radius); padding: 22px; backdrop-filter: blur(12px); }
.panel h2 { font-size: 18px; margin-bottom: 4px; }
.panel .sub { color: var(--muted); font-size: 13px; margin-bottom: 18px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; letter-spacing: .04em; text-transform: uppercase; font-family: var(--mono); }
.field input, .field select, .field textarea {
  width: 100%; background: rgba(7,11,20,0.5); border: 1px solid var(--stroke-2); color: var(--text); border-radius: 10px; padding: 11px 12px; font-size: 15px; outline: 0; font-family: inherit;
  transition: border-color .2s, box-shadow .2s;
}
.field textarea { resize: vertical; min-height: 84px; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: rgba(34,211,238,0.6); box-shadow: var(--glow); }
.field select option { background: var(--bg-2); }
.ai-preview { min-height: 420px; display: grid; place-items: center; background: repeating-conic-gradient(rgba(255,255,255,0.04) 0 25%, transparent 0 50%) 0 0 / 24px 24px; border-radius: 12px; border: 1px dashed var(--stroke-2); position: relative; overflow: hidden; }
.ai-preview img { max-height: 70vh; max-width: 100%; background: #fff; border-radius: 8px; box-shadow: var(--shadow); }
.ai-preview .placeholder { color: var(--muted-2); text-align: center; padding: 30px; font-size: 14px; }
.ai-preview .placeholder svg { width: 64px; height: 64px; margin: 0 auto 12px; opacity: .5; }
.ai-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.quota { font-family: var(--mono); font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.quota .bar { flex: 1; height: 6px; background: var(--glass-2); border-radius: 3px; overflow: hidden; }
.quota .bar i { display: block; height: 100%; background: var(--accent-2); width: 0; transition: width .4s; }
.history { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; margin-top: 16px; }
.history .h { background: #fff; border-radius: 8px; overflow: hidden; border: 1px solid var(--stroke); cursor: pointer; aspect-ratio: 1/1.3; }
.history .h img { width: 100%; height: 100%; object-fit: contain; }
.note { font-size: 13px; color: var(--muted); background: rgba(251,191,36,0.06); border: 1px solid rgba(251,191,36,0.25); border-radius: 10px; padding: 10px 12px; }
.note.info { background: rgba(34,211,238,0.06); border-color: rgba(34,211,238,0.25); }
.kbd { font-family: var(--mono); font-size: 12px; background: var(--glass-2); border: 1px solid var(--stroke-2); padding: 1px 6px; border-radius: 5px; }

/* ----------------------------------------------------------------- modal */
.modal { position: fixed; inset: 0; z-index: 100; display: none; align-items: center; justify-content: center; padding: 16px; background: rgba(3,6,12,0.8); backdrop-filter: blur(10px); }
.modal.active { display: flex; }
.modal-box { width: min(1100px, 100%); max-height: 94vh; overflow: hidden; background: rgba(11,18,32,0.98); border: 1px solid var(--stroke-2); border-radius: 20px; box-shadow: var(--shadow); display: grid; grid-template-columns: 1fr 340px; }
.modal-main { padding: 18px; display: grid; place-items: center; background: repeating-conic-gradient(rgba(255,255,255,0.035) 0 25%, transparent 0 50%) 0 0 / 24px 24px; border-right: 1px solid var(--stroke); min-height: 0; overflow: hidden; }
.sheet { background: #fff; box-shadow: 0 20px 50px rgba(0,0,0,0.5); position: relative; display: inline-block; max-width: 100%; }
.sheet canvas { display: block; max-width: 100%; max-height: calc(94vh - 40px); width: auto; height: auto; }
.modal-side { padding: 22px; display: flex; flex-direction: column; gap: 14px; overflow: auto; }
.modal-side h3 { font-size: 17px; }
.modal-side .meta { font-size: 12px; color: var(--muted); font-family: var(--mono); line-height: 1.7; word-break: break-word; }
.modal-close { position: absolute; top: 12px; right: 12px; background: var(--glass-2); border: 1px solid var(--stroke-2); color: var(--text); width: 36px; height: 36px; border-radius: 10px; cursor: pointer; font-size: 18px; z-index: 2; }
.opt-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 13px; color: var(--muted); }
.switch { position: relative; width: 40px; height: 22px; background: var(--glass-2); border: 1px solid var(--stroke-2); border-radius: 999px; cursor: pointer; transition: background .2s; flex: none; }
.switch::after { content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--muted); transition: all .2s; }
.switch.on { background: rgba(34,211,238,0.3); border-color: rgba(34,211,238,0.6); }
.switch.on::after { left: 20px; background: var(--cyan); }
.modal-side .actions { display: grid; gap: 8px; margin-top: auto; }
.modal-side .actions .btn { width: 100%; }
.progress { font-family: var(--mono); font-size: 12px; color: var(--cyan); min-height: 16px; }

/* ---------------------------------------------------------------- footer */
footer { border-top: 1px solid var(--stroke); padding: 28px 0; color: var(--muted); font-size: 13px; }
footer .container { display: flex; flex-wrap: wrap; gap: 12px 24px; align-items: center; justify-content: space-between; }
footer .srcs { display: flex; flex-wrap: wrap; gap: 6px 14px; }

/* ------------------------------------------------------------ responsive */
@media (max-width: 900px) {
  .ai-layout { grid-template-columns: 1fr; }
  .modal-box { grid-template-columns: 1fr; overflow: auto; }
  .modal-main { border-right: 0; border-bottom: 1px solid var(--stroke); overflow: visible; }
  .sheet canvas { max-height: 60vh; }
}
@media (max-width: 720px) {
  .container { width: calc(100% - 28px); }
  .nav-links { display: none; position: absolute; top: var(--nav-h); left: 0; right: 0; flex-direction: column; align-items: stretch; padding: 10px 14px 16px; background: rgba(7,11,20,0.96); border-bottom: 1px solid var(--stroke); }
  .nav-links.open { display: flex; }
  .nav-burger { display: block; }
  .nav .status-pill { display: none; }
  .hero { padding: 48px 0 32px; }
  .searchbar { flex-direction: column; }
  .searchbar .btn { width: 100%; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
  .sheet { max-width: 100%; }
  .modal { padding: 8px; }
}

/* ------------------------------------------------------------- printing */
@media print {
  body * { visibility: hidden !important; }
  body::before, body::after { display: none; }
}
