:root {
  --bg: #f3f0ea;
  --paper: #fffcf7;
  --ink: #1b2330;
  --muted: #6b7380;
  --line: #e4ddd2;
  --accent: #2156d6;
  --accent-soft: #e8eefc;
  --danger: #c43c2c;
  --danger-soft: #fdeceb;
  --ok: #0f7a56;
  --shadow: 0 18px 50px rgba(27, 35, 48, 0.08);
  --radius: 18px;
  --tap: 48px;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background:
    radial-gradient(900px 380px at 100% -10%, #e4ecfb 0%, transparent 55%),
    var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }

[hidden] { display: none !important; }

.kicker {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.lede, .muted { color: var(--muted); }

.login {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px 18px calc(24px + env(safe-area-inset-bottom));
}

.login-card, .panel, .row, .sheet-card {
  background: var(--paper);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.login-card {
  width: min(420px, 100%);
  padding: 28px 24px;
  border-radius: 28px;
}

.login-card h1, .topbar h1 {
  margin: 0;
  letter-spacing: -0.04em;
  font-size: 32px;
}

.stack { display: grid; gap: 14px; margin-top: 22px; }

.field {
  display: grid;
  gap: 6px;
}

.field > span {
  font-size: 12px;
  color: var(--muted);
}

input, select, textarea {
  width: 100%;
  min-height: var(--tap);
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}

textarea { min-height: 140px; resize: vertical; }

input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

select {
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'><path fill='%236b7380' d='M4 6l4 5 4-5'/></svg>");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 40px;
}

.search {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: var(--tap);
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
}

.search:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.search svg { flex: none; opacity: .45; }
.search input {
  border: 0;
  min-height: 44px;
  padding: 0;
  box-shadow: none;
}

.btn {
  min-height: var(--tap);
  padding: 0 16px;
  border: 0;
  border-radius: 14px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 650;
}

.btn.primary { background: var(--accent); color: #fff; }
.btn.danger { background: var(--danger-soft); color: var(--danger); }
.btn.ghost { background: transparent; color: var(--muted); }
.btn.wide { width: 100%; }

.form-error { color: var(--danger); margin: 0; font-size: 14px; }

.shell {
  min-height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr auto;
}

.sidebar { display: none; }

.main {
  padding: 18px 18px 110px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 18px;
}

.who { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 14px; }

.toolbar {
  display: grid;
  gap: 10px;
  margin-bottom: 14px;
}

.list { display: grid; gap: 10px; }

.row {
  display: grid;
  gap: 8px;
  padding: 14px;
  border-radius: var(--radius);
}

.row-top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

.row h3 { margin: 0; font-size: 17px; }
.row p { margin: 0; color: var(--muted); font-size: 13px; }

.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.actions .btn { min-height: 40px; }

.toggle {
  position: relative;
  width: 48px;
  height: 28px;
  border-radius: 999px;
  background: #d7d1c7;
  border: 0;
  flex: none;
}

.toggle.on { background: var(--ok); }
.toggle i {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  transition: transform .18s;
}
.toggle.on i { transform: translateX(20px); }

.chip {
  display: inline-flex;
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
}

.drop {
  display: grid;
  place-items: center;
  gap: 6px;
  min-height: 120px;
  padding: 16px;
  border: 1.5px dashed var(--line);
  border-radius: 16px;
  background: #fff;
  text-align: center;
  color: var(--muted);
}

.drop.drag { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
  background: rgba(255, 252, 247, 0.94);
  backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
}

.tab {
  min-height: 56px;
  border: 0;
  border-radius: 14px;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  display: grid;
  place-items: center;
  gap: 3px;
}

.tab svg { width: 20px; height: 20px; }
.tab.active { color: var(--accent); background: var(--accent-soft); }

.sheet {
  position: fixed;
  inset: 0;
  z-index: 20;
}

.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(27, 35, 48, 0.35);
}

.sheet-card {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: 92dvh;
  overflow: auto;
  padding: 10px 18px calc(22px + env(safe-area-inset-bottom));
  border-radius: 28px 28px 0 0;
}

.sheet-handle {
  width: 42px;
  height: 4px;
  margin: 6px auto 14px;
  border-radius: 99px;
  background: #d7d1c7;
}

.empty {
  padding: 40px 16px;
  text-align: center;
  color: var(--muted);
}

.lesson {
  display: grid;
  gap: 6px;
}

.lesson time { font-variant-numeric: tabular-nums; font-weight: 700; }

@media (min-width: 900px) {
  .shell {
    grid-template-columns: 240px 1fr;
    grid-template-rows: 1fr;
    max-width: 1180px;
    margin: 0 auto;
  }
  .sidebar {
    display: flex;
    flex-direction: column;
    gap: 18px;
    padding: 28px 18px;
  }
  .side-nav { display: grid; gap: 6px; }
  .side-nav .tab {
    grid-template-columns: 24px 1fr;
    justify-items: start;
    padding: 0 12px;
    font-size: 14px;
    min-height: 44px;
  }
  .tabbar, #logout-mobile { display: none; }
  .main { padding: 28px 28px 40px; }
  .toolbar { grid-template-columns: 1fr auto; align-items: center; }
  .sheet-card {
    left: 50%;
    right: auto;
    top: 50%;
    bottom: auto;
    width: min(560px, calc(100vw - 48px));
    transform: translate(-50%, -50%);
    border-radius: 24px;
    max-height: 86vh;
  }
  .sheet-handle { display: none; }
}
