/* RAJIH 3.0 Studio — built strictly on the official Rawajeh palette.
   Official: #8A603E #9F7B5E #CEBBAB #000000 · Special: #34271D #AE8C81 #FDF5E4 */
:root {
  --r-signature: #8A603E; --r-warm: #9F7B5E; --r-beige: #CEBBAB; --r-deep: #34271D;
  --r-rose: #AE8C81; --r-ivory: #FDF5E4; --r-ink: #292723; --r-muted: #6b6157;
  --r-ok: #4f6b4a; --r-wait: #8a6a2e; --r-issue: #9d3131;
  --r-radius: 16px; --r-ease: cubic-bezier(.2,.7,.2,1);
}

/* ---------- brand atmosphere: the overlapping diamonds, quietly */
.masthead { position: relative; isolation: isolate; }
.masthead::after {
  content: ''; position: absolute; inset-block: -6px; inset-inline-end: 40%; inline-size: 120px; z-index: -1;
  background: url('/rawajeh-diamonds.png') center / contain no-repeat; opacity: .07; pointer-events: none;
}
.studio-tour-toggle {
  margin-inline-start: auto; border: 1px solid var(--r-beige); background: var(--r-ivory); color: var(--r-deep);
  border-radius: 999px; padding: 7px 14px; font: inherit; font-size: .86rem; font-weight: 600; cursor: pointer;
  transition: background .2s var(--r-ease), border-color .2s var(--r-ease);
}
.studio-tour-toggle span { color: var(--r-signature); }
.studio-tour-toggle:hover, .studio-tour-toggle[aria-expanded='true'] { background: #f4e6cf; border-color: var(--r-warm); }
.studio-tour-toggle:focus-visible, .studio-node-button:focus-visible, .studio-library-item:focus-visible,
.studio-brief-open:focus-visible, .studio-starter:focus-visible, .studio-tour-say:focus-visible { outline: 3px solid var(--r-warm); outline-offset: 2px; }

/* ---------- living character stage (bound to real voice phases & measured audio level) */
.character-halo { position: relative; --voice-level: 0; transition: box-shadow .12s linear, transform .3s var(--r-ease); }
.character-halo::after {
  content: ''; position: absolute; inset: -2px; border-radius: 50%; pointer-events: none;
  box-shadow: 0 0 0 calc(2px + var(--voice-level) * 10px) rgba(159, 123, 94, calc(.18 + var(--voice-level) * .5));
  opacity: 0; transition: opacity .25s var(--r-ease);
}
body[data-rajih-phase='speaking'] .character-halo::after { opacity: 1; }
body[data-rajih-phase='listening'] .character-halo { box-shadow: 0 0 0 3px #CEBBABaa, 0 0 22px #9F7B5E44; }
body[data-rajih-phase='thinking'] .character-halo { animation: rajih-think 1.6s var(--r-ease) infinite; }
body[data-rajih-phase='interrupted'] .character-halo { box-shadow: 0 0 0 3px #AE8C81; }
body[data-rajih-phase='error'] .character-halo { box-shadow: 0 0 0 3px #9d313155; }
@keyframes rajih-think { 0%, 100% { box-shadow: 0 0 0 2px #CEBBAB66; } 50% { box-shadow: 0 0 0 6px #9F7B5E33; } }
.character-card[data-phase]:not([data-phase=''])::before {
  content: attr(data-phase); position: absolute; inset-block-start: 14px; inset-inline-start: 14px;
  background: var(--r-deep); color: var(--r-ivory); font-size: .74rem; font-weight: 600; padding: 3px 10px; border-radius: 999px;
}
.studio-caption {
  margin: 4px 0 0; max-inline-size: 100%; padding: 8px 12px; border-radius: 14px; background: var(--r-ivory);
  border: 1px solid #ead9c2; color: var(--r-ink); font-size: .86rem; line-height: 1.6; text-align: center;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.studio-caption[data-who='user'] { background: #fff; color: var(--r-muted); font-style: italic; }
.studio-meter { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin-top: 6px; }
.studio-meter-item { display: grid; gap: 1px; padding: 5px 9px; border-radius: 10px; background: #f6eee3; min-inline-size: 74px; text-align: center; }
.studio-meter-item small { color: var(--r-muted); font-size: .68rem; }
.studio-meter-item b { color: var(--r-deep); font-size: .84rem; font-variant-numeric: tabular-nums; }

/* ---------- live case canvas: what RAJIH understood, and why */
.studio-canvas, .studio-mission { display: grid; gap: 10px; padding: 14px; margin-block-end: 12px; border-radius: var(--r-radius);
  background: linear-gradient(180deg, #fffdf8, #fbf4ea); border: 1px solid #eadcc9; }
.studio-canvas-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.studio-canvas-hint { color: var(--r-muted); font-size: .76rem; }
.studio-progress { block-size: 4px; border-radius: 4px; background: #efe3d3; overflow: hidden; }
.studio-progress span { display: block; block-size: 100%; background: linear-gradient(90deg, var(--r-warm), var(--r-signature)); transition: inline-size .5s var(--r-ease); }
.studio-tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.studio-tile { position: relative; display: grid; gap: 4px; align-content: start; padding: 10px 11px; border-radius: 12px; background: #fff;
  border: 1px solid #ece2d6; min-block-size: 64px; transition: border-color .3s var(--r-ease), box-shadow .3s var(--r-ease); }
.studio-tile.is-missing { background: #fffdfa; border-style: dashed; }
.studio-tile.is-missing .studio-tile-value { color: #b3a698; }
.studio-tile.is-fresh { animation: rajih-captured 1.4s var(--r-ease); }
@keyframes rajih-captured { 0% { box-shadow: 0 0 0 0 #9F7B5E88; border-color: var(--r-signature); transform: translateY(-2px); } 100% { box-shadow: 0 0 0 10px #9F7B5E00; transform: none; } }
.studio-tile-top { display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.studio-tile-label { color: var(--r-muted); font-size: .74rem; }
.studio-tile-value { color: var(--r-ink); font-weight: 600; font-size: .95rem; overflow-wrap: anywhere; }
.studio-tile-was { font-size: .74rem; color: var(--r-muted); }
.studio-tile-was del { color: var(--r-rose); }
.studio-tile-proof { font-size: .72rem; color: var(--r-warm); line-height: 1.5; }
.studio-tile-proof q { quotes: '«' '»'; color: var(--r-signature); }
.studio-tile-issue { font-size: .72rem; color: var(--r-issue); }
.studio-chip { font-size: .66rem; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: #f2e9dd; color: var(--r-muted); white-space: nowrap; }
.studio-chip.is-proposed { background: #f4e6cf; color: var(--r-signature); }
.studio-chip.is-confirmed { background: #e6eee2; color: var(--r-ok); }
.studio-chip.is-deferred { background: #efe9f0; color: #6d5a6e; }
.studio-chip.is-uncertain { background: #fbecd2; color: var(--r-wait); }
.studio-chip.is-corrected { background: var(--r-deep); color: var(--r-ivory); }

/* ---------- mission map */
.studio-track { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; position: relative; }
.studio-node { position: relative; }
.studio-node + .studio-node::before { content: ''; position: absolute; inset-inline-start: 17px; inset-block-start: -10px; block-size: 20px; border-inline-start: 2px dotted var(--r-beige); }
.studio-node-button { inline-size: 100%; display: flex; gap: 10px; align-items: center; padding: 8px; border: 0; background: transparent; border-radius: 12px; cursor: pointer; text-align: start; font: inherit; color: inherit; }
.studio-node-button:hover { background: #f6eee3; }
.studio-node-dot { flex: none; inline-size: 20px; block-size: 20px; margin-inline: 6px; transform: rotate(45deg); border-radius: 4px; border: 2px solid var(--r-beige); background: #fff; }
.studio-node.is-active .studio-node-dot { border-color: var(--r-signature); background: #f4e6cf; }
.studio-node.is-done .studio-node-dot { border-color: var(--r-ok); background: var(--r-ok); }
.studio-node.is-waiting .studio-node-dot { border-color: var(--r-wait); background: #fbecd2; }
.studio-node-text { display: grid; gap: 1px; }
.studio-node-text strong { font-size: .88rem; color: var(--r-ink); }
.studio-node-text small { font-size: .74rem; color: var(--r-muted); }
.studio-node-text em { font-style: normal; font-size: .7rem; color: var(--r-warm); }
.studio-next { margin: 0; padding: 9px 11px; border-radius: 10px; background: var(--r-deep); color: var(--r-ivory); font-size: .82rem; }
.studio-next strong { color: #f3dcc0; }

/* ---------- library in the sidebar */
.studio-library { display: grid; gap: 6px; margin-block: 10px 4px; }
.studio-library-items { display: grid; gap: 4px; max-block-size: 30vh; overflow: auto; }
.studio-library-item { display: flex; align-items: center; gap: 9px; inline-size: 100%; padding: 7px 8px; border: 0; border-radius: 11px;
  background: transparent; color: inherit; font: inherit; text-align: start; cursor: pointer; }
.studio-library-item:hover, .studio-library-item.is-current { background: #ffffff1c; }
.studio-ring { --p: 0; flex: none; inline-size: 26px; block-size: 26px; border-radius: 50%;
  background: conic-gradient(#e9cfae calc(var(--p) * 1%), #ffffff26 0); -webkit-mask: radial-gradient(circle 8px, transparent 98%, #000); mask: radial-gradient(circle 8px, transparent 98%, #000); }
.studio-library-text { display: grid; min-inline-size: 0; }
.studio-library-text strong { font-size: .85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.studio-library-text small { font-size: .7rem; opacity: .75; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.studio-days { margin-inline-start: auto; font-size: .68rem; padding: 2px 7px; border-radius: 999px; background: #e9cfae; color: var(--r-deep); font-weight: 700; white-space: nowrap; }
.studio-empty { font-size: .76rem; opacity: .7; margin: 2px 6px; }
.sidebar-collapsed .studio-library { display: none; }
@media (max-width: 920px) and (min-width: 651px) { .app-frame:not(.sidebar-expanded) .studio-library { display: none; } }

/* ---------- daily briefing on the welcome screen */
.studio-briefing { margin: 18px auto 0; max-inline-size: 620px; display: grid; gap: 12px; text-align: start; }
.studio-brief-head { display: grid; gap: 2px; }
.studio-brief-headline { margin: 0; font-size: 1.02rem; color: var(--r-deep); font-weight: 600; }
.studio-brief-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.studio-brief-note { display: grid; gap: 3px; padding: 10px 12px; border-radius: 13px; background: #fff; border: 1px solid #ece2d6; border-inline-start: 4px solid var(--r-beige); }
.studio-brief-note.is-p0 { border-inline-start-color: var(--r-signature); }
.studio-brief-note.is-p1 { border-inline-start-color: var(--r-warm); }
.studio-brief-open { border: 0; background: none; padding: 0; text-align: start; font: inherit; color: var(--r-ink); cursor: pointer; font-weight: 600; font-size: .9rem; }
.studio-why { color: var(--r-muted); font-size: .72rem; }
.studio-starters { display: flex; flex-wrap: wrap; gap: 8px; }
.studio-starter { border: 1px solid #e5d6c3; background: var(--r-ivory); color: var(--r-deep); border-radius: 999px; padding: 7px 13px; font: inherit; font-size: .84rem; cursor: pointer; transition: background .2s var(--r-ease); }
.studio-starter:hover { background: #f4e6cf; }

/* ---------- judge tour */
.studio-tour { position: sticky; inset-block-start: 0; z-index: 3; margin: 0 auto 12px; max-inline-size: 640px; padding: 14px 16px; border-radius: var(--r-radius);
  background: var(--r-deep); color: var(--r-ivory); box-shadow: 0 14px 40px #34271d33; display: grid; gap: 8px; }
.studio-tour .eyebrow { color: #e9cfae; }
.studio-tour-head { display: flex; justify-content: space-between; align-items: center; }
.studio-tour-note { margin: 0; font-size: .76rem; opacity: .8; }
.studio-tour-list { margin: 0; padding-inline-start: 1.3em; display: grid; gap: 6px; max-block-size: 40vh; overflow: auto; }
.studio-tour-list li { display: grid; gap: 2px; font-size: .84rem; }
.studio-tour-list li.is-done strong { color: #b9d3a8; }
.studio-tour-list li.is-done strong::after { content: ' ✓'; }
.studio-tour-say { justify-self: start; border: 0; background: #ffffff14; color: #f3dcc0; border-radius: 8px; padding: 3px 8px; font: inherit; font-size: .78rem; cursor: pointer; text-align: start; }
.studio-tour-say:hover { background: #ffffff26; }

/* ---------- settings additions */
.studio-budget { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.studio-budget input { inline-size: 7rem; padding: 6px 8px; border-radius: 9px; border: 1px solid var(--r-beige); font: inherit; }
.studio-diag-list { display: grid; grid-template-columns: minmax(8rem, auto) 1fr; gap: 4px 12px; font-size: .8rem; margin: 10px 0 0; }
.studio-diag-list dt { color: var(--r-muted); }
.studio-diag-list dd { margin: 0; color: var(--r-ink); font-variant-numeric: tabular-nums; }
.rt-check { display: flex; gap: 6px; align-items: center; font-size: .82rem; margin-block: 6px; }

/* ---------- duplicate guard */
.studio-duplicate { display: grid; gap: 6px; padding: 11px 12px; border-radius: 12px; background: #fbecd2; border: 1px solid #e8c98f; color: var(--r-deep); font-size: .84rem; }
.studio-duplicate-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.studio-duplicate-actions .button { font-size: .8rem; padding: 6px 12px; }

/* ---------- verified file readback */
.studio-peek, .studio-pack { justify-self: start; margin-inline-start: 40px; border: 1px dashed var(--r-warm); background: transparent; color: var(--r-signature);
  border-radius: 999px; padding: 4px 11px; font: inherit; font-size: .76rem; cursor: pointer; }
.studio-pack { margin: 0; border-style: solid; background: var(--r-ivory); font-weight: 600; }
.studio-peek:disabled { opacity: .6; cursor: default; }
.studio-peek-out:empty { display: none; }
.studio-cells { margin: 6px 0 4px 0; inline-size: 100%; border-collapse: collapse; font-size: .74rem; background: #fff; border-radius: 10px; overflow: hidden; }
.studio-cells caption { text-align: start; color: var(--r-muted); padding-block-end: 4px; font-size: .72rem; }
.studio-cells th, .studio-cells td { padding: 4px 6px; border-bottom: 1px solid #f0e6d9; text-align: start; overflow-wrap: anywhere; }
.studio-cells th { color: var(--r-muted); font-weight: 600; background: #faf4ea; }

/* ---------- command palette */
.studio-palette { inline-size: min(560px, 92vw); padding: 10px; border: 1px solid var(--r-beige); border-radius: 18px; background: #fffdf8; box-shadow: 0 24px 60px #34271d40; }
.studio-palette::backdrop { background: #34271d55; }
.studio-palette input { inline-size: 100%; box-sizing: border-box; padding: 12px 14px; border: 1px solid #eadcc9; border-radius: 12px; font: inherit; font-size: 1rem; background: #fff; }
.studio-palette-list { list-style: none; margin: 8px 0 4px; padding: 0; display: grid; gap: 2px; max-block-size: 50vh; overflow: auto; }
.studio-palette-list li { padding: 9px 12px; border-radius: 10px; cursor: pointer; font-size: .9rem; }
.studio-palette-list li.is-active, .studio-palette-list li:hover { background: var(--r-deep); color: var(--r-ivory); }
.studio-palette-hint { margin: 0; color: var(--r-muted); font-size: .72rem; text-align: center; }

/* ---------- handoff pack: printed alone */
.studio-print { display: none; }
@media print {
  body > *:not(#studio-print) { display: none !important; }
  .studio-print { display: block !important; color: #000; font-size: 11pt; }
  .studio-print-head { display: flex; justify-content: space-between; align-items: center; border-bottom: 2px solid #8A603E; padding-bottom: 8px; }
  .studio-print-head img { block-size: 60px; }
  .studio-print-head h1 { margin: 0; font-size: 18pt; color: #34271D; }
  .studio-print-facts { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; margin: 14px 0; }
  .studio-print-facts dt { color: #6b6157; } .studio-print-facts dd { margin: 0; font-weight: 600; }
  .studio-print-flows { inline-size: 100%; border-collapse: collapse; }
  .studio-print-flows th, .studio-print-flows td { border: 1px solid #CEBBAB; padding: 5px 7px; text-align: start; vertical-align: top; }
  .studio-print-flows th { background: #FDF5E4; }
  .studio-print footer { margin-top: 12px; font-size: 9pt; color: #6b6157; }
}

@media (max-width: 650px) {
  .studio-tiles { grid-template-columns: 1fr; }
  .studio-tour-toggle { padding: 6px 10px; font-size: .78rem; }
  .masthead::after { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .studio-tile.is-fresh, body[data-rajih-phase='thinking'] .character-halo { animation: none; }
  .character-halo::after { transition: none; }
}
