:root {
  --theme-text: #241b19;
  --theme-muted: #746560;
  --theme-background: #f7f1e7;
  --theme-background-deep: #eee2d0;
  --theme-background-glow: #fff8e9;
  --theme-panel: rgba(255, 253, 248, .92);
  --theme-panel-alt: #f4e8d4;
  --theme-accent: #6d2637;
  --theme-accent-strong: #461924;
  --theme-highlight: #b9883c;
  --theme-border: #dacbb8;
  --theme-success: #46664f;
  --theme-topbar-start: #461924;
  --theme-topbar-end: #6d2637;
  --theme-on-accent: #ffffff;
  --theme-shadow: rgba(61, 39, 29, .12);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--theme-text);
  background: var(--theme-background);
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; color: var(--theme-text); background: radial-gradient(circle at 70% 0, var(--theme-background-glow) 0, var(--theme-background) 36rem); transition: color .2s ease, background .2s ease; }
a { color: inherit; }
button, input, select, textarea { font: inherit; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid #ddaa54; outline-offset: 2px; }
.skip-link { position: fixed; left: 1rem; top: -6rem; z-index: 50; background: white; padding: .75rem 1rem; }
.skip-link:focus { top: 1rem; }
.topbar { height: 76px; display: flex; align-items: center; justify-content: space-between; padding: 0 2rem; color: #fff; background: linear-gradient(115deg, var(--theme-topbar-start), var(--theme-topbar-end)); box-shadow: 0 4px 16px var(--theme-shadow); }
.brand { display: inline-flex; gap: .8rem; align-items: center; text-decoration: none; letter-spacing: .02em; }
.brand-mark { display: grid; place-items: center; width: 38px; height: 38px; border: 1px solid rgba(255,255,255,.45); border-radius: 50%; font-family: Georgia, serif; font-size: 1.45rem; }
.brand span:last-child { display: grid; }
.brand small { opacity: .72; font-size: .68rem; text-transform: uppercase; letter-spacing: .12em; }
.user-menu { display: flex; align-items: center; gap: 1rem; }
.user-menu form { margin: 0; }
.app-shell { display: grid; grid-template-columns: 250px minmax(0, 1fr); min-height: calc(100vh - 76px); }
.sidebar { padding: 2rem 1.2rem; border-right: 1px solid var(--theme-border); background: color-mix(in srgb, var(--theme-background-deep) 78%, transparent); }
.sidebar-heading { display: flex; justify-content: space-between; align-items: center; margin: 0 .55rem 1rem; color: var(--theme-muted); text-transform: uppercase; font-size: .72rem; font-weight: 800; letter-spacing: .14em; }
.sidebar-heading a { font-size: 1.35rem; text-decoration: none; color: var(--theme-accent); }
.campaign-link { display: block; padding: .75rem .8rem; border-radius: 9px; text-decoration: none; font-weight: 650; }
.campaign-link:hover { background: var(--theme-panel); }
.main-content { padding: clamp(1.5rem, 4vw, 3.5rem); max-width: 1500px; width: 100%; }
.main-content.centered { grid-column: 1 / -1; display: grid; place-items: center; }
h1, h2 { font-family: Georgia, "Times New Roman", serif; line-height: 1.08; }
h1 { margin: .2rem 0 .7rem; font-size: clamp(2.1rem, 4vw, 3.7rem); font-weight: 500; }
h2 { margin: .35rem 0 .6rem; font-size: 1.45rem; }
p { line-height: 1.62; }
.eyebrow { margin: 0; color: var(--theme-accent); text-transform: uppercase; letter-spacing: .16em; font-weight: 850; font-size: .72rem; }
.lede { color: var(--theme-muted); max-width: 65ch; font-size: 1.06rem; }
.muted { color: var(--theme-muted); }.small { font-size: .85rem; }
.page-header, .campaign-hero { display: flex; justify-content: space-between; align-items: flex-end; gap: 2rem; margin-bottom: 2.2rem; }
.button { display: inline-flex; justify-content: center; align-items: center; border: 1px solid transparent; border-radius: 8px; padding: .72rem 1rem; font-weight: 750; text-decoration: none; cursor: pointer; }
.button.primary { color: var(--theme-on-accent); background: var(--theme-accent); box-shadow: 0 4px 10px var(--theme-shadow); }
.button.primary:hover { background: var(--theme-accent-strong); }
.button.ghost { border-color: currentColor; color: inherit; background: transparent; }
.button:disabled { opacity: .55; cursor: not-allowed; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(270px, 1fr)); gap: 1.2rem; }
.campaign-card, .workspace-card, .panel, .auth-card, .empty-state { border: 1px solid var(--theme-border); border-radius: 14px; background: var(--theme-panel); box-shadow: 0 16px 40px var(--theme-shadow); }
.campaign-card { padding: 1.5rem; text-decoration: none; transition: transform .16s ease, box-shadow .16s ease; }
.campaign-card:hover { transform: translateY(-2px); box-shadow: 0 18px 45px rgba(61,39,29,.16); }
.card-icon { color: var(--theme-highlight); font-size: 1.8rem; }
.card-action { color: var(--theme-accent); font-weight: 750; }
.empty-state { grid-column: 1 / -1; text-align: center; padding: 4rem 2rem; }
.empty-icon { display: block; color: var(--theme-highlight); font-size: 3rem; }
.narrow-page { max-width: 760px; margin: 0 auto; }
.panel { padding: clamp(1.25rem, 3vw, 2rem); margin-top: 2rem; }
.stacked-form { display: grid; gap: .8rem; }
.field { display: grid; align-content: start; gap: .4rem; }
label { font-weight: 780; }
input, select, textarea { width: 100%; padding: .78rem .85rem; border: 1px solid var(--theme-border); border-radius: 8px; color: var(--theme-text); background: var(--theme-panel-alt); }
input:not([type="file"]), select { height: 2.8rem; }
textarea { resize: vertical; }
.help { margin: 0; color: var(--theme-muted); font-size: .82rem; }
.field-error, .form-error { color: #8b1f31; font-weight: 700; }
.form-actions { display: flex; justify-content: flex-end; gap: .75rem; margin-top: .6rem; }
.auth-card { width: min(480px, calc(100vw - 2rem)); padding: clamp(1.5rem, 5vw, 3rem); }
.messages { margin-bottom: 1rem; }.message { border-left: 4px solid var(--theme-success); padding: .8rem 1rem; color: var(--theme-text); background: var(--theme-panel-alt); }
.mode-switcher { display: flex; gap: .3rem; padding: .3rem; border: 1px solid var(--theme-border); border-radius: 10px; background: var(--theme-panel); }
.mode-switcher button { border: 0; padding: .6rem .8rem; border-radius: 7px; color: var(--theme-muted); background: transparent; }
.mode-switcher button.active { color: var(--theme-on-accent); background: var(--theme-accent); }
.ruleset-strip { display: flex; align-items: center; flex-wrap: wrap; gap: .8rem 1.3rem; padding: 1rem 1.2rem; border-block: 1px solid var(--theme-border); color: var(--theme-muted); }
.ruleset-strip > span { text-transform: uppercase; font-size: .68rem; letter-spacing: .13em; font-weight: 800; }
.ruleset-strip strong { color: var(--theme-text); }.ruleset-strip small { color: var(--theme-muted); font-weight: 500; }
.workspace-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; margin-top: 2rem; }
.workspace-card { padding: 1.4rem; }
.workspace-link { color: inherit; text-decoration: none; }
.workspace-link:hover { border-color: var(--theme-highlight); transform: translateY(-2px); }
.workspace-card.featured { grid-column: 1 / -1; padding: 2rem; background: linear-gradient(120deg, var(--theme-panel), var(--theme-panel-alt)); }
.status-chip { display: inline-block; padding: .25rem .55rem; border: 1px solid var(--theme-success); border-radius: 999px; color: var(--theme-success); background: var(--theme-panel-alt); font-size: .75rem; font-weight: 800; }
.record-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1rem; }
.record-card { padding: 1.4rem; border: 1px solid var(--theme-border); border-radius: 13px; color: inherit; background: var(--theme-panel); box-shadow: 0 12px 30px var(--theme-shadow); text-decoration: none; }
.record-card:hover { border-color: var(--theme-highlight); transform: translateY(-2px); }
.record-type, .visibility-chip { display: inline-block; color: var(--theme-highlight); font-size: .7rem; font-weight: 850; letter-spacing: .12em; text-transform: uppercase; }
.visibility-chip { padding: .24rem .5rem; border: 1px solid var(--theme-border); border-radius: 999px; color: var(--theme-muted); letter-spacing: .04em; text-transform: none; }
.record-editor { display: grid; grid-template-columns: minmax(0, 1fr) 330px; align-items: start; gap: 1.3rem; }
.editor-fields { display: grid; gap: 1rem; }
.editor-section { margin: 0; padding: clamp(1.1rem, 2.5vw, 1.8rem); border: 1px solid var(--theme-border); border-radius: 14px; color: var(--theme-text); background: var(--theme-panel); box-shadow: 0 10px 28px var(--theme-shadow); }
.section-heading { display: flex; gap: .9rem; align-items: flex-start; margin-bottom: 1.2rem; }
.section-heading h2, .section-heading p { margin: 0; }
.section-heading p { color: var(--theme-muted); }
.section-number { display: grid; place-items: center; flex: 0 0 2rem; width: 2rem; height: 2rem; border: 1px solid var(--theme-highlight); border-radius: 50%; color: var(--theme-highlight); font-weight: 850; }
.field-grid { display: grid; gap: 1rem; }.field-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }.field-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.disclosure > summary { display: flex; gap: .9rem; align-items: center; cursor: pointer; list-style: none; }
.disclosure > summary::-webkit-details-marker { display: none; }
.disclosure > summary span:last-child { display: grid; gap: .2rem; }
.disclosure > summary strong { font-family: Georgia, serif; font-size: 1.35rem; }
.disclosure > summary small { color: var(--theme-muted); }
.disclosure[open] > summary { margin-bottom: 1.3rem; }
.current-portrait { width: 96px; height: 96px; margin-bottom: 1rem; border: 1px solid var(--theme-border); border-radius: 12px; object-fit: cover; }
.live-preview { position: sticky; top: 1.2rem; padding: 1.4rem; border: 1px solid var(--theme-border); border-radius: 14px; background: linear-gradient(155deg, var(--theme-panel), var(--theme-panel-alt)); box-shadow: 0 16px 38px var(--theme-shadow); }
.preview-portrait { display: grid; place-items: center; width: 100%; aspect-ratio: 4 / 3; margin: 1rem 0; overflow: hidden; border: 1px solid var(--theme-border); border-radius: 11px; color: var(--theme-highlight); background: var(--theme-background-deep); font-size: 4rem; }
.preview-portrait img { width: 100%; height: 100%; object-fit: cover; }
.preview-byline { color: var(--theme-muted); }.preview-description { min-height: 5rem; white-space: pre-wrap; }
.preview-private { margin-top: 1rem; padding: .7rem; border: 1px dashed var(--theme-border); border-radius: 8px; color: var(--theme-muted); font-size: .76rem; }
.sticky-save { position: sticky; bottom: .8rem; display: flex; justify-content: space-between; align-items: center; z-index: 2; padding: .8rem 1rem; border: 1px solid var(--theme-border); border-radius: 11px; background: var(--theme-panel); box-shadow: 0 8px 30px var(--theme-shadow); }
.save-state { color: var(--theme-muted); font-size: .82rem; font-weight: 750; }
.header-actions { display: flex; gap: .6rem; }.header-actions form { margin: 0; }
.record-detail { display: grid; gap: 1rem; }
.record-public { display: grid; grid-template-columns: minmax(180px, 300px) minmax(0, 1fr); gap: 2rem; padding: 1.5rem; border: 1px solid var(--theme-border); border-radius: 14px; background: var(--theme-panel); }
.detail-portrait { margin: 0; }.detail-portrait img { width: 100%; aspect-ratio: 4 / 5; border-radius: 11px; object-fit: cover; }.detail-portrait figcaption { margin-top: .4rem; color: var(--theme-muted); font-size: .8rem; }
.fact-row { display: flex; flex-wrap: wrap; gap: .4rem; }.fact-row span { padding: .3rem .6rem; border: 1px solid var(--theme-border); border-radius: 999px; color: var(--theme-muted); font-size: .78rem; }
.record-prose { line-height: 1.7; white-space: pre-wrap; }
.detail-panel, .gm-panel { padding: 1.5rem; border: 1px solid var(--theme-border); border-radius: 14px; background: var(--theme-panel); }
.gm-panel { border-left: 5px solid var(--theme-highlight); }
.relationship-list { display: flex; flex-wrap: wrap; gap: .6rem; }.relationship-list a { padding: .5rem .7rem; border-radius: 8px; color: var(--theme-on-accent); background: var(--theme-accent); text-decoration: none; }
.private-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: .8rem; }.private-facts div { padding: .8rem; border: 1px solid var(--theme-border); border-radius: 8px; }.private-facts dt { color: var(--theme-highlight); font-weight: 800; }.private-facts dd { margin: .3rem 0 0; white-space: pre-wrap; }
.combat-summary { display: flex; flex-wrap: wrap; align-items: center; gap: .7rem; margin-top: 1rem; padding: .8rem; border: 1px solid var(--theme-border); border-radius: 8px; }.combat-summary span { color: var(--theme-muted); }
.revision-note { color: var(--theme-muted); font-size: .76rem; }
@media (max-width: 850px) { .app-shell { grid-template-columns: 1fr; }.sidebar { display: none; }.workspace-grid { grid-template-columns: 1fr; }.page-header, .campaign-hero { align-items: flex-start; flex-direction: column; }.mode-switcher { width: 100%; overflow-x: auto; }.topbar { padding: 0 1rem; }.user-menu > span { display: none; } }
@media (max-width: 1050px) { .record-editor { grid-template-columns: 1fr; }.live-preview { position: static; grid-row: 1; }.field-grid.three { grid-template-columns: 1fr 1fr; } }
@media (max-width: 650px) { .field-grid.two, .field-grid.three, .record-public { grid-template-columns: 1fr; }.sticky-save { bottom: .35rem; } }
