/* Merak Molası — shared stylesheet for the public pages and the editor panel. */
:root {
  --accent: #ff6b35;
  --accent-strong: #e85a24;
  --accent-soft: #fff1eb;
  --bg: #f7f7f8;
  --surface: #ffffff;
  --surface-2: #f1f1f3;
  --text: #1c1c1f;
  --muted: #6b6b75;
  --border: #e3e3e8;
  --ok: #16a34a;
  --ok-soft: #e8f7ee;
  --warn: #b45309;
  --warn-soft: #fef3c7;
  --danger: #dc2626;
  --danger-soft: #fdecec;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .05), 0 4px 16px rgba(0, 0, 0, .04);
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --accent-soft: #3a2117;
    --bg: #121214;
    --surface: #1b1b1f;
    --surface-2: #24242a;
    --text: #ececf1;
    --muted: #a0a0ab;
    --border: #2f2f36;
    --ok-soft: #12301f;
    --warn-soft: #3a2a0c;
    --danger-soft: #3b1515;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .6em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.2rem; }
p { margin: 0 0 1em; }
code { background: var(--surface-2); padding: .1em .35em; border-radius: 4px; font-size: .9em; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

/* ---------- Layout ---------- */
.topbar {
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
  padding: .75rem 1rem; background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.brand { font-weight: 700; color: var(--text); display: flex; align-items: center; gap: .4rem; }
.brand .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); display: inline-block; }
.nav { display: flex; gap: .25rem; flex-wrap: wrap; flex: 1; }
.nav a { color: var(--muted); padding: .35rem .65rem; border-radius: 8px; }
.nav a:hover { background: var(--surface-2); text-decoration: none; color: var(--text); }
.nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.container { max-width: 1120px; margin: 0 auto; padding: 1.25rem 1rem 3rem; }
.narrow { max-width: 760px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.page-head h1 { margin: 0; }

/* ---------- Cards / stats ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.1rem; box-shadow: var(--shadow); }
.card + .card { margin-top: 1rem; }
.grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
.stat .label { color: var(--muted); font-size: .85rem; }
.stat .value { font-size: 1.8rem; font-weight: 700; }
.stat .hint { color: var(--muted); font-size: .8rem; }
.stat.accent .value { color: var(--accent); }
.section-title { margin: 1.5rem 0 .75rem; font-size: 1rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .6rem .75rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: .8rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td.nowrap { white-space: nowrap; }

/* ---------- Badges ---------- */
.badge { display: inline-block; padding: .1rem .5rem; border-radius: 999px; font-size: .75rem; font-weight: 600; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.accent { background: var(--accent-soft); color: var(--accent); }

/* ---------- Forms ---------- */
form.inline { display: inline; }
.form-grid { display: grid; gap: .9rem 1rem; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.field { display: flex; flex-direction: column; gap: .3rem; }
.field.full { grid-column: 1 / -1; }
label { font-size: .85rem; font-weight: 600; color: var(--muted); }
input[type=text], input[type=email], input[type=password], input[type=url], input[type=number], input[type=search],
input[type=datetime-local], select, textarea {
  width: 100%; padding: .55rem .7rem; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--text); font: inherit;
}
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
.field-error, .validation-summary-errors, .field-validation-error { color: var(--danger); font-size: .85rem; }
.validation-summary-errors ul { margin: .25rem 0 0; padding-left: 1.2rem; }
.input-validation-error { border-color: var(--danger) !important; }
fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: .9rem 1rem 1rem; margin: 0 0 1rem; }
legend { font-weight: 700; padding: 0 .4rem; }
.filters { display: flex; flex-wrap: wrap; gap: .5rem; align-items: end; margin-bottom: 1rem; }
.filters .field { min-width: 150px; }
.options-row { display: grid; gap: .5rem; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
.radio-inline { display: flex; align-items: center; gap: .35rem; font-weight: 400; color: var(--text); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: .35rem; padding: .5rem .95rem; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-weight: 600;
  cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-strong); }
.btn.danger { color: var(--danger); border-color: var(--danger); background: transparent; }
.btn.danger:hover { background: var(--danger-soft); }
.btn.small { padding: .25rem .6rem; font-size: .85rem; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }

/* ---------- Alerts ---------- */
.alert { padding: .7rem .9rem; border-radius: 8px; margin-bottom: 1rem; background: var(--accent-soft); }
.alert.ok { background: var(--ok-soft); color: var(--ok); }
.alert.danger { background: var(--danger-soft); color: var(--danger); }

/* ---------- Pager ---------- */
.pager { display: flex; gap: .5rem; align-items: center; justify-content: flex-end; margin-top: .75rem; }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.login-card { width: 100%; max-width: 380px; }
.login-card .field { margin-bottom: .8rem; }

/* ---------- Lesson editor + phone preview ---------- */
.editor { display: grid; gap: 1.25rem; grid-template-columns: minmax(0, 1fr) 320px; align-items: start; }
@media (max-width: 960px) { .editor { grid-template-columns: 1fr; } }
.preview-col { position: sticky; top: 70px; }
@media (max-width: 960px) { .preview-col { position: static; } }
.phone {
  width: 300px; max-width: 100%; margin: 0 auto; border: 10px solid #1d1d22; border-radius: 36px;
  background: #fffaf6; color: #1c1c1f; overflow: hidden; box-shadow: 0 10px 30px rgba(0, 0, 0, .18);
}
.phone .notch { height: 22px; background: #1d1d22; width: 45%; margin: 0 auto; border-radius: 0 0 14px 14px; }
.phone .screen { height: 540px; overflow-y: auto; padding: .9rem; }
.phone .p-head { display: flex; align-items: center; gap: .5rem; margin-bottom: .8rem; }
.phone .p-head .p-emoji { font-size: 1.6rem; }
.phone .p-head .p-title { font-weight: 800; font-size: 1.05rem; line-height: 1.2; }
.phone .p-head .p-meta { font-size: .75rem; color: #7a6f69; }
.phone .p-card { background: #fff; border-radius: 16px; padding: .9rem; margin-bottom: .7rem; box-shadow: 0 2px 10px rgba(255, 107, 53, .12); border: 1px solid #ffe2d6; }
.phone .p-card .c-emoji { font-size: 1.8rem; }
.phone .p-card .c-title { font-weight: 700; margin: .3rem 0; }
.phone .p-card .c-body { font-size: .9rem; white-space: pre-wrap; }
.phone .p-quiz { background: #ff6b35; color: #fff; border-radius: 16px; padding: .9rem; margin-bottom: .7rem; }
.phone .p-quiz .q { font-weight: 700; margin-bottom: .5rem; }
.phone .p-quiz .o { background: rgba(255, 255, 255, .18); border-radius: 10px; padding: .4rem .6rem; margin: .3rem 0; font-size: .88rem; }
.phone .p-quiz .o.correct { background: #fff; color: #c2410c; font-weight: 700; }
.phone .p-source { font-size: .72rem; color: #7a6f69; }

/* ---------- Public pages ---------- */
.hero { text-align: center; padding: 4rem 1rem 2rem; }
.hero .logo { font-size: 3.5rem; }
.hero h1 { font-size: 2.2rem; margin-bottom: .3rem; }
.hero p.lead { font-size: 1.15rem; color: var(--muted); max-width: 560px; margin: 0 auto 1.5rem; }
.play-badge { display: inline-flex; align-items: center; gap: .6rem; background: #000; color: #fff; padding: .7rem 1.2rem; border-radius: 10px; font-weight: 600; }
.play-badge:hover { text-decoration: none; opacity: .9; }
.features { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); margin-top: 2rem; }
.prose h2 { margin-top: 1.6rem; }
.prose ul { padding-left: 1.3rem; }
.prose li { margin-bottom: .35rem; }
.footer { text-align: center; color: var(--muted); font-size: .85rem; padding: 2rem 1rem; }
.footer a { color: var(--muted); margin: 0 .5rem; }
