:root {
  color-scheme: light;
  --ink: #14232b;
  --muted: #5d6b72;
  --paper: #f7f6f1;
  --surface: #ffffff;
  --line: #dbe1de;
  --navy: #123646;
  --teal: #087e78;
  --mint: #dff1e9;
  --focus: #8a4b00;
  --shadow: 0 18px 50px rgba(18, 54, 70, 0.12);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { min-height: 100%; background: var(--paper); }
body { margin: 0; min-height: 100vh; color: var(--ink); background: radial-gradient(circle at 85% 5%, #dcece5 0, transparent 28rem), var(--paper); }
button, a { font: inherit; }
a { color: var(--teal); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }

.skip-link { position: fixed; left: 1rem; top: -4rem; z-index: 10; padding: .7rem 1rem; background: var(--navy); color: white; border-radius: .5rem; }
.skip-link:focus { top: 1rem; }
.topbar { min-height: 76px; display: flex; align-items: center; justify-content: space-between; padding: 1rem clamp(1.2rem, 4vw, 4rem); border-bottom: 1px solid rgba(20,35,43,.1); background: rgba(247,246,241,.9); backdrop-filter: blur(12px); }
.brand { display: flex; align-items: center; gap: .8rem; color: var(--ink); text-decoration: none; }
.brand span:last-child { display: grid; }
.brand small { color: var(--muted); margin-top: .08rem; }
.brand-mark { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 13px; background: var(--navy); color: white; font-weight: 800; box-shadow: inset 0 -5px 0 rgba(8,126,120,.45); }

.role-gate { max-width: 1180px; margin: 0 auto; padding: clamp(3rem, 8vw, 7rem) clamp(1.2rem, 4vw, 3rem) 4rem; }
.eyebrow { margin: 0 0 .6rem; color: var(--teal); font-weight: 800; font-size: .76rem; text-transform: uppercase; letter-spacing: .12em; }
h1 { max-width: 800px; margin: 0; font-size: clamp(2.5rem, 7vw, 5.8rem); line-height: .96; letter-spacing: -.055em; }
.lede { max-width: 720px; margin: 1.3rem 0 2.4rem; color: var(--muted); font-size: clamp(1.05rem, 2vw, 1.35rem); line-height: 1.55; }
.role-grid { display: grid; grid-template-columns: repeat(5, minmax(150px, 1fr)); gap: .9rem; }
.role-card { min-height: 230px; display: flex; flex-direction: column; justify-content: space-between; text-align: left; border: 1px solid var(--line); border-radius: 18px; padding: 1.15rem; background: rgba(255,255,255,.86); color: var(--ink); cursor: pointer; box-shadow: 0 6px 18px rgba(18,54,70,.04); transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease; }
.role-card:hover { transform: translateY(-4px); border-color: var(--teal); box-shadow: var(--shadow); }
.role-index { color: var(--teal); font-weight: 800; }
.role-card h2 { margin: 1rem 0 .35rem; font-size: 1.35rem; }
.role-card p { margin: 0; color: var(--muted); line-height: 1.45; }
.role-card span:last-child { color: var(--navy); font-weight: 750; }
.safety-callout { margin-top: 2rem; padding: 1.1rem 1.3rem; border-left: 5px solid var(--teal); border-radius: 0 12px 12px 0; background: var(--mint); line-height: 1.5; }

.workspace { min-height: calc(100vh - 76px); display: grid; grid-template-columns: minmax(260px, 330px) 1fr; }
.sidebar { padding: 1.5rem; border-right: 1px solid var(--line); background: rgba(255,255,255,.7); overflow-y: auto; }
.role-summary { padding: .8rem .5rem 1.2rem; }
.role-summary h2 { margin: 0 0 .45rem; font-size: 1.8rem; }
.role-summary p { margin: 0; color: var(--muted); line-height: 1.45; }
.nav-section { margin: 1rem 0; }
.nav-section h3 { margin: 0 .5rem .35rem; color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .1em; }
.nav-file { width: 100%; border: 0; border-radius: 9px; padding: .58rem .65rem; background: transparent; color: var(--ink); text-align: left; cursor: pointer; line-height: 1.3; }
.nav-file:hover, .nav-file[aria-current="page"] { background: var(--mint); color: var(--navy); }
.sidebar-actions { display: grid; gap: .55rem; margin-top: 1.4rem; padding-top: 1.2rem; border-top: 1px solid var(--line); }
button, .button-link { min-height: 42px; display: inline-flex; align-items: center; justify-content: center; border: 0; border-radius: 10px; padding: .65rem .8rem; background: var(--navy); color: white; text-decoration: none; cursor: pointer; font-weight: 750; }
.button-link.secondary { background: white; color: var(--navy); border: 1px solid var(--line); }
.quiet-button { min-height: auto; background: transparent; border: 1px solid var(--line); color: var(--navy); }
.text-link { justify-self: center; padding: .5rem; }

.document-panel { min-width: 0; padding: clamp(1.3rem, 4vw, 4rem); overflow-x: hidden; }
.empty-state { max-width: 620px; margin: 12vh auto; padding: 2rem; }
.empty-state h2 { margin: 0 0 .8rem; font-size: 2.2rem; }
.empty-state p:last-child { color: var(--muted); line-height: 1.6; }
#document-view { max-width: 980px; margin: 0 auto; }
.document-header { display: flex; align-items: start; justify-content: space-between; gap: 1rem; }
.document-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.mobile-only { display: none; }
.document-header h2 { margin: 0; font-size: clamp(2rem, 4vw, 3.4rem); letter-spacing: -.04em; }
.path { margin: 0 0 .4rem; color: var(--teal); font: 700 .8rem ui-monospace, SFMono-Regular, Menlo, monospace; overflow-wrap: anywhere; }
.metadata { display: flex; flex-wrap: wrap; gap: .5rem; margin: 1.2rem 0 2rem; }
.metadata div { display: flex; gap: .35rem; padding: .38rem .58rem; border: 1px solid var(--line); border-radius: 999px; background: white; font-size: .78rem; }
.metadata dt { color: var(--muted); }
.metadata dd { margin: 0; font-weight: 700; }
.document-content { padding: clamp(1.2rem, 3vw, 2.5rem); border: 1px solid var(--line); border-radius: 18px; background: var(--surface); box-shadow: var(--shadow); line-height: 1.65; overflow-x: auto; }
.document-content h1, .document-content h2, .document-content h3 { line-height: 1.2; letter-spacing: -.025em; }
.document-content h1 { font-size: 2rem; }
.document-content h2 { margin-top: 2rem; }
.document-content blockquote { margin: 1rem 0; padding: .2rem 1rem; border-left: 4px solid var(--teal); background: var(--mint); }
.document-content code { padding: .15rem .3rem; border-radius: 4px; background: #eef1ef; }
.document-content table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.document-content th, .document-content td { padding: .6rem .7rem; border: 1px solid var(--line); text-align: left; vertical-align: top; }
.document-content th { background: #eef4f1; }
.toast { position: fixed; right: 1rem; bottom: 1rem; max-width: 340px; padding: .8rem 1rem; border-radius: 10px; background: var(--navy); color: white; opacity: 0; transform: translateY(1rem); transition: .2s ease; pointer-events: none; }
.toast.show { opacity: 1; transform: translateY(0); }

@media (max-width: 960px) {
  .role-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .workspace { grid-template-columns: 1fr; }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--line); }
  #file-nav { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6rem; }
  .nav-section { margin: 0; }
  .mobile-only { display: inline-flex; }
}

@media (max-width: 560px) {
  .topbar { padding: .8rem 1rem; }
  .brand small { display: none; }
  .role-grid, #file-nav { grid-template-columns: 1fr; }
  .role-card { min-height: 170px; }
  .document-header { display: grid; }
  .document-header .quiet-button { justify-self: start; }
}

@media print {
  .topbar, .sidebar, .skip-link, .toast { display: none !important; }
  .workspace, #workspace { display: block !important; }
  .document-panel { padding: 0; }
  .document-content { border: 0; box-shadow: none; padding: 0; }
}
