:root {
  --ink: #152126;
  --muted: #64747a;
  --line: #d6e0e2;
  --canvas: #edf2f3;
  --surface: #ffffff;
  --surface-subtle: #f6f9f9;
  --brand: #11343b;
  --accent: #1a6370;
  --accent-soft: #dcecef;
  --danger: #a03939;
  font-family: "Noto Sans", "Segoe UI", Arial, sans-serif;
  color: var(--ink);
  background: var(--canvas);
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: var(--canvas); }
button, input, textarea { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, textarea:focus-visible { outline: 3px solid #7bb7c1; outline-offset: 2px; }

.app-shell { min-height: 100vh; }
.topbar { height: 58px; display: flex; align-items: center; justify-content: space-between; padding: 0 20px; background: var(--brand); color: #fff; }
.brand { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; font-weight: 700; }
.brand small { display: block; color: #bdd4d8; font-size: 11px; font-weight: 500; letter-spacing: 0; }
.brand-mark { width: 28px; height: 28px; display: grid; place-items: center; border: 1px solid #84a9af; font-family: Georgia, serif; font-size: 18px; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.status-badge { color: #d1e7db; font-size: 12px; }
.workspace { min-height: calc(100vh - 58px); display: grid; grid-template-columns: 274px minmax(0, 1fr) 350px; }
.sidebar { padding: 18px 14px; border-right: 1px solid var(--line); background: var(--surface); overflow: auto; }
.main-panel { min-width: 0; display: grid; background: var(--surface-subtle); }
.inspector { padding: 18px; border-left: 1px solid var(--line); background: var(--surface); overflow: auto; }
.inspector header { display: flex; align-items: center; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--line); padding-bottom: 12px; }
.inspector h2 { margin: 0; font-size: 15px; }

.login-panel { max-width: 320px; margin: 12vh auto 0; }
.login-panel h1, .view-header h1, .empty-state h1 { margin: 0; font-size: 22px; font-weight: 700; letter-spacing: 0; }
.stack { display: grid; gap: 12px; margin-top: 18px; }
label { display: grid; gap: 6px; color: var(--muted); font-size: 13px; }
input, textarea { width: 100%; border: 1px solid #b9c9cc; border-radius: 4px; background: #fff; color: var(--ink); padding: 9px 10px; }
textarea { resize: vertical; min-height: 72px; }
button { border: 1px solid var(--accent); border-radius: 4px; background: var(--accent); color: #fff; padding: 9px 12px; font-weight: 650; }
button:hover { background: #15535e; }
.text-button { border-color: transparent; background: transparent; color: var(--accent); padding: 6px 4px; }
.text-button:hover { background: var(--accent-soft); }
.icon-button { padding: 6px 8px; font-size: 12px; }

.new-conversation { width: 100%; margin-bottom: 16px; background: var(--brand); border-color: var(--brand); }
.search-control { margin-bottom: 14px; }
.section-nav { display: grid; gap: 2px; margin: 4px 0 16px; }
.nav-item, .conversation-item { border: 0; border-left: 3px solid transparent; border-radius: 0; background: transparent; color: var(--ink); text-align: left; }
.nav-item { padding: 8px; font-size: 13px; font-weight: 600; }
.nav-item:hover, .nav-item.active { border-left-color: var(--accent); background: var(--accent-soft); color: var(--brand); }
.conversation-list { display: grid; gap: 3px; }
.conversation-item { padding: 9px 8px; }
.conversation-item.active { border-left-color: var(--accent); background: #edf5f5; }
.conversation-title { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; font-weight: 650; }
.conversation-date { display: block; color: var(--muted); font-size: 11px; margin-top: 2px; }

.view { min-height: 0; display: grid; grid-template-rows: auto 1fr auto; }
.view-header { min-height: 82px; display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 17px 24px; background: var(--surface); border-bottom: 1px solid var(--line); }
.eyebrow { margin: 0 0 3px; color: var(--muted); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0; }
.messages { overflow: auto; padding: 24px; }
.message { max-width: 780px; margin: 0 0 18px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 5px; background: var(--surface); white-space: pre-wrap; overflow-wrap: anywhere; }
.message.user { margin-left: auto; background: #e7f0f0; border-color: #bfd4d6; }
.message.dlm { border-left: 4px solid var(--accent); }
.message-label { display: block; margin-bottom: 6px; color: var(--muted); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0; }
.composer { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 10px; padding: 14px 24px; background: var(--surface); border-top: 1px solid var(--line); }
.composer button { min-width: 96px; }
.empty-state { place-self: center; max-width: 470px; padding: 28px; text-align: center; }
.empty-state p { color: var(--muted); }

.data-list { align-self: start; padding: 24px; display: grid; gap: 10px; }
.data-row { display: grid; grid-template-columns: minmax(160px, 32%) 1fr; gap: 16px; padding: 13px; border: 1px solid var(--line); border-radius: 5px; background: var(--surface); }
.data-key { color: var(--muted); font-size: 12px; font-weight: 700; overflow-wrap: anywhere; }
.data-value { overflow-wrap: anywhere; white-space: pre-wrap; font-size: 13px; }
.inspector-content { display: grid; gap: 12px; padding-top: 14px; }
.inspector-section { border-bottom: 1px solid var(--line); padding-bottom: 12px; }
.inspector-section h3 { margin: 0 0 6px; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0; }
.inspector-section pre { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; font: 12px/1.45 ui-monospace, SFMono-Regular, Menlo, monospace; }
.environment-options { margin: 24px; border: 1px solid var(--line); border-radius: 5px; background: var(--surface); display: grid; gap: 10px; max-width: 420px; padding: 16px; }
.environment-options label { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--ink); }
.environment-options input { width: auto; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }
.mobile-only { display: none; }

body[data-environment="enterprise"] { --canvas: #f1f3f5; --surface-subtle: #f8f9fa; }
body[data-environment="tv"] { font-size: 18px; }
body[data-environment="tv"] .workspace { grid-template-columns: 330px minmax(0, 1fr) 410px; }
body[data-environment="tv"] .topbar { height: 70px; }
body[data-environment="tv"] .workspace { min-height: calc(100vh - 70px); }
body[data-environment="tv"] .message { max-width: 940px; }

@media (max-width: 1080px) {
  .workspace { grid-template-columns: 250px minmax(0, 1fr); }
  .inspector { position: fixed; z-index: 3; top: 58px; right: 0; bottom: 0; width: min(390px, 94vw); box-shadow: -8px 0 20px rgb(21 33 38 / 15%); }
}
@media (max-width: 720px) {
  .workspace { display: block; }
  .sidebar { position: fixed; z-index: 4; top: 58px; bottom: 0; left: 0; width: min(290px, 88vw); transform: translateX(-105%); transition: transform 160ms ease; box-shadow: 6px 0 16px rgb(21 33 38 / 15%); }
  .sidebar.open { transform: translateX(0); }
  .mobile-only { display: inline-block; }
  .view-header { padding: 14px 16px; min-height: 70px; }
  .messages { padding: 16px; }
  .composer { grid-template-columns: 1fr; padding: 12px 16px; }
  .composer button { width: 100%; }
  .login-panel { margin-top: 8vh; }
}
