:root {
  /* ── Professional light theme: navy sidebar, teal accent ─────────────
     Content sits on a soft cool-grey canvas with white surfaces; the
     sidebar is a deep navy panel. Accent moved from indigo to teal, with
     a warm amber for highlights — calmer and more "SaaS dashboard". */
  --bg: #f2f5fa;
  --bg-soft: #f7f9fc;
  --surface: #ffffff;
  --surface-2: #f4f6fa;
  --surface-3: #e9edf5;
  --sidebar-1: #12263f;
  --sidebar-2: #0b1a2e;
  --border: #e2e8f2;
  --border-soft: #ecf0f7;
  --text: #1e2b3d;
  --text-muted: #64748b;
  --text-dim: #94a3b8;

  --primary: #0d9488;
  --primary-dark: #0f766e;
  --primary-glow: rgba(13,148,136,.35);
  --danger: #e11d48;
  --danger-bg: #fde8ee;
  --success-bg: #e5f7ef;
  --success-fg: #0d7a4f;

  /* Accent colors */
  --c-indigo: #6366f1;
  --c-slate:  #64748b;
  --c-teal:   #0d9488;
  --c-violet: #8b5cf6;
  --c-amber:  #d97706;
  --c-green:  #16a34a;
  --c-coral:  #f43f5e;
  --c-pink:   #db2777;
  --c-blue:   #2563eb;

  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(18,38,63,.05), 0 6px 20px rgba(18,38,63,.06);
  --shadow-lg: 0 18px 50px rgba(18,38,63,.16);
  --font: "Nunito", "Poppins", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14.5px;
  line-height: 1.55;
}

a { color: var(--primary-dark); text-decoration: none; font-weight: 700; }
a:hover { color: var(--primary); text-decoration: none; }
code { background: var(--surface-3); padding: 1px 6px; border-radius: 6px; font-size: 12.5px; color: #334155; }
::selection { background: rgba(13,148,136,.22); }

/* ---------- App shell ---------- */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 248px; flex-shrink: 0; color: #fff; position: sticky; top: 0;
  height: 100vh; overflow-y: auto;
  background:
    radial-gradient(130% 40% at 0% 0%, rgba(13,148,136,.22), transparent 60%),
    linear-gradient(180deg, var(--sidebar-1), var(--sidebar-2));
  display: flex; flex-direction: column; padding: 18px 14px;
}
.sidebar::-webkit-scrollbar { width: 8px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.12); border-radius: 8px; }

/* Logo lockup sits in a clean white panel so the wordmark reads. */
.brand { display: flex; align-items: center; justify-content: center; padding: 6px 6px 18px; }
.brand-logo {
  display: block; width: 100%; max-width: 188px; height: auto;
  background: #fff; border-radius: 16px; padding: 14px 16px;
  box-shadow: 0 10px 26px rgba(0,0,0,.35);
}
.brand-mark {
  background: var(--primary); color: #fff; font-weight: 800;
  padding: 6px 10px; border-radius: 10px; letter-spacing: .5px;
}
.brand-name { font-weight: 800; font-size: 18px; }

.nav { display: flex; flex-direction: column; gap: 3px; }
.nav-link {
  position: relative; color: #b7c4d8; padding: 10px 13px; border-radius: 11px;
  font-weight: 700; font-size: 14px; display: flex; align-items: center; gap: 10px;
  transition: background .15s, color .15s;
}
.nav-link:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav-link.active {
  color: #fff;
  background: linear-gradient(90deg, rgba(13,148,136,.42), rgba(13,148,136,.14));
  box-shadow: inset 0 0 0 1px rgba(45,212,191,.35);
}
.nav-link.active::before {
  content: ""; position: absolute; left: 3px; top: 50%; transform: translateY(-50%);
  width: 4px; height: 18px; border-radius: 4px; background: #2dd4bf;
  box-shadow: 0 0 12px var(--primary-glow);
}
.nav-link.is-disabled { color: rgba(255,255,255,.32); cursor: not-allowed; }
.nav-emoji { font-size: 16px; width: 20px; text-align: center; flex-shrink: 0; }
.nav-section {
  margin: 16px 13px 5px; font-size: 10.5px; text-transform: uppercase;
  letter-spacing: .12em; color: rgba(255,255,255,.42); font-weight: 800;
}
.sidebar-foot { margin-top: auto; padding: 14px 12px 4px; color: rgba(255,255,255,.40); font-size: 12px; font-weight: 700; }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  background: rgba(255,255,255,.85); backdrop-filter: saturate(150%) blur(10px);
  border-bottom: 1px solid var(--border); padding: 15px 30px;
  position: sticky; top: 0; z-index: 20;
}
.page-title { font-size: 20px; margin: 0; font-weight: 800; letter-spacing: -.01em; color: var(--text); }
.user-menu { display: flex; align-items: center; gap: 12px; }
.user-name { color: var(--text-muted); font-weight: 700; }
a.user-name:hover { color: var(--text); }
.content { padding: 30px; max-width: 1180px; width: 100%; }

/* ---------- Cards / stats ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 18px; }
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px 22px; box-shadow: var(--shadow);
}
.card .stat { font-size: 32px; font-weight: 800; line-height: 1.1; }
.card .label { font-size: 13px; font-weight: 700; margin-top: 2px; }

/* Vivid gradient stat tiles on the dashboard. */
.cards > .card {
  position: relative; overflow: hidden; border: none; color: #fff;
}
.cards > .card::after {
  content: ""; position: absolute; right: -30px; bottom: -40px;
  width: 130px; height: 130px; border-radius: 50%;
  background: rgba(255,255,255,.14);
}
.cards > .card:nth-child(6n+1) { background: linear-gradient(135deg, #0d9488, #0f766e); }
.cards > .card:nth-child(6n+2) { background: linear-gradient(135deg, #2563eb, #1d4ed8); }
.cards > .card:nth-child(6n+3) { background: linear-gradient(135deg, #8b5cf6, #6d28d9); }
.cards > .card:nth-child(6n+4) { background: linear-gradient(135deg, #f59e0b, #d97706); }
.cards > .card:nth-child(6n+5) { background: linear-gradient(135deg, #ec4899, #be185d); }
.cards > .card:nth-child(6n+6) { background: linear-gradient(135deg, #10b981, #047857); }
.cards > .card .stat { color: #fff; }
.cards > .card .label { color: rgba(255,255,255,.92); }

/* ---------- Toolbar ---------- */
.toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; gap: 12px; flex-wrap: wrap; }
.toolbar h2 { margin: 0; font-size: 17px; font-weight: 800; color: var(--text); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); padding: 9px 15px; border-radius: 11px;
  font-weight: 800; cursor: pointer; font-size: 14px; font-family: inherit;
  transition: background .15s, border-color .15s, transform .05s;
  box-shadow: 0 1px 2px rgba(18,38,63,.06);
}
.btn:hover { text-decoration: none; background: var(--surface-2); border-color: #cbd5e4; color: var(--text); }
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  border-color: transparent; color: #fff; box-shadow: 0 6px 16px rgba(13,148,136,.35);
}
.btn-primary:hover { filter: brightness(1.06); background: linear-gradient(135deg, var(--primary), var(--primary-dark)); color: #fff; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: #c2103b; border-color: #c2103b; color: #fff; }
.btn-ghost { background: transparent; box-shadow: none; }
.btn-sm { padding: 6px 11px; font-size: 13px; border-radius: 9px; }

/* ---------- Tables ---------- */
.table {
  width: 100%; border-collapse: collapse; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow);
}
.table th, .table td { padding: 13px 16px; text-align: left; border-bottom: 1px solid var(--border-soft); }
.table th { background: var(--bg-soft); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); font-weight: 800; }
.table tr:last-child td { border-bottom: none; }
.table tbody tr { transition: background .12s; }
.table tr:hover td { background: #f6f9fd; }

.badge { display: inline-block; padding: 3px 11px; border-radius: 999px; font-size: 12px; font-weight: 800; }
.badge-published { background: var(--success-bg); color: var(--success-fg); }
.badge-draft { background: var(--surface-3); color: var(--text-muted); }
.badge-level { background: #e0f2f0; color: #0f766e; }
.badge-type { background: var(--surface-3); color: var(--text-muted); text-transform: capitalize; }

/* Colored level/band badges (Speaking, Courses…) */
.badge-beginner           { background: #e5f7ef; color: #0d7a4f; }
.badge-intermediate       { background: #e4edfd; color: #1d4ed8; }
.badge-upper_intermediate { background: #efe9fd; color: #6d28d9; }
.badge-advanced           { background: #fdeee9; color: #c2410c; }
.badge-journey            { background: #fdf3d7; color: #a16207; }

/* ---------- Forms ---------- */
.form { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); }
.form-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px; }
.field { margin-bottom: 18px; }
.field label { display: block; font-weight: 800; margin-bottom: 6px; color: #33415c; }
.field .hint { color: var(--text-muted); font-size: 12px; margin-top: 4px; font-weight: 600; }
input[type=text], input[type=password], input[type=email], input[type=url], input[type=number], textarea, select {
  width: 100%; padding: 10px 12px; border: 1.5px solid #d7deea;
  border-radius: var(--radius-sm); font-size: 14px; font-family: inherit;
  background: #fff; color: var(--text);
}
input::placeholder, textarea::placeholder { color: var(--text-dim); }
select option { background: #fff; color: var(--text); }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(13,148,136,.18); }
textarea { resize: vertical; min-height: 90px; }
.form-actions { display: flex; gap: 10px; margin-top: 6px; align-items: center; }

/* ---------- Flash / alerts ---------- */
.flash { padding: 13px 16px; border-radius: var(--radius-sm); margin-bottom: 18px; font-weight: 700; }
.flash-success { background: var(--success-bg); color: var(--success-fg); }
.flash-error { background: var(--danger-bg); color: #be123c; }
.alert-error { background: var(--danger-bg); color: #be123c; padding: 11px 14px; border-radius: var(--radius-sm); margin-bottom: 16px; font-weight: 700; }
.empty { text-align: center; color: var(--text-muted); padding: 52px 20px; font-weight: 700; background: var(--surface); border: 1.5px dashed #d7deea; border-radius: var(--radius); }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(900px 500px at 80% -10%, rgba(13,148,136,.16), transparent 60%),
    radial-gradient(700px 400px at 10% 110%, rgba(37,99,235,.10), transparent 55%),
    linear-gradient(180deg, #10233d, #0b1a2e); padding: 20px; }
.login-card { background: #fff; border: 1px solid var(--border); border-radius: 20px; padding: 38px; width: 380px; box-shadow: var(--shadow-lg); }
.login-card .brand { justify-content: center; padding-top: 0; }
.login-card .brand-logo { box-shadow: none; }
.login-card h2 { text-align: center; margin: 0 0 22px; font-weight: 800; color: var(--text); }

/* =====================================================================
   LESSON BUILDER
   ===================================================================== */
.builder { margin-top: 8px; }
.builder-blocks { display: flex; flex-direction: column; gap: 14px; margin-bottom: 16px; }

.block {
  background: var(--surface); border: 1px solid var(--border); border-left: 5px solid var(--c-slate);
  border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden;
}
.block.dragging { opacity: .5; }
.block-head {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px;
  background: var(--bg-soft); border-bottom: 1px solid var(--border-soft); cursor: default;
}
.block-handle { cursor: grab; color: var(--text-muted); font-size: 16px; user-select: none; }
.block-icon {
  width: 28px; height: 28px; border-radius: 8px; display: inline-flex;
  align-items: center; justify-content: center; color: #fff; font-weight: 800; font-size: 14px; flex-shrink: 0;
}
.block-title { font-weight: 800; }
.block-head .spacer { flex: 1; }
.block-body { padding: 16px 14px; }
.block-body .field:last-child { margin-bottom: 0; }

/* type accent colors */
.block--indigo { border-left-color: var(--c-indigo); } .block--indigo .block-icon { background: var(--c-indigo); }
.block--slate  { border-left-color: var(--c-slate); }  .block--slate  .block-icon { background: var(--c-slate); }
.block--teal   { border-left-color: var(--c-teal); }   .block--teal   .block-icon { background: var(--c-teal); }
.block--violet { border-left-color: var(--c-violet); } .block--violet .block-icon { background: var(--c-violet); }
.block--amber  { border-left-color: var(--c-amber); }  .block--amber  .block-icon { background: var(--c-amber); }
.block--green  { border-left-color: var(--c-green); }  .block--green  .block-icon { background: var(--c-green); }
.block--coral  { border-left-color: var(--c-coral); }  .block--coral  .block-icon { background: var(--c-coral); }
.block--pink   { border-left-color: var(--c-pink); }   .block--pink   .block-icon { background: var(--c-pink); }
.block--blue   { border-left-color: var(--c-blue); }   .block--blue   .block-icon { background: var(--c-blue); }

.icon-btn {
  border: none; background: transparent; cursor: pointer; color: var(--text-muted);
  font-size: 15px; padding: 4px 7px; border-radius: 7px; font-weight: 800;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn.danger:hover { background: var(--danger-bg); color: #be123c; }

/* repeater rows (vocab / dialogue / quiz options) */
.rep-row { display: flex; gap: 8px; align-items: flex-start; margin-bottom: 8px; }
.rep-row > * { flex: 1; }
.rep-row .rep-del { flex: 0 0 auto; }
.rep-row .opt-radio { flex: 0 0 auto; align-self: center; }

/* media preview inside a block */
.media-preview { margin-top: 8px; }
.media-preview img { max-width: 200px; border-radius: 10px; border: 1px solid var(--border); display: block; }
.media-preview .tag { color: var(--text-muted); font-size: 12px; font-weight: 700; }

/* block palette */
.palette {
  display: flex; flex-wrap: wrap; gap: 8px; padding: 16px; background: var(--surface);
  border: 1.5px dashed #d7deea; border-radius: var(--radius);
}
.palette-label { width: 100%; font-weight: 800; color: var(--text-muted); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
.chip {
  display: inline-flex; align-items: center; gap: 7px; padding: 8px 13px; border-radius: 999px;
  border: 1.5px solid var(--border); background: var(--surface); cursor: pointer; font-weight: 800; font-size: 13px;
  color: var(--text); transition: transform .05s, border-color .15s, background .15s;
}
.chip:hover { background: var(--surface-2); border-color: var(--primary); }
.chip:active { transform: translateY(1px); }
.chip .dot { width: 18px; height: 18px; border-radius: 6px; display: inline-flex; align-items: center; justify-content: center; color: #fff; font-size: 11px; }

/* ---------- Segmented filter tabs (media, etc.) ---------- */
.seg-tabs { display: inline-flex; flex-wrap: wrap; gap: 6px; background: var(--surface); border: 1px solid var(--border); padding: 5px; border-radius: 13px; box-shadow: 0 1px 2px rgba(18,38,63,.05); }
.seg-tab {
  border: none; background: transparent; color: var(--text-muted); cursor: pointer;
  padding: 8px 15px; border-radius: 9px; font-weight: 800; font-size: 13px; font-family: inherit;
  display: inline-flex; align-items: center; gap: 7px; transition: background .15s, color .15s;
}
.seg-tab:hover { color: var(--text); }
.seg-tab.active { background: linear-gradient(135deg, var(--primary), var(--primary-dark)); color: #fff; box-shadow: 0 4px 14px rgba(13,148,136,.35); }
.seg-tab .count {
  font-size: 11px; font-weight: 800; background: var(--surface-3); color: var(--text-muted);
  padding: 1px 8px; border-radius: 999px;
}
.seg-tab.active .count { background: rgba(255,255,255,.28); color: #fff; }

/* ---------- Media library grid ---------- */
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 16px; }
.media-item { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); transition: transform .08s, box-shadow .15s, border-color .15s; }
.media-item:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: #cbd5e4; }
.media-thumb { height: 122px; background: var(--surface-2) center/cover no-repeat; display: flex; align-items: center; justify-content: center; font-size: 34px; }
.media-thumb.is-svg {
  background-color: #fff; background-repeat: no-repeat;
  background-image:
    linear-gradient(45deg,#e7eaf3 25%,transparent 25%),
    linear-gradient(-45deg,#e7eaf3 25%,transparent 25%),
    linear-gradient(45deg,transparent 75%,#e7eaf3 75%),
    linear-gradient(-45deg,transparent 75%,#e7eaf3 75%);
  background-size: 16px 16px; background-position: 0 0,0 8px,8px -8px,-8px 0;
}
.media-thumb.is-svg img { width: 70%; height: 70%; object-fit: contain; }
.media-meta { padding: 10px 12px; }
.media-meta .name { font-weight: 800; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.media-meta .row { display: flex; align-items: center; justify-content: space-between; margin-top: 6px; }
.badge-image { background: #e4edfd; color: #1d4ed8; }
.badge-video { background: #f6e6fb; color: #a21caf; }
.badge-audio { background: #e5f7ef; color: #0d7a4f; }
.badge-svg   { background: #fdf3d7; color: #a16207; }

/* ---------- Modal ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(15,27,46,.55); display: none; align-items: center; justify-content: center; z-index: 50; padding: 20px; backdrop-filter: blur(3px); }
.modal-backdrop.open { display: flex; }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); width: 460px; max-width: 100%; padding: 22px; }
.modal h3 { margin: 0 0 16px; font-weight: 800; color: var(--text); }

/* ---------- Speaking scenarios ---------- */
.speak-teacher { display: flex; align-items: center; gap: 10px; }
.speak-emoji {
  width: 38px; height: 38px; border-radius: 11px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center; font-size: 19px;
  background: var(--surface-2); border: 1px solid var(--border);
}
.speak-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; font-weight: 600; }
.step-card {
  background: var(--surface); border: 1px solid var(--border); border-left: 5px solid var(--c-teal);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; margin-bottom: 12px;
}
.step-card .step-no {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; border-radius: 8px; background: var(--c-teal); color: #fff;
  font-weight: 800; font-size: 13px; margin-right: 8px;
}

@media (max-width: 760px) {
  .sidebar { width: 66px; padding: 16px 8px; }
  .brand-logo { padding: 8px; }
  .brand-name, .nav-section, .sidebar-foot, .nav-link span:not(.nav-emoji) { display: none; }
  .form-row { grid-template-columns: 1fr; }
}
