:root {
  color-scheme: light dark;
  --bg: #f4f1ea;
  --panel: #fffaf1;
  --panel-2: #ffffff;
  --text: #241f1a;
  --muted: #756b61;
  --line: #ded2c2;
  --brand: #8f4a27;
  --brand-dark: #5f2f1a;
  --danger: #b23131;
  --success: #287a4b;
  --shadow: 0 18px 48px rgba(44, 30, 18, .12);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #191613;
    --panel: #211c18;
    --panel-2: #2a241f;
    --text: #f4ece1;
    --muted: #b7aa9d;
    --line: #41362e;
    --brand: #d28a54;
    --brand-dark: #f0b27c;
    --shadow: 0 18px 48px rgba(0, 0, 0, .28);
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
body { margin: 0; color: var(--text); background: radial-gradient(circle at top left, rgba(143, 74, 39, .16), transparent 36rem), var(--bg); }
a { color: var(--brand-dark); text-decoration: none; }
a:hover { text-decoration: underline; }
.app { min-height: 100vh; display: grid; grid-template-columns: 280px 1fr; }
.mobile-menu-toggle, .sidebar-backdrop { display: none; }
.sidebar { position: sticky; top: 0; height: 100vh; overflow-y: auto; padding: 24px 18px; border-right: 1px solid var(--line); background: rgba(255,255,255,.24); backdrop-filter: blur(10px); }
.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 26px; font-weight: 800; font-size: 1.15rem; }
.brand img { width: 34px; height: 34px; object-fit: contain; border-radius: 10px; }
.nav { display: grid; gap: 6px; }
.nav a, .nav button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 12px; border: 0; border-radius: 12px; color: var(--text); background: transparent; font: inherit; cursor: pointer; text-align: left; }
.nav a:hover, .nav button:hover, .nav .active { background: var(--panel); text-decoration: none; box-shadow: var(--shadow); }
.context-nav { gap: 14px; }
.context-heading { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: center; margin-bottom: 2px; padding: 14px; border: 1px solid var(--line); border-radius: 16px; background: color-mix(in srgb, var(--panel) 72%, transparent); }
.context-heading-copy { display: grid; min-width: 0; gap: 4px; }
.context-heading-copy > span, .context-section-label { color: var(--muted); font-size: .68rem; font-weight: 850; letter-spacing: .1em; text-transform: uppercase; }
.context-heading strong { overflow: hidden; font-size: 1.02rem; line-height: 1.25; text-overflow: ellipsis; }
.context-heading .context-heading-settings { display: inline-flex; width: 34px; height: 34px; padding: 0; justify-content: center; color: var(--muted); border-radius: 50%; }
.context-heading .context-heading-settings:hover { color: var(--text); }
.context-nav-section { display: grid; gap: 6px; }
.context-heading { order: 0; }
.context-manage-section { order: 1; }
.context-content-section { order: 2; }
.context-world-section { order: 3; }
.context-session-section { order: 4; }
.context-section-label { padding: 0 10px; }
.context-nav a.active, .context-nav button.active { position: relative; background: color-mix(in srgb, var(--brand) 13%, var(--panel)); box-shadow: none; font-weight: 800; }
.context-nav a.active::before, .context-nav button.active::before { content: ""; position: absolute; inset: 8px auto 8px 3px; width: 4px; border-radius: 999px; background: var(--brand); }
.context-overview-link { font-weight: 750; }
.context-tree { display: grid; gap: 4px; }
.context-tree-group { min-width: 0; }
.context-folder { display: grid; grid-template-columns: 12px 18px minmax(0, 1fr) auto; gap: 7px; align-items: center; min-height: 34px; padding: 7px 8px; border-radius: 10px; color: var(--muted); font-size: .84rem; font-weight: 800; cursor: pointer; list-style: none; }
.context-folder::-webkit-details-marker { display: none; }
.context-folder:hover { background: color-mix(in srgb, var(--panel) 62%, transparent); color: var(--text); }
.context-folder-chevron::before { content: "›"; display: block; font-size: 1.1rem; line-height: 1; transform-origin: center; transition: transform .16s ease; }
.context-folder-group[open] > .context-folder .context-folder-chevron::before { transform: rotate(90deg); }
.context-folder-icon::before { content: "📂"; }
.context-folder-name, .context-item-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.context-folder-count { min-width: 22px; padding: 2px 6px; border-radius: 999px; background: color-mix(in srgb, var(--line) 70%, transparent); color: var(--muted); font-size: .68rem; text-align: center; }
.context-tree-children { display: grid; gap: 2px; margin: 1px 0 4px 13px; padding-left: 9px; border-left: 1px solid color-mix(in srgb, var(--line) 75%, transparent); }
.context-tree-children .context-tree-group { margin-left: 1px; }
.nav .context-tree-link { display: grid; grid-template-columns: 18px minmax(0, 1fr); gap: 8px; min-height: 34px; padding: 7px 9px; font-size: .88rem; }
.context-item-icon { position: relative; display: inline-block; width: 17px; height: 17px; flex: 0 0 17px; color: var(--muted); }
.context-item-icon-overview::before { content: "🌐"; }
.context-item-icon-page::before { content: "📃"; }
.context-item-icon-map::before { content: "🗺️"; }
.context-tree-link.active .context-item-icon { color: var(--brand); }
.context-tree-empty { display: block; padding: 7px 10px; color: var(--muted); font-size: .78rem; font-style: italic; }
.context-actions { display: grid; gap: 3px; }
.context-actions a, .context-actions button { min-height: 36px; padding: 8px 10px; color: var(--muted); font-size: .86rem; }
.context-actions a:hover, .context-actions button:hover { color: var(--text); }
.context-create-actions { grid-template-columns: repeat(3, 1fr); gap: 7px; padding: 0 8px; }
.context-create-actions button { width: 100%; min-height: 40px; padding: 0; border: 1px solid var(--line); background: color-mix(in srgb, var(--panel) 70%, transparent); color: var(--muted); }
.context-create-actions button:hover { background: var(--panel); color: var(--brand); box-shadow: none; }
.context-action-icon { display: inline-flex; justify-content: center; align-items: center; width: 18px; height: 18px; font-weight: 900; }
.context-action-icon-media::before { content: "📀"; }
.context-action-icon-settings::before { content: "⚙️"; }
.context-action-icon-folder-add::before { content: "＋"; font-size: 1.25rem; }
.context-action-icon-folder-add::after { content: "📂"; margin-left: -4px; font-size: .85rem; }
.context-action-icon-element-add::before { content: "＋"; font-size: 1.25rem; }
.context-action-icon-element-add::after { content: "📃"; margin-left: -4px; font-size: .85rem; }
.context-action-icon-media-add::before { content: "＋"; font-size: 1.25rem; }
.context-action-icon-media-add::after { content: "📀"; margin-left: -4px; font-size: .8rem; }
.context-action-icon-audio::before { content: "🎛️"; }
.context-action-icon-audio-2::before { content: "🎵️"; }
.context-action-icon-screen::before { content: "📺"; }
.context-action-icon-world::before { content: "🌍"; }
.context-world-section { padding-top: 12px; border-top: 1px solid var(--line); }
.context-associated-world { min-width: 0; }
.context-associated-world-summary { display: grid; grid-template-columns: 12px 20px minmax(0, 1fr); gap: 8px; align-items: center; min-height: 40px; padding: 8px 10px; border-radius: 11px; color: var(--text); font-size: .88rem; font-weight: 800; cursor: pointer; list-style: none; }
.context-associated-world-summary::-webkit-details-marker { display: none; }
.context-associated-world-summary:hover { background: var(--panel); }
.context-associated-world[open] > .context-associated-world-summary .context-folder-chevron::before { transform: rotate(90deg); }
.context-associated-world-content { display: grid; gap: 4px; margin-top: 4px; padding: 8px 0 0 10px; border-left: 2px solid color-mix(in srgb, var(--brand) 45%, var(--line)); }
.context-external { margin-left: auto; color: var(--muted); font-size: .78rem; }
.sidebar-section { margin-top: 24px; padding-top: 18px; border-top: 1px solid var(--line); }
.user-card { display: flex; gap: 10px; align-items: center; padding: 8px; margin: -8px; border-radius: 12px; font-size: .92rem; color: var(--muted); }
.user-card:hover { background: var(--panel); color: var(--text); text-decoration: none; box-shadow: var(--shadow); }
.avatar { width: 38px; height: 38px; border-radius: 50%; object-fit: cover; background: var(--line); }
.main { padding: 32px; max-width: 1440px; width: 100%; }
.topbar { display: flex; justify-content: space-between; gap: 18px; align-items: flex-start; margin-bottom: 24px; }
h1 { margin: 0 0 8px; font-size: clamp(1.8rem, 4vw, 3rem); letter-spacing: -.04em; }
h2 { margin: 0 0 14px; font-size: 1.25rem; }
h3 { margin: 0 0 10px; font-size: 1rem; }
.muted { color: var(--muted); }
.grid { display: grid; gap: 18px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 22px; box-shadow: var(--shadow); overflow: hidden; }
.card.pad { padding: 20px; }
.cover { width: 100%; aspect-ratio: 16 / 7; object-fit: cover; display: block; background: var(--line); }
.card-body { padding: 18px; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.button, button, input[type=submit] { display: inline-flex; justify-content: center; align-items: center; gap: 8px; border: 0; border-radius: 999px; padding: 10px 16px; background: var(--brand); color: #fff; font-weight: 700; cursor: pointer; }
.button.secondary, button.secondary { background: var(--panel-2); color: var(--text); border: 1px solid var(--line); }
.button.danger, button.danger { background: var(--danger); }
.button.small, button.small { padding: 7px 11px; font-size: .88rem; }
.field { display: grid; gap: 7px; margin-bottom: 14px; }
.field label { font-weight: 700; }
input, select, textarea { width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel-2); color: var(--text); font: inherit; }
textarea { min-height: 150px; resize: vertical; }
.flash { padding: 12px 14px; border-radius: 14px; margin: 0 0 12px; background: var(--panel-2); border: 1px solid var(--line); }
.flash.error { border-color: rgba(178,49,49,.45); color: var(--danger); }
.flash.success { border-color: rgba(40,122,75,.45); color: var(--success); }
.split { display: grid; grid-template-columns: 300px 1fr; gap: 20px; align-items: start; }
.tree ul { list-style: none; margin: 0; padding-left: 18px; }
.tree > ul { padding-left: 0; }
.tree li { margin: 7px 0; }
.tree .folder { font-weight: 800; color: var(--muted); }
.editor-wrap { background: var(--panel-2); border-radius: 18px; border: 1px solid var(--line); padding: 16px; min-height: 420px; }
.editor-toolbar { justify-content: space-between; margin-bottom: 12px; }
.editor-wrap .note-editor.note-frame { border: 0; background: transparent; color: var(--text); }
.editor-wrap .note-editable { height: auto !important; min-height: 360px; overflow: visible; background: var(--panel-2) !important; color: var(--text); }
.editor-wrap.editor-readonly { background: transparent; }
.editor-readonly .note-editor.note-frame, .editor-readonly .note-editable { background: transparent !important; }
.editor-readonly .note-toolbar, .editor-readonly .note-statusbar { display: none !important; }
.checkbox-field { display: flex; width: fit-content; align-items: center; gap: 9px; margin-bottom: 10px; font-weight: 700; }
.checkbox-field input { width: auto; }
.choice-card { display: flex; align-items: flex-start; gap: 11px; margin: 10px 0; padding: 13px; border: 1px solid var(--line); border-radius: 14px; background: var(--panel-2); cursor: pointer; }
.choice-card:hover { border-color: var(--brand); }
.choice-card input { width: auto; margin-top: 3px; }
.choice-card span { display: grid; gap: 3px; }
.choice-card small { color: var(--muted); line-height: 1.4; }
.choice-card.danger-choice { border-color: color-mix(in srgb, var(--danger) 35%, var(--line)); }
.ai-assistant { margin-top: 18px; }
.ai-submit-row { display: block; margin-top: 14px; }
.ai-assistant [data-ai-output] { min-height: 0; margin-top: 12px; white-space: pre-wrap; }
.ai-assistant [data-ai-output]:empty { display: none; }
.editor-html, .note-editable {
  font-size: 1rem;
  line-height: 1.75;
  overflow-wrap: break-word;
}
.editor-html > :first-child, .note-editable > :first-child { margin-top: 0; }
.editor-html > :last-child, .note-editable > :last-child { margin-bottom: 0; }
.editor-html p, .note-editable p { max-width: 78ch; margin: 0 0 1.15em; }
.editor-html ul, .editor-html ol, .note-editable ul, .note-editable ol { max-width: 78ch; margin: 0 0 1.25em; padding-left: 1.6em; }
.editor-html li, .note-editable li { margin-bottom: .4em; padding-left: .2em; }
.editor-html h1, .editor-html h2, .editor-html h3, .editor-html h4, .editor-html h5, .editor-html h6,
.note-editable h1, .note-editable h2, .note-editable h3, .note-editable h4, .note-editable h5, .note-editable h6 {
  max-width: 36ch;
  color: var(--text);
  font-weight: 800;
  text-wrap: balance;
}
.editor-html h1, .note-editable h1 {
  margin: 0 0 .75em;
  padding-bottom: .28em;
  border-bottom: 2px solid color-mix(in srgb, var(--brand) 42%, var(--line));
  color: var(--brand-dark);
  font-size: clamp(2.35rem, 5vw, 3.4rem);
  line-height: 1.08;
  letter-spacing: -.045em;
}
.editor-html h2, .note-editable h2 {
  margin: 1.65em 0 .65em;
  padding-left: .55em;
  border-left: .18em solid var(--brand);
  color: var(--brand-dark);
  font-size: clamp(1.9rem, 3.5vw, 2.4rem);
  line-height: 1.16;
  letter-spacing: -.03em;
}
.editor-html h3, .note-editable h3 {
  margin: 1.55em 0 .6em;
  color: color-mix(in srgb, var(--brand-dark) 82%, var(--text));
  font-size: clamp(1.6rem, 3vw, 1.9rem);
  line-height: 1.22;
  letter-spacing: -.02em;
}
.editor-html h4, .note-editable h4 {
  margin: 1.45em 0 .55em;
  font-size: 1.4rem;
  line-height: 1.3;
}
.editor-html h5, .note-editable h5 {
  margin: 1.4em 0 .5em;
  color: color-mix(in srgb, var(--brand) 78%, var(--text));
  font-size: 1.2rem;
  line-height: 1.35;
  letter-spacing: .015em;
}
.editor-html h6, .note-editable h6 {
  margin: 1.35em 0 .5em;
  color: var(--muted);
  font-size: 1.075rem;
  line-height: 1.4;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.editor-html blockquote, .note-editable blockquote {
  max-width: 74ch;
  margin: 1.5em 0;
  padding: .15em 0 .15em 1.15em;
  border-left: 3px solid color-mix(in srgb, var(--brand) 55%, var(--line));
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.7;
}
.editor-html img, .note-editable img { max-width: 100%; height: auto; border-radius: 10px; }
.editor-html .media-action, .note-editable .media-action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  margin: 2px 3px;
  padding: 6px 10px;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--brand) 45%, var(--line));
  border-radius: 999px;
  background: color-mix(in srgb, var(--brand) 12%, var(--panel-2));
  color: var(--text);
  font-size: .88rem;
  font-weight: 800;
  line-height: 1.2;
  text-decoration: none;
  text-overflow: ellipsis;
  vertical-align: middle;
  white-space: nowrap;
  cursor: pointer;
  transition: border-color .18s ease, background .18s ease, transform .18s ease;
}
.editor-html .media-action:hover, .note-editable .media-action:hover { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 20%, var(--panel-2)); text-decoration: none; }
.editor-html .media-action-audio, .note-editable .media-action-audio { border-color: #8a6dc7; background: color-mix(in srgb, #8a6dc7 16%, var(--panel-2)); }
.editor-html .media-action-image, .note-editable .media-action-image { border-color: #3b8798; background: color-mix(in srgb, #3b8798 16%, var(--panel-2)); }
.editor-html .media-action.is-sent, .note-editable .media-action.is-sent { border-color: var(--success); background: color-mix(in srgb, var(--success) 20%, var(--panel-2)); transform: translateY(-1px); }
.map-toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.map-zoom-controls { display: inline-flex; align-items: center; gap: 8px; }
.map-touch-help { display: none; margin: -3px 0 10px; font-size: .82rem; }
.map-viewport { position: relative; height: min(68vh, 760px); overflow: hidden; overscroll-behavior: contain; border-radius: 18px; border: 1px solid var(--line); background: #111; cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.map-viewport.is-dragging { cursor: grabbing; }
.map-viewport.is-pinching { cursor: zoom-in; }
.map-viewport.is-adding-pin { cursor: crosshair; }
.map-canvas { position: relative; width: 100%; transform-origin: 0 0; will-change: transform; }
.map-canvas img { width: 100%; display: block; user-select: none; -webkit-user-drag: none; }
.pin { position: absolute; z-index: 1; width: 22px; height: 22px; transform: translate(-50%, -100%); border-radius: 50% 50% 50% 0; rotate: -45deg; background: currentColor; border: 2px solid rgba(0,0,0,.25); cursor: pointer; }
.pin span { position: absolute; left: 16px; top: -12px; rotate: 45deg; white-space: nowrap; background: rgba(0,0,0,.72); color: #fff; padding: 4px 7px; border-radius: 8px; font-size: .78rem; opacity: 0; pointer-events: none; }
.pin:hover span { opacity: 1; }
.pin-delete { display: none; position: absolute; transform: translate(-50%, -100%); z-index: 2; width: 26px; height: 26px; padding: 0; border-radius: 50%; background: var(--danger); color: #fff; font-size: .9rem; }
.map-viewport.is-deleting-pin .pin { opacity: .3; pointer-events: none; }
.map-viewport.is-deleting-pin .pin-delete { display: inline-flex; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; border-bottom: 1px solid var(--line); padding: 10px; vertical-align: top; }
.empty { padding: 26px; border: 1px dashed var(--line); border-radius: 18px; color: var(--muted); text-align: center; }
.modalish { margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--line); }
.git-facts { display: grid; gap: 9px; margin-bottom: 16px; }
.git-facts p { display: grid; gap: 4px; margin: 0; }
.git-facts span { color: var(--muted); font-size: .76rem; font-weight: 800; text-transform: uppercase; }
.git-output { max-height: 300px; margin: 0; padding: 13px; overflow: auto; border: 1px solid var(--line); border-radius: 13px; background: var(--panel-2); color: var(--text); font: .82rem/1.5 ui-monospace, SFMono-Regular, Consolas, monospace; white-space: pre-wrap; }
.git-remote-title { margin-top: 20px; }
.settings-item { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 0; border-top: 1px solid var(--line); }
.settings-item:first-of-type { border-top: 0; }
.scenario-order-card { grid-column: 1 / -1; }
.scenario-order-layout { display: grid; grid-template-columns: minmax(210px, 280px) minmax(0, 1fr); gap: 22px; }
.scenario-folder-browser { padding-right: 18px; border-right: 1px solid var(--line); }
.scenario-folder-link { display: flex; align-items: center; gap: 8px; min-height: 38px; margin: 3px 0; padding: 8px 10px 8px calc(10px + var(--folder-depth, 0) * 18px); border-radius: 10px; color: var(--text); }
.scenario-folder-link:hover { background: var(--panel-2); text-decoration: none; }
.scenario-folder-link.active { background: var(--brand); color: #fff; font-weight: 800; }
.scenario-order-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; }
.scenario-order-heading h2 { margin-bottom: 0; }
.eyebrow { margin: 0 0 5px; color: var(--muted); font-size: .72rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.scenario-order-list { display: grid; gap: 8px; margin: 18px 0; padding: 0; list-style: none; }
.scenario-order-item { display: grid; grid-template-columns: auto auto minmax(0, 1fr) auto auto; gap: 10px; align-items: center; min-height: 54px; padding: 9px 10px; border: 1px solid var(--line); border-radius: 13px; background: var(--panel-2); }
.scenario-order-item[draggable="true"] { cursor: grab; }
.scenario-order-item.is-dragging { opacity: .45; }
.scenario-order-item.drag-over { border-color: var(--brand); box-shadow: inset 0 2px 0 var(--brand); }
.drag-handle { color: var(--muted); font-weight: 900; letter-spacing: -3px; }
.order-item-icon { color: var(--brand); }
.order-item-type { color: var(--muted); font-size: .78rem; font-weight: 700; text-transform: uppercase; }
.order-item-actions { display: flex; gap: 5px; }
.order-item-actions button { width: 34px; height: 34px; padding: 0; }
.inline-form { display: inline; }
.modal { width: min(680px, calc(100vw - 32px)); max-height: calc(100vh - 48px); padding: 0; color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: 22px; box-shadow: 0 30px 90px rgba(0,0,0,.35); }
.modal::backdrop { background: rgba(12, 9, 7, .7); backdrop-filter: blur(5px); }
.modal-content { padding: 22px; }
.modal-header { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 18px; }
.modal-header h2 { margin: 0; }
.modal-close { width: 38px; height: 38px; padding: 0; border-radius: 50%; font-size: 1.3rem; }
.modal-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
.media-library-preview { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line); }
.upload-quota { display: grid; gap: 7px; margin-bottom: 18px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 13px; background: var(--panel-2); }
.upload-quota-heading { display: flex; justify-content: space-between; gap: 12px; }
.upload-quota-heading span, .upload-quota small { color: var(--muted); font-size: .8rem; }
.upload-quota progress { width: 100%; height: 10px; overflow: hidden; border: 0; border-radius: 999px; accent-color: var(--brand); }
.upload-quota progress::-webkit-progress-bar { background: var(--line); border-radius: 999px; }
.upload-quota progress::-webkit-progress-value { background: var(--brand); border-radius: 999px; }
.upload-quota progress::-moz-progress-bar { background: var(--brand); border-radius: 999px; }
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 12px; }
.media-card { margin: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 14px; background: var(--panel-2); }
.media-card img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; }
.media-card figcaption { padding: 8px 10px; color: var(--muted); font-size: .82rem; }
.media-card-actions { padding: 0 9px 9px; }
.media-card-actions button { width: 100%; padding: 7px 9px; font-size: .76rem; }
.audio-library-list { display: grid; gap: 9px; }
.audio-library-item { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 11px 12px; border: 1px solid var(--line); border-radius: 13px; background: var(--panel-2); }
.audio-library-details { display: grid; gap: 3px; min-width: 0; }
.audio-library-details strong { overflow-wrap: anywhere; }
.audio-library-details span { color: var(--muted); font-size: .78rem; }
.audio-library-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 7px; }
.audio-library-actions form { margin: 0; }
.cover-choice-current { display: block; width: min(100%, 360px); aspect-ratio: 16 / 9; margin-bottom: 14px; object-fit: cover; border: 1px solid var(--line); border-radius: 14px; background: var(--panel-2); }
.cover-picker-modal { width: min(880px, calc(100vw - 32px)); }
.cover-picker-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; max-height: min(62vh, 620px); overflow-y: auto; padding: 3px; }
.cover-picker-item { position: relative; display: grid; overflow: hidden; border: 2px solid transparent; border-radius: 14px; background: var(--panel-2); cursor: pointer; }
.cover-picker-item:has(input:checked) { border-color: var(--brand); box-shadow: 0 0 0 2px color-mix(in srgb, var(--brand) 25%, transparent); }
.cover-picker-item input { position: absolute; top: 9px; right: 9px; z-index: 1; width: 18px; height: 18px; accent-color: var(--brand); }
.cover-picker-item img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; }
.cover-picker-item span { padding: 9px 10px; font-size: .82rem; font-weight: 700; }
.profile-media-modal { width: min(960px, calc(100vw - 32px)); }
.profile-media-grid { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
.profile-media-details { display: grid; gap: 4px; padding: 9px 10px; }
.profile-media-details strong { overflow-wrap: anywhere; }
.profile-media-details span { color: var(--muted); font-size: .78rem; }
.media-picker-empty { grid-column: 1 / -1; margin: 0; color: var(--muted); }
.media-picker-grid { max-height: min(65vh, 620px); overflow-y: auto; }
.media-picker-item { display: grid; padding: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 14px; background: var(--panel-2); color: var(--text); text-align: left; }
.media-picker-item:hover { border-color: var(--brand); }
.media-picker-item img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; }
.media-picker-item span { padding: 9px 10px; font-size: .82rem; }
.media-picker-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(92px, 1fr)); gap: 7px; padding: 0 9px 9px; }
.media-picker-actions button { min-width: 0; padding: 7px 9px; font-size: .76rem; }
.media-action-image-choice { cursor: pointer; }
.media-action-editor-footer { display: flex; justify-content: flex-start; margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); }
.media-feedback { position: fixed; right: 22px; bottom: 22px; z-index: 300; max-width: min(360px, calc(100vw - 32px)); padding: 11px 14px; border: 1px solid rgba(40,122,75,.5); border-radius: 13px; background: var(--panel); color: var(--success); box-shadow: var(--shadow); font-weight: 700; }
.media-feedback.is-error { border-color: rgba(178,49,49,.5); color: var(--danger); }
.tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; border-bottom: 1px solid var(--line); padding-bottom: 10px; }
.tab-button[aria-selected="true"] { background: var(--brand); color: #fff; border-color: transparent; }
.tab-panel[hidden] { display: none; }
.link-picker-status { min-height: 1.3em; margin: -3px 0 12px; color: var(--muted); font-size: .84rem; }
.link-picker-status.is-error { color: var(--danger); }
.link-picker-modal select { max-height: 280px; }
.editor-html .citation, .editor-html .mj, .editor-html .mj-secret, .editor-html .regles,
.note-editable .citation, .note-editable .mj, .note-editable .mj-secret, .note-editable .regles { margin: 18px 0; padding: 16px 18px; border: 1px solid var(--line); border-radius: 14px; }
.editor-html .citation, .note-editable .citation { background: #e9eef2; color: #4b5d68; font-style: italic; border-color: #a9b8c1; }
.editor-html .mj, .note-editable .mj { background: #e6f2e6; color: #315b37; border-color: #94b99a; }
.editor-html .mj-secret, .note-editable .mj-secret { background: #41414b; color: #fff; border-color: #6e6e7c; }
.editor-html .regles, .note-editable .regles { background: #f3e8d9; color: #3c2b18; border-color: #c9aa82; }
.editor-html .citation::before, .editor-html .mj::before, .editor-html .mj-secret::before, .editor-html .regles::before,
.note-editable .citation::before, .note-editable .mj::before, .note-editable .mj-secret::before, .note-editable .regles::before { display: block; margin-bottom: 8px; font-size: .75rem; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; opacity: .75; }
.editor-html .citation::before, .note-editable .citation::before { content: "Citation"; }
.editor-html .mj::before, .note-editable .mj::before { content: "Maître du jeu"; }
.editor-html .mj-secret::before, .note-editable .mj-secret::before { content: "MJ secret"; }
.editor-html .regles::before, .note-editable .regles::before { content: "Règles"; }
.editor-html .citation a, .editor-html .mj a, .editor-html .mj-secret a, .editor-html .regles a,
.note-editable .citation a, .note-editable .mj a, .note-editable .mj-secret a, .note-editable .regles a { color: inherit; text-decoration: underline; }
.layout_cadre { margin: 18px 0; padding: 16px; border-left: 3px solid var(--muted); border-radius: 8px; }
.cdx-text-variant--citation .layout_cadre { background: #e9eef2; color: #4b5d68; border: 1px solid #a9b8c1; font-style: italic; }
.cdx-text-variant--mj_simple .layout_cadre, .cdx-text-variant--conseil .layout_cadre { background: #e6f2e6; color: #315b37; border: 1px solid #94b99a; }
.cdx-text-variant--mj_secret .layout_cadre { background: #41414b; color: #fff; border: 1px solid #6e6e7c; }
.cdx-text-variant--regles .layout_cadre { background: #f3e8d9; color: #3c2b18; border: 1px solid #c9aa82; }

@media (prefers-color-scheme: dark) {
  .editor-html .citation, .note-editable .citation { background: #122633; color: #b6c5cc; }
  .editor-html .mj, .note-editable .mj { background: #15351b; color: #b8d7bc; }
  .editor-html .regles, .note-editable .regles { background: #302318; color: #f3e8d9; }
}

@media (max-width: 900px) {
  .app { display: block; }
  .mobile-menu-toggle { display: inline-flex; position: fixed; top: 14px; right: 14px; z-index: 110; width: 46px; height: 46px; padding: 0; border-radius: 14px; box-shadow: var(--shadow); }
  .mobile-menu-icon, .mobile-menu-icon::before, .mobile-menu-icon::after { display: block; width: 21px; height: 2px; border-radius: 99px; background: currentColor; content: ""; transition: transform .2s ease, opacity .2s ease; }
  .mobile-menu-icon { position: relative; }
  .mobile-menu-icon::before { position: absolute; top: -7px; }
  .mobile-menu-icon::after { position: absolute; top: 7px; }
  .sidebar-open .mobile-menu-icon { background: transparent; }
  .sidebar-open .mobile-menu-icon::before { transform: translateY(7px) rotate(45deg); }
  .sidebar-open .mobile-menu-icon::after { transform: translateY(-7px) rotate(-45deg); }
  .sidebar { position: fixed; inset: 0 auto 0 0; z-index: 100; width: min(86vw, 320px); height: 100vh; padding-top: 24px; overflow-y: auto; background: var(--bg); transform: translateX(-105%); transition: transform .22s ease; box-shadow: var(--shadow); }
  .sidebar-open .sidebar { transform: translateX(0); }
  .sidebar-backdrop { position: fixed; inset: 0; z-index: 90; background: rgba(12, 9, 7, .62); backdrop-filter: blur(3px); }
  .sidebar-open .sidebar-backdrop { display: block; }
  body.sidebar-open { overflow: hidden; }
  .main { padding: 76px 20px 20px; }
  .map-section { padding: 14px; }
  .map-section .editor-toolbar { display: grid; gap: 12px; }
  .map-toolbar { width: 100%; }
  .map-zoom-controls { width: 100%; justify-content: space-between; padding: 6px; border: 1px solid var(--line); border-radius: 16px; background: var(--panel-2); }
  .map-zoom-controls button { min-width: 44px; min-height: 44px; padding: 0 13px; font-size: 1rem; }
  .map-touch-help { display: block; }
  .map-viewport { height: min(70vh, 620px); min-height: 420px; }
  .grid.two, .grid.three, .split { grid-template-columns: 1fr; }
  .scenario-order-layout { grid-template-columns: 1fr; }
  .scenario-folder-browser { padding-right: 0; padding-bottom: 18px; border-right: 0; border-bottom: 1px solid var(--line); }
  .scenario-order-item { grid-template-columns: auto auto minmax(0, 1fr) auto; }
  .order-item-type { display: none; }
  .upload-quota-heading, .audio-library-item { align-items: stretch; flex-direction: column; }
  .audio-library-actions { justify-content: flex-start; }
}
