:root {
  --brand-dark: #17283c;
  --brand-light: #f4f0e8;
  --brand-accent: #b69a65;
  --ink: #202d3a;
  --muted: #59636c;
  --line: #e4dfd4;
  --surface: #fffdfa;
  --success: #255d49;
  --success-bg: #e8f1e9;
  --danger: #943b3b;
  --danger-bg: #faece9;
  --warning: #725617;
  --warning-bg: #f8f0de;
  --display: "Instrument Serif", Georgia, serif;
  --sans: "Instrument Sans", "Segoe UI", system-ui, sans-serif;
  --sidebar: 248px;
  color: var(--ink);
  background: var(--brand-light);
  font: 15px/1.5 var(--sans);
  font-synthesis: none;
}
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; min-width: 300px; }
button, input, textarea, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
a { color: inherit; }
img { max-width: 100%; }
p, h1, h2, h3, h4 { margin: 0; }
h1, h2 { font-family: var(--display); font-weight: 400; line-height: 1.08; }
h1 { font-size: clamp(2.25rem, 4.4vw, 3.65rem); letter-spacing: -.037em; }
h2 { font-size: clamp(1.65rem, 2.9vw, 2.25rem); letter-spacing: -.027em; }
h3 { font-size: 1.01rem; font-weight: 650; line-height: 1.35; }
small { color: var(--muted); }
:focus-visible { outline: 3px solid var(--brand-accent); outline-offset: 3px; }
[hidden] { display: none !important; }
.skip { position: fixed; z-index: 40; top: 8px; left: 8px; transform: translateY(-180%); background: white; padding: 10px 16px; }
.skip:focus { transform: none; }
.app-shell { min-height: 100svh; }
.sidebar { width: var(--sidebar); position: fixed; inset: 0 auto 0 0; display: flex; flex-direction: column; background: var(--brand-dark); color: #f8f6ef; padding: 35px 20px 18px; z-index: 5; overflow-y: auto; }
.brand { padding: 1px 12px 28px; border-bottom: 1px solid #ffffff24; text-decoration: none; display: block; }
.brand img { display: block; width: 164px; height: 43px; object-fit: contain; object-position: left; }
.brand-name { color: #e5d6b9; font-size: .72rem; letter-spacing: .2em; text-transform: uppercase; margin: 10px 0 0; display: block; }
.side-nav { display: flex; flex-direction: column; gap: 5px; padding: 25px 0; }
.nav-link { color: #f2f0ebcc; border: 1px solid transparent; background: transparent; text-decoration: none; display: flex; align-items: center; gap: 12px; border-radius: 8px; padding: 11px 12px; font-weight: 500; min-height: 45px; }
.nav-link:hover { color: white; background: #ffffff0c; }
.nav-link[aria-current=page] { color: white; background: #ffffff12; border-color: #ffffff18; box-shadow: inset 2px 0 var(--brand-accent); }
.nav-link[aria-current=page] .icon { color: #e0c89b; }
.nav-badge { font-size: .72rem; margin-left: auto; min-width: 1.4rem; text-align: center; color: var(--brand-dark); background: #e4c98f; border-radius: 99px; font-weight: 700; padding: 1px 5px; }
.side-user { margin-top: auto; display: flex; align-items: center; gap: 11px; padding: 14px 7px 4px; border-top: 1px solid #ffffff24; min-width: 0; }
.side-user div:nth-child(2) { flex: 1; min-width: 0; }
.side-user strong, .side-user small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-user small { color: #ffffffa8; }
.avatar { width: 36px; height: 36px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 50%; background: #ffffff1f; color: #f0ddbd; font-weight: 650; font-size: .78rem; }
.workspace { margin-left: var(--sidebar); min-width: 0; }
.topbar { background: #fffdfaee; border-bottom: 1px solid var(--line); padding: 0 clamp(20px, 4vw, 53px); height: 70px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.crumb { font-size: .85rem; color: var(--muted); display: flex; align-items: center; gap: 10px; }
.crumb strong { color: var(--ink); font-weight: 600; }
.top-actions { display: flex; gap: 10px; align-items: center; }
.mobile-toggle { display: none !important; }
.content { max-width: 1370px; margin: auto; padding: 36px clamp(20px, 4vw, 53px) 70px; }
.page-head { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 27px; }
.page-head p { color: var(--muted); margin-top: 10px; max-width: 60ch; }
.head-actions, .actions { display: flex; align-items: center; flex-wrap: wrap; gap: 9px; }
.actions.end { justify-content: flex-end; }
.hero { position: relative; isolation: isolate; overflow: hidden; display: flex; align-items: end; gap: 20px; justify-content: space-between; padding: clamp(28px, 5.2vw, 55px); min-height: 238px; color: #fffdf8; background: var(--brand-dark); border-radius: 13px; margin-bottom: 23px; }
.hero::after, .hero::before { content: ""; position: absolute; z-index: -1; width: 370px; height: 370px; border-radius: 50%; border: 1px solid #e9c88d30; right: -85px; top: -102px; pointer-events: none; }
.hero::after { width: 306px; height: 306px; right: -56px; top: -69px; box-shadow: 0 0 0 31px #c9a7660b, 0 0 0 63px #c9a76607; }
.hero h1 { font-size: clamp(2.35rem, 4.75vw, 4.3rem); }
.hero p { margin-top: 12px; color: #f8f3e0ca; max-width: 53ch; }
.hero .overline { margin: 0 0 9px; color: #e5cfa4; }
.overline { color: var(--muted); font-size: .72rem; letter-spacing: .13em; text-transform: uppercase; font-weight: 700; }
.metric-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 15px; margin-bottom: 24px; }
.metric { display: flex; gap: 13px; align-items: start; min-width: 0; padding: 20px; background: var(--surface); border: 1px solid var(--line); border-radius: 11px; }
.metric-icon { flex: none; display: grid; place-items: center; width: 37px; height: 37px; border-radius: 8px; background: #f4ecde; color: #71582e; }
.metric strong { display: block; font: 400 2.03rem/1 var(--display); margin-bottom: 5px; }
.metric span { color: var(--muted); font-size: .87rem; }
.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 17px; align-items: start; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 11px; padding: clamp(16px, 3vw, 27px); min-width: 0; }
.panel + .panel { margin-top: 16px; }
.dashboard-grid > .panel + .panel { margin-top: 0; }
.panel-heading { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 17px; }
.panel-heading p { color: var(--muted); margin-top: 6px; }
.empty { min-height: 142px; border: 1px dashed #dcd5c7; border-radius: 9px; padding: 23px; display: grid; align-content: center; justify-items: start; gap: 7px; }
.empty p { color: var(--muted); max-width: 58ch; }
.empty .actions { margin-top: 7px; }
.empty.compact { min-height: 0; padding: 16px; }
.btn { appearance: none; display: inline-flex; align-items: center; justify-content: center; gap: 7px; text-align: center; font-weight: 620; border: 1px solid transparent; border-radius: 7px; padding: 9px 13px; min-height: 40px; text-decoration: none; line-height: 1.22; background: transparent; color: var(--ink); }
.btn:hover:not(:disabled) { background: #efe9df; }
.btn.primary { color: white; background: var(--brand-dark); border-color: var(--brand-dark); }
.btn.primary:hover:not(:disabled) { background: #304359; }
.btn.gold { color: #1f2833; background: #e0c797; border-color: #e0c797; }
.btn.gold:hover:not(:disabled) { background: #edd8ac; }
.btn.outline { border-color: #d9d2c5; }
.btn.danger { color: var(--danger); }
.btn.small { min-height: 34px; padding: 6px 9px; font-size: .84rem; }
.btn:disabled { cursor: not-allowed; opacity: .55; }
.icon { display: inline-block; flex: 0 0 auto; width: 18px; height: 18px; vertical-align: middle; }
.icon-button { position: relative; width: 37px; min-height: 37px; padding: 0; }
.side-user .icon-button { color: #f7f2e9; width: 32px; }
.side-user .icon-button:hover { background: #ffffff15; }
.badge-dot { position: absolute; top: 4px; right: 4px; width: 8px; height: 8px; border-radius: 50%; background: var(--danger); }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 275px), 1fr)); gap: 15px; }
.card { display: flex; flex-direction: column; gap: 12px; min-height: 185px; }
.card .actions { margin-top: auto; }
.card p { color: var(--muted); }
.card-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.pill { display: inline-flex; gap: 5px; align-items: center; max-width: 100%; font-size: .76rem; font-weight: 650; color: #4e565d; background: #eeece6; padding: 3px 8px; border-radius: 99px; line-height: 1.4; }
.pill.success { color: var(--success); background: var(--success-bg); }
.pill.danger { color: var(--danger); background: var(--danger-bg); }
.pill.warning { color: var(--warning); background: var(--warning-bg); }
.list { list-style: none; margin: 0; padding: 0; }
.list > li { display: flex; align-items: center; justify-content: space-between; gap: 12px; border-top: 1px solid var(--line); padding: 12px 0; }
.list > li:first-child { border-top: 0; padding-top: 1px; }
.list > li:last-child { padding-bottom: 0; }
.list > li p { color: var(--muted); font-size: .9rem; margin-top: 3px; }
.list > li .actions { flex-shrink: 0; }
.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; text-align: left; }
th, td { padding: 13px 11px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-size: .78rem; font-weight: 650; }
tr:last-child td { border-bottom: 0; }
.row-detail { display: block; color: var(--muted); font-size: .83rem; overflow-wrap: anywhere; }
.form { display: grid; gap: 16px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px; }
.field { display: grid; gap: 5px; align-content: start; min-width: 0; color: var(--ink); font-weight: 620; font-size: .87rem; }
.field small, .hint { font-weight: 400; font-size: .83rem; color: var(--muted); }
input:not([type=checkbox], [type=radio]), textarea, select { width: 100%; min-width: 0; padding: 9px 11px; min-height: 41px; color: var(--ink); background: #fffefa; border: 1px solid #d6d1c7; border-radius: 6px; font-weight: 400; }
input[type=checkbox], input[type=radio] { accent-color: var(--brand-dark); min-width: 16px; min-height: 16px; }
textarea { resize: vertical; }
.question { display: grid; gap: 11px; border: 1px solid var(--line); background: #faf7f0; padding: 14px; border-radius: 8px; }
.question-list { display: grid; gap: 10px; }
.question-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.option-edit, .choice { display: flex; align-items: center; gap: 10px; }
.option-edit .field { flex: 1; }
.choice { cursor: pointer; border: 1px solid var(--line); border-radius: 8px; padding: 12px; margin: 7px 0; }
.choice:has(:checked) { border-color: var(--brand-accent); background: #f8f1e4; }
.choice:hover { background: #f9f4eb; }
.choice input { margin: 0; }
.quiz { max-width: 760px; margin: auto; }
.quiz h2 { margin: 9px 0 15px; }
.progress { width: 100%; height: 5px; appearance: none; border: 0; border-radius: 99px; background: #ebe4d7; }
.progress::-webkit-progress-bar { background: #ebe4d7; border-radius: 99px; }
.progress::-webkit-progress-value { background: #ae905b; border-radius: 99px; }
.progress::-moz-progress-bar { background: #ae905b; border-radius: 99px; }
.step-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.step { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; border: 1px solid var(--line); border-radius: 9px; padding: 15px; }
.step-content { min-width: 0; }
.step .actions { margin-top: 10px; }
.step p { color: var(--muted); font-size: .9rem; margin-top: 5px; }
.step .pill { flex: 0 0 auto; }
.prose { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.72; color: #39444c; max-width: 78ch; }
.prose + .actions { margin-top: 17px; }
.stack { display: grid; gap: 11px; }
.stack > .panel { margin-top: 0; }
.alert { border: 1px solid #e8c9c7; color: var(--danger); background: var(--danger-bg); padding: 10px 12px; border-radius: 7px; overflow-wrap: anywhere; }
.notice { border: 1px solid #e7d8bb; color: #5d481e; background: #fbf3e3; padding: 12px; border-radius: 7px; }
.auth-shell { display: grid; grid-template-columns: 1fr 1fr; min-height: 100svh; }
.auth-brand { background: var(--brand-dark); color: #fffdf8; padding: clamp(34px, 7vw, 110px); display: grid; align-content: center; gap: 20px; }
.auth-brand img { width: 220px; }
.auth-brand p { color: #f3e7d1ca; max-width: 37ch; }
.auth-content { display: grid; align-content: center; justify-content: center; padding: 30px; }
.auth-content .panel { width: min(410px, 100%); }
.loading { min-height: 100svh; display: grid; place-content: center; justify-items: center; gap: 10px; color: var(--muted); }
.loading img { width: 170px; }
.toast { position: fixed; z-index: 50; bottom: 18px; right: 20px; background: var(--brand-dark); color: white; border-radius: 9px; padding: 12px 16px; width: max-content; max-width: calc(100% - 40px); box-shadow: 0 8px 26px #15202b29; }
.toast.error { background: #753332; }
.presentation { min-height: 70svh; padding: clamp(22px, 6vw, 75px); border-radius: 14px; background: var(--brand-dark); color: #fffdf8; display: flex; flex-direction: column; justify-content: space-between; gap: 24px; }
.presentation img { width: 125px; align-self: flex-start; }
.presentation h1 { max-width: 28ch; }
.presentation .prose { margin-top: 20px; color: #f8f1e1; font-size: clamp(1rem, 2vw, 1.5rem); }
.presentation .btn.outline { color: white; border-color: #ffffff4a; }
.presentation .btn.outline:hover:not(:disabled) { background: #ffffff18; }
.presentation small { color: #fffdf8bd; }
.selection-row { display: flex; gap: 8px; align-items: center; justify-content: space-between; }
.selection-row > label { display: flex; gap: 8px; align-items: center; }
.link-box { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.mobile-scrim { display: none; }
.import-panel { margin-bottom: 15px; }
.import-panel summary { cursor: pointer; font-weight: 650; }
.import-panel form { margin-top: 14px; }
.chain-preview { margin: 0; padding-left: 21px; color: var(--muted); }
.quiz-options { margin: 0; border: 0; padding: 0; min-width: 0; }
.quiz-options legend { margin-bottom: 6px; padding: 0; }
.dialog { width: min(470px, calc(100% - 36px)); max-height: calc(100% - 40px); overflow: auto; }
.dialog::backdrop { background: #14223279; }
:fullscreen .presentation { position: fixed; inset: 0; z-index: 20; border-radius: 0; }
@media (max-width: 1000px) {
  :root { --sidebar: 215px; }
  .metric { padding: 14px; }
}
@media (max-width: 750px) {
  .sidebar { transform: translateX(-100%); transition: transform .18s ease; }
  .sidebar.open { transform: translateX(0); }
  .mobile-scrim.open { display: block; position: fixed; inset: 0; border: 0; background: #13213079; z-index: 4; }
  .workspace { margin-left: 0; }
  .mobile-toggle { display: inline-flex !important; }
  .topbar { height: 57px; }
  .content { padding-top: 23px; }
  .dashboard-grid { grid-template-columns: 1fr; }
}
@media (max-width: 540px) {
  .top-actions .label-desktop, .crumb > span { display: none; }
  .hero, .page-head { align-items: start; flex-direction: column; }
  .hero { min-height: 0; }
  .metric-grid { gap: 6px; }
  .metric { display: block; padding: 9px; }
  .metric-icon { display: none; }
  .metric strong { font-size: 1.6rem; }
  .metric span { font-size: .73rem; }
  .form-grid, .auth-shell { grid-template-columns: 1fr; }
  .auth-shell { align-content: start; }
  .auth-brand { padding: 25px; gap: 12px; }
  .auth-brand img { width: 145px; }
  .auth-content { padding: 18px; }
  .list > li { flex-wrap: wrap; }
  .list > li .actions { flex-shrink: 1; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
