/* DzhetikSchool — styles from the brandbook.
   Palette: cherry #52000C, warm ivory #F1E5D7, noir black #1D1717, cherry red #810100.
   Type: headings — condensed grotesque (Heading Now; Oswald until the licence is sorted),
         text — Inter, accents — script (Bella Script CYR; Marck Script as a free stand-in).
   The one loud element: the display greeting with a script word over it, as on the brandbook slides.
   Everything else stays quiet so the data reads first. */

:root {
  --cherry: #52000c;
  --ivory: #f1e5d7;
  --noir: #1d1717;
  --red: #810100;
  --paper: #fbf6ef;
  --rose: #a07a7a;
  --muted: #6f6260;
  --line: rgba(29, 23, 23, 0.16);

  --ok: #3d6a37;
  --wait: #93620a;
  --bad: #810100;
  --neutral: #6f6260;

  --bg: var(--ivory);
  --surface: var(--paper);
  --text: var(--noir);
  --text-2: var(--muted);
  --accent: var(--cherry);
  --on-accent: var(--ivory);

  --f-head: "Heading Now", "Oswald", "Arial Narrow", "Roboto Condensed", sans-serif;
  --f-body: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --f-script: "Bella Script CYR", "Marck Script", "Segoe Script", cursive;

  --r-lg: 28px;
  --r-md: 18px;
  --r-sm: 12px;
  --tabbar-h: 72px;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #1d1717;
  --surface: #2a2121;
  --text: #f1e5d7;
  --text-2: #bfaea3;
  --line: rgba(241, 229, 215, 0.16);
  --rose: #7a5a5a;
  --ok: #8fbf7f;
  --wait: #e0b25a;
  --bad: #ff8a7a;
  --neutral: #bfaea3;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 400 16px/1.5 var(--f-body);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }
:focus-visible { outline: 3px solid var(--red); outline-offset: 2px; border-radius: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ------------------------------------------------------------ layout */
.app { max-width: 640px; margin: 0 auto; padding: 0 16px calc(var(--tabbar-h) + 32px); }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 0 6px;
}
.back { display: inline-flex; gap: 6px; align-items: center; background: none; border: 0; padding: 8px 0; color: var(--text-2); cursor: pointer; }

/* ------------------------------------------------------------ wordmark */
.wordmark { position: relative; display: inline-block; line-height: 1; text-decoration: none; }
.wordmark b {
  font: 700 22px/1 var(--f-head); letter-spacing: 0.01em; color: var(--accent);
}
.wordmark i {
  position: absolute; left: 34%; top: 52%;
  font: 400 22px/1 var(--f-script); font-style: normal; color: var(--red);
  text-shadow: 0 0 3px var(--bg), 0 0 3px var(--bg), 0 0 3px var(--bg);
  transform: rotate(-6deg);
}
:root[data-theme="dark"] .wordmark b { color: var(--ivory); }
:root[data-theme="dark"] .wordmark i { color: #d9534a; }

/* ------------------------------------------------------------ display heading (brand moment) */
.display {
  position: relative; margin: 18px 0 30px; padding-bottom: 8px;
  font: 700 clamp(44px, 13vw, 72px)/0.92 var(--f-head);
  text-transform: uppercase; letter-spacing: -0.005em; color: var(--accent);
  overflow-wrap: anywhere;
}
:root[data-theme="dark"] .display { color: var(--ivory); }
.display .script {
  position: absolute; left: 22%; bottom: -14px;
  font: 400 clamp(30px, 8.5vw, 46px)/1 var(--f-script);
  text-transform: none; color: var(--red); letter-spacing: 0;
  transform: rotate(-5deg);
  text-shadow:
    2px 0 0 var(--bg), -2px 0 0 var(--bg), 0 2px 0 var(--bg), 0 -2px 0 var(--bg),
    2px 2px 0 var(--bg), -2px -2px 0 var(--bg), 2px -2px 0 var(--bg), -2px 2px 0 var(--bg);
  white-space: nowrap;
}
:root[data-theme="dark"] .display .script { color: #e0675c; }

h2 { font: 600 22px/1.15 var(--f-head); text-transform: uppercase; letter-spacing: 0.01em; margin: 28px 0 12px; }
h3 { font: 600 17px/1.3 var(--f-body); margin: 0 0 4px; }
p { margin: 0 0 12px; }
.muted { color: var(--text-2); }
.small { font-size: 14px; }

/* ------------------------------------------------------------ hero card: next lesson */
.hero {
  position: relative; overflow: hidden;
  background-color: var(--cherry); color: var(--ivory);
  background-image: radial-gradient(rgba(241, 229, 215, 0.13) 22%, transparent 24%);
  background-size: 34px 34px; background-position: 6px 6px;
  border-radius: var(--r-lg); padding: 22px 20px 20px;
}
.hero .when { font: 700 34px/1 var(--f-head); text-transform: uppercase; margin: 6px 0 8px; }
.hero .what { font-size: 17px; font-weight: 600; }
.hero .who { color: rgba(241, 229, 215, 0.78); font-size: 15px; }
.hero .actions { margin-top: 18px; display: flex; gap: 10px; flex-wrap: wrap; }
.hero .btn.primary { background: var(--ivory); color: var(--cherry); }
.hero .btn.ghost { border-color: rgba(241, 229, 215, 0.5); color: var(--ivory); }
.hero .label { font-size: 14px; color: rgba(241, 229, 215, 0.78); }

/* ------------------------------------------------------------ lists & rows */
.list { background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--r-md); overflow: hidden; }
.row {
  display: flex; gap: 12px; align-items: center; justify-content: space-between;
  padding: 14px 16px; border-top: 1px solid var(--line); text-decoration: none;
  background: none; width: 100%; text-align: left; border-left: 0; border-right: 0; border-bottom: 0;
}
.row:first-child { border-top: 0; }
a.row, button.row { cursor: pointer; }
a.row:hover, button.row:hover { background: rgba(82, 0, 12, 0.04); }
.row .main { min-width: 0; flex: 1; }
.row .title { font-weight: 600; }
.row .sub { color: var(--text-2); font-size: 14px; }
.row .side { text-align: right; flex-shrink: 0; }
.chev { color: var(--text-2); }

.day { font: 600 15px/1 var(--f-body); color: var(--text-2); margin: 22px 4px 8px; }
.day:first-letter { text-transform: uppercase; }

/* balance */
.meter { height: 8px; border-radius: 99px; background: rgba(82, 0, 12, 0.12); overflow: hidden; margin-top: 8px; }
.meter > span { display: block; height: 100%; background: var(--cherry); border-radius: inherit; }
:root[data-theme="dark"] .meter { background: rgba(241, 229, 215, 0.15); }
:root[data-theme="dark"] .meter > span { background: var(--ivory); }
.big-num { font: 700 30px/1 var(--f-head); }

/* ------------------------------------------------------------ status badges (colour + text, ТЗ 21) */
.badge {
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
  font-size: 13px; font-weight: 600; padding: 4px 10px; border-radius: 99px;
  border: 1.5px solid currentColor;
}
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge.ok { color: var(--ok); }
.badge.wait { color: var(--wait); }
.badge.bad { color: var(--bad); }
.badge.neutral { color: var(--neutral); }

/* ------------------------------------------------------------ buttons & forms */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 20px; border-radius: 99px; cursor: pointer;
  border: 1.5px solid var(--accent); background: transparent; color: var(--accent);
  font-weight: 600; text-decoration: none; white-space: nowrap;
}
.btn.primary { background: var(--accent); color: var(--on-accent); }
.btn.danger { border-color: var(--bad); color: var(--bad); }
.btn.block { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: default; }
:root[data-theme="dark"] .btn { border-color: var(--ivory); color: var(--ivory); }
:root[data-theme="dark"] .btn.primary { background: var(--ivory); color: var(--cherry); }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }

.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 14px; font-weight: 600; margin-bottom: 6px; }
.field small { display: block; color: var(--text-2); margin-top: 4px; }
input[type="text"], input[type="password"], input[type="number"], input[type="url"], input[type="email"],
input[type="datetime-local"], input[type="tel"], select, textarea {
  width: 100%; min-height: 48px; padding: 12px 14px; border-radius: var(--r-sm);
  border: 1.5px solid var(--line); background: var(--surface);
}
textarea { min-height: 120px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
:root[data-theme="dark"] input:focus, :root[data-theme="dark"] select:focus, :root[data-theme="dark"] textarea:focus { border-color: var(--ivory); }
.check { display: flex; gap: 10px; align-items: center; padding: 12px 16px; border-top: 1px solid var(--line); }
.check:first-child { border-top: 0; }
.check input { width: 20px; height: 20px; accent-color: var(--cherry); }

.card { background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--r-md); padding: 18px; }
.card + .card { margin-top: 12px; }
.card + p, .card + .btn { margin-top: 14px; }
.note { border-left: 3px solid var(--red); padding: 8px 0 8px 14px; margin: 12px 0; }
.secret { font: 700 28px/1 var(--f-head); letter-spacing: 0.06em; background: var(--ivory); color: var(--cherry); border-radius: var(--r-sm); padding: 14px; text-align: center; margin: 10px 0; user-select: all; }
.error { color: var(--bad); font-weight: 600; margin: 8px 0; }

/* segmented tabs */
.seg { display: flex; gap: 6px; overflow-x: auto; padding: 2px; margin: 0 0 14px; scrollbar-width: none; }
.seg a, .seg button {
  flex-shrink: 0; padding: 9px 16px; border-radius: 99px; text-decoration: none; cursor: pointer;
  border: 1.5px solid var(--line); background: transparent; font-weight: 600; font-size: 14px;
}
.seg .on { background: var(--noir); color: var(--ivory); border-color: var(--noir); }
:root[data-theme="dark"] .seg .on { background: var(--ivory); color: var(--noir); border-color: var(--ivory); }

/* tiles for staff */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.tile { background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--r-md); padding: 16px; }
.tile .big-num { color: var(--accent); }
:root[data-theme="dark"] .tile .big-num { color: var(--ivory); }

/* empty states: brand stripes */
.empty {
  border-radius: var(--r-md); padding: 26px 20px; text-align: center;
  background: repeating-linear-gradient(90deg, rgba(82, 0, 12, 0.05) 0 14px, transparent 14px 28px), var(--surface);
  border: 1.5px dashed var(--line);
}
.empty .script-note { font: 400 30px/1 var(--f-script); color: var(--red); display: block; margin-bottom: 8px; }
:root[data-theme="dark"] .empty .script-note { color: #e0675c; }

/* ------------------------------------------------------------ tab bar */
.tabbar {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  width: min(608px, calc(100% - 24px)); height: var(--tabbar-h);
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  background: var(--noir); border-radius: 26px; padding: 6px; z-index: 10;
  box-shadow: 0 10px 30px rgba(29, 23, 23, 0.25);
}
:root[data-theme="dark"] .tabbar { background: #2e2424; box-shadow: none; border: 1px solid var(--line); }
.tabbar a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: rgba(241, 229, 215, 0.62); text-decoration: none; font-size: 12px; font-weight: 600; border-radius: 20px;
}
.tabbar a.on { color: var(--noir); background: var(--ivory); }
.tabbar svg { width: 22px; height: 22px; }
.tabbar .count { position: absolute; transform: translate(14px, -12px); background: var(--red); color: var(--ivory); border-radius: 99px; font-size: 11px; padding: 0 6px; }

/* ------------------------------------------------------------ auth screen */
.auth {
  min-height: 100vh; display: grid; place-items: center; padding: 24px 16px;
  background-color: var(--ivory);
  background-image: radial-gradient(rgba(82, 0, 12, 0.85) 9%, transparent 10%);
  background-size: 44px 44px;
}
:root[data-theme="dark"] .auth { background-color: var(--noir); background-image: radial-gradient(rgba(160, 122, 122, 0.55) 9%, transparent 10%); }
.auth-card { width: min(420px, 100%); background: var(--surface); border: 2px solid var(--noir); border-radius: 32px; padding: 26px 22px 24px; }
:root[data-theme="dark"] .auth-card { border-color: var(--line); }
.auth-card .display { margin-top: 20px; font-size: clamp(48px, 15vw, 64px); }

/* toast */
.toast {
  position: fixed; left: 16px; right: 16px; margin: 0 auto; width: fit-content; bottom: calc(var(--tabbar-h) + 28px);
  background: var(--noir); color: var(--ivory); padding: 12px 18px; border-radius: 14px; z-index: 20;
  font-weight: 600; max-width: calc(100% - 32px);
}
:root[data-theme="dark"] .toast { background: var(--ivory); color: var(--noir); }

.loader { padding: 60px 0; text-align: center; color: var(--text-2); }
.demo-bar { background: var(--noir); color: var(--ivory); font-size: 13px; text-align: center; padding: 6px 12px; }
.demo-bar button { background: none; border: 1px solid rgba(241,229,215,.5); color: var(--ivory); border-radius: 99px; padding: 2px 10px; margin-left: 6px; cursor: pointer; font-size: 12px; }

@media (prefers-reduced-motion: no-preference) {
  .display .script { animation: write 0.7s ease-out 0.1s both; }
  @keyframes write { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }
}
@media (min-width: 700px) {
  .app { padding-top: 12px; }
}

/* attached files */
.files { display: grid; gap: 8px; margin-top: 8px; }
.file {
  display: flex; justify-content: space-between; align-items: center; gap: 12px; width: 100%;
  padding: 12px 14px; border-radius: var(--r-sm); border: 1.5px solid var(--line); background: var(--bg);
  cursor: pointer; text-align: left;
}
.file-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
input[type="file"] { width: 100%; padding: 12px; border: 1.5px dashed var(--line); border-radius: var(--r-sm); background: var(--surface); }
