:root {
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #211b2a;
  background: #f6f4f8;
  --muted: #5f5768;
  --line: #e4deeb;
  --accent: #85216e;
  --sidebar: #21182b;
  --surface: #fff;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 0; min-height: 100vh; display: grid; grid-template-columns: minmax(244px, 20rem) minmax(0, 1fr); }
button, input, textarea, select { font: inherit; }
button, summary, select { cursor: pointer; }
:focus-visible { outline: 3px solid #b439a0; outline-offset: 3px; }
.skip { position: fixed; top: 8px; left: 8px; z-index: 2; background: white; color: var(--accent); padding: 12px; transform: translateY(-160%); }
.skip:focus { transform: none; }
.inbox { background: var(--sidebar); color: #fff; padding: 30px 18px 20px; min-width: 0; display: flex; flex-direction: column; gap: 16px; }
.brand { display: block; width: 148px; height: auto; margin: 6px 10px 24px; }
.inbox h2 { margin: 0 10px; font-size: .86rem; color: #e0cfe7; }
.inbox-list { display: grid; gap: 6px; }
.case { border: 1px solid transparent; border-radius: 12px; padding: 11px 12px; color: #f5edf8; background: transparent; width: 100%; text-align: left; display: grid; gap: 6px; }
.case:hover { background: #30233d; }
.case[aria-current="true"] { border-color: #775170; background: #3a2848; box-shadow: inset 3px 0 #f06cdb; }
.case .case-title { font-size: .92rem; font-weight: 650; line-height: 1.3; }
.case .case-kind { font-size: .75rem; color: #e0cfe7; }
.inbox-footer { color: #e0cfe7; font-size: .77rem; margin: auto 10px 0; padding-top: 16px; }
.signal { display: inline-block; width: 8px; height: 8px; background: #ee71d4; border-radius: 50%; margin-right: 5px; }
main { min-width: 0; padding: clamp(18px, 3.4vw, 54px); }
.case-header, .workspace { max-width: 1300px; margin-inline: auto; }
.case-header { padding-bottom: 24px; border-bottom: 1px solid var(--line); margin-bottom: 24px; }
.case-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; font-size: .86rem; color: var(--muted); }
.channel, .pill { display: inline-flex; align-items: center; border-radius: 999px; padding: 5px 10px; font-weight: 650; background: #efe3f4; color: #64245a; font-size: .76rem; }
h1 { margin: 12px 0 6px; font-size: clamp(1.85rem, 4vw, 3.35rem); line-height: 1.07; letter-spacing: -.045em; }
.case-header p { color: var(--muted); margin: 8px 0 0; font-size: .9rem; }
.workspace { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: 20px; align-items: start; }
.stack { display: grid; gap: 16px; min-width: 0; }
.card { min-width: 0; padding: clamp(14px, 2.3vw, 24px); background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 4px 16px #32223f08; overflow-wrap: anywhere; }
.card h2 { margin: 0; font-size: 1.19rem; letter-spacing: -.02em; }
.card-heading { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: 8px; }
.micro { color: var(--muted); font-size: .78rem; }
.byline { font-weight: 650; font-size: .87rem; }
.message, textarea { line-height: 1.55; }
.message { white-space: pre-wrap; margin: 12px 0 0; }
.context { background: #fdf9fe; border-top: 3px solid #d92bb8; }
.ada-label { display: flex; align-items: center; gap: 8px; color: var(--accent); font-size: .76rem; font-weight: 700; margin-bottom: 10px; }
.ada-label img { width: 25px; height: 25px; }
.source { border-top: 1px solid var(--line); margin-top: 12px; padding-top: 7px; }
.source summary { padding: 5px 0; min-height: 44px; font-weight: 630; font-size: .88rem; }
.source summary span { display: block; margin: 4px 0 0 14px; color: var(--muted); font-weight: 500; font-size: .76rem; }
.source p { margin: 6px 0; font-size: .86rem; }
.hint { margin: 12px 0 0; font-size: .83rem; line-height: 1.5; color: var(--muted); }
.hint:empty { display: none; }
.routing { display: grid; gap: 6px; margin: 14px 0 18px; font-size: .85rem; }
.routing div { display: grid; grid-template-columns: 64px minmax(0, 1fr); gap: 6px; }
dt { color: var(--muted); }
dd { margin: 0; font-weight: 580; }
label { display: block; font-weight: 650; font-size: .85rem; margin-bottom: 6px; }
textarea, input, select { width: 100%; min-width: 0; border-radius: 9px; border: 1px solid #bcb0c6; background: #fdfbfe; color: inherit; padding: 10px 12px; }
textarea { resize: vertical; min-height: 108px; }
.btn { border: 1px solid transparent; border-radius: 9px; padding: 10px 14px; min-height: 44px; font-weight: 650; }
.primary { background: #782067; color: white; }
.primary:hover { background: #621955; }
.secondary { background: #f5eff7; color: #59234e; border-color: #e5daea; }
.secondary:hover { background: #eee2f2; }
.btn:disabled { opacity: .6; cursor: default; }
.controls { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 12px; }
.status { margin: 10px 0 0; color: var(--muted); font-size: .85rem; line-height: 1.45; }
.status:empty { margin: 0; }
.status[data-state="confirmed"] { color: #21613a; }
.status[data-state="failed"], .status[data-state="unknown"] { color: #8a3822; }
.status[data-state="pending"]::before { content: ""; display: inline-block; width: .66em; height: .66em; margin-right: 6px; border-radius: 50%; border: 2px solid #d7b5d0; border-top-color: var(--accent); animation: spin .75s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .status[data-state="pending"]::before { animation: none; } }
@media (max-width: 1040px) { .workspace { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 650px) {
  body { display: block; }
  .inbox { padding: 14px; gap: 8px; }
  .brand { width: 100px; margin: 1px 3px 4px; }
  .inbox h2 { margin: 2px 3px; }
  .inbox-list { display: flex; overflow-x: auto; padding: 4px; scroll-snap-type: x proximity; }
  .case { flex: 0 0 168px; scroll-snap-align: start; }
  .inbox-footer { margin: 0 3px; padding-top: 1px; }
  .case-header { padding-bottom: 15px; margin-bottom: 15px; }
  input, select, textarea { font-size: 1rem; }
}

.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.journey { display: flex; align-items: center; flex-wrap: wrap; list-style: none; gap: 7px; padding: 0; margin: 17px 0 0; }
.journey li { border-radius: 999px; padding: 5px 10px; color: var(--muted); background: #eeeaf1; font-size: .77rem; }
.journey li[aria-current="step"] { background: #eeddf0; color: #67245e; font-weight: 700; }
.journey li[data-complete="true"] { background: #e7f2ea; color: #21613a; }
.action-card fieldset { border: 0; margin: 14px 0 0; padding: 0; min-width: 0; }
.action-card fieldset:disabled { opacity: .75; }
.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 12px; }
.options { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 8px; }
.options summary { color: var(--muted); min-height: 44px; align-content: center; font-size: .8rem; }
.options label { color: var(--muted); font-weight: 500; }
.receipt { padding: 12px; border: 1px solid #cbe5d3; border-radius: 10px; background: #f4faf6; margin-top: 12px; font-size: .85rem; }
.receipt p { margin: 4px 0; }
.receipt .micro { color: #3e6450; }
.receipt strong { color: #21613a; }
.source-toggle { display: inline-flex; gap: 8px; align-items: center; min-height: 44px; margin: 3px 0 0; }
.source-toggle input { width: auto; accent-color: var(--accent); }
@media (max-width: 420px) { .fields { grid-template-columns: minmax(0, 1fr); } }

.journal { margin-top: 12px; }
.journal[hidden], .journal-conflict[hidden] { display: none; }
.journal .controls { margin-top: 8px; }
.journal-conflict { background: #fff8ef; border: 1px solid #dec4aa; padding: 12px; border-radius: 12px; margin-top: 10px; }
.conflict-columns { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.conflict-version { background: white; border-radius: 8px; padding: 10px; overflow-wrap: anywhere; }
.conflict-version h3 { font-size: .88rem; margin: 0; }
.conflict-version p { max-height: 10rem; overflow: auto; font-size: .83rem; }
@media (max-width: 600px) { .conflict-columns { grid-template-columns: minmax(0, 1fr); } }

.graph-back { color: #e0cfe7; margin: 0 10px 4px; padding: 8px 0; }

#ada-prepare fieldset { margin-bottom: 12px; }
#ada-sources legend { font-weight: 650; }
#ada-sources details { padding: 4px 0 5px 22px; color: var(--muted); }
#ada-sources details p { margin: 3px 0; }
#ada-result .message { margin-bottom: 8px; }
#ada-result .reader-notice { color: #762f19; }
#ada-actions a { text-decoration: none; }

.work-filters { display: flex; flex-wrap: wrap; gap: 6px; margin-inline: 4px; }
.work-filters button { border: 1px solid #70536f; border-radius: 8px; background: transparent; color: #f5edf8; padding: 7px 9px; font-size: .76rem; min-height: 36px; }
.work-filters button[aria-pressed="true"] { background: #f0e2f4; color: #381a38; border-color: #f0e2f4; font-weight: 650; }
.work-empty { color: #e0cfe7; font-size: .85rem; margin: 8px; }
.work-review { margin-top: 16px; }
.work-review select { width: auto; max-width: 100%; }
.work-review p:empty { display: none; }

.inbox-search { display: grid; gap: 6px; margin-inline: 4px; }
.inbox-search label, .inbox-result { color: #e0cfe7; font-size: .78rem; }
.inbox-search input, .inbox-search select { width: 100%; min-height: 40px; padding: 7px 9px; border: 1px solid #8e6c8b; border-radius: 8px; }
.inbox-result { margin: 0 8px; }
.case-priority { color: #fbc1f0; font-weight: 650; }
.work-priority { display: inline-flex; align-items: center; min-height: 40px; margin-inline-start: 8px; gap: 6px; }
.work-priority input { width: auto; min-width: 16px; min-height: 16px; }

body.compose-page { display: block; }
.compose-workspace { margin-top: 16px; }
.compose-workspace label { margin-top: 12px; }
.compose-list { padding: 0; margin-bottom: 0; list-style: none; }
.compose-list li + li { margin-top: 6px; }
.compose-list button { text-align: left; width: 100%; }
.compose-list button[aria-current="true"] { border-color: var(--accent); }
.compose-page dialog { width: min(38rem, calc(100% - 32px)); border: 1px solid var(--line); }
.compose-page dialog::backdrop { background: #21182ba6; }
#message-confirm-text { white-space: pre-wrap; }

.thread-entries { list-style: none; padding: 0; margin: 0; }
.thread-entry { padding: 12px 0; border-top: 1px solid var(--line); overflow-wrap: anywhere; }
.thread-entry h3 { font-size: 1rem; margin: 0 0 3px; }
.thread-entry .message { margin: 6px 0; }
.thread-attachments { color: var(--muted); padding-left: 20px; }
.thread-attachments li + li { margin-top: 6px; }

.case-task-notice { color: #ffdbad; font-weight: 650; }
