/* Kanka — single stylesheet in the etenoz hub / Arena visual language (light + dark).
   Tokens and base treatments copied from arena/src/styles (tokens.css, base.css); no runtime dependency on Arena.
   Sections: tokens · base · vocabulary · shell · page heads · home · tasks · tools · schedule · settings
             · chat · approval card · dialogs · command menu · notifications · toast · auth */

/* ---------- tokens ---------- */
:root {
  --bg: #e9eef2;
  --paper: #f7f9fa;
  --ink: #0e2033;
  --muted: #4d5e6d;
  --line: #aebdca;
  --accent: #7a4b31;
  --focus: #0e5da8;
  --scrim: rgba(14, 32, 51, 0.45);
  --serif: 'Fraunces', Georgia, serif;
  --sans: 'Space Grotesk', system-ui, sans-serif;
  --topbar: 3.75rem;
  color-scheme: light;
}
[data-theme="dark"] {
  --bg: #0e2033;
  --paper: #15293d;
  --ink: #eef2f5;
  --muted: #9fb0bf;
  --line: #2c4157;
  --accent: #c08a68;
  --focus: #7fb3e6;
  --scrim: rgba(4, 12, 20, 0.6);
  color-scheme: dark;
}
/* before app.js runs (auth screen, first paint) there is no data-theme yet: follow the system scheme */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --bg: #0e2033;
    --paper: #15293d;
    --ink: #eef2f5;
    --muted: #9fb0bf;
    --line: #2c4157;
    --accent: #c08a68;
    --focus: #7fb3e6;
    --scrim: rgba(4, 12, 20, 0.6);
    color-scheme: dark;
  }
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-weight: 400;
  font-size: 15px;
  line-height: 1.5;
  overflow: hidden;
}
h1, h2, h3, p { margin: 0; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.icon-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.ui-icon { display: block; width: 1.15rem; height: 1.15rem; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- vocabulary (used by later tasks) ---------- */
.display, .serif, h1 {
  font-family: var(--serif);
  font-weight: 800;
  letter-spacing: -0.03em;
  font-optical-sizing: auto;
}
.display { font-size: clamp(40px, 6vw, 72px); line-height: 0.95; }
.label, .page-kicker, .eyebrow {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.muted { color: var(--muted); }
.accent { color: var(--accent); font-weight: 600; }

.btn, .primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 2.5rem;
  border: 1px solid var(--ink);
  border-radius: 6px;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  background: var(--ink);
  color: var(--bg);
}
.btn-secondary, .secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 2.5rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 500;
  background: transparent;
  color: var(--ink);
}
.btn-secondary:hover, .secondary:hover { border-color: var(--ink); }
.btn:disabled, .primary:disabled, .btn-secondary:disabled { opacity: 0.55; cursor: default; }

.field { display: grid; gap: 6px; min-width: 0; font-size: 11px; font-weight: 500; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.field input, .field select, .field textarea,
.task-form input, .dialog-card input, .dialog-card textarea, .auth-card input {
  width: 100%;
  min-width: 0;
  min-height: 2.75rem;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--paper);
  color: var(--ink);
  font-size: 15px;
  font-weight: 400;
  letter-spacing: normal;
  text-transform: none;
}
.field input:focus, .field select:focus, .task-form input:focus, .dialog-card input:focus, .dialog-card textarea:focus, .auth-card input:focus { border-color: var(--ink); }

.paper, dialog, .notification-panel, .auth-card {
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 10px;
}

/* hairline-separated row: number · body · aside */
.rule-list { display: grid; }
.rule-row {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  width: 100%;
  min-width: 0;
  padding: 14px 0;
  border: 0;
  border-top: 1px solid var(--line);
  border-radius: 0;
  background: none;
  text-align: left;
}
.rule-row:last-child { border-bottom: 1px solid var(--line); }
.rule-num { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.rule-body { display: grid; gap: 2px; min-width: 0; }
.rule-body strong { font-family: var(--serif); font-weight: 800; letter-spacing: -0.03em; font-size: 22px; line-height: 1.15; overflow-wrap: anywhere; }
.rule-body small { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.rule-aside { color: var(--muted); font-size: 15px; }
button.rule-row:hover .rule-aside { color: var(--ink); }
button.rule-row:hover strong { text-decoration: underline; text-decoration-thickness: 1.5px; text-underline-offset: 4px; }

/* ---------- shell ---------- */
.app-layout { height: var(--visual-height, 100dvh); display: flex; }
.app-shell { min-width: 0; flex: 1; height: var(--visual-height, 100dvh); display: flex; flex-direction: column; }

.brand { display: inline-flex; align-items: baseline; gap: 0.3em; color: var(--ink); font-weight: 600; font-size: 15px; text-decoration: none; white-space: nowrap; }
.brand span { color: var(--muted); font-weight: 400; }

.sidebar {
  width: 16rem;
  flex: 0 0 16rem;
  display: flex;
  flex-direction: column;
  padding: 18px 16px 14px;
  background: var(--bg);
  border-right: 1px solid var(--line);
  overflow-y: auto;
  scrollbar-width: thin;
}
.sidebar-head { display: flex; align-items: center; justify-content: space-between; min-height: 2.5rem; margin-bottom: 14px; }
.sidebar-close, .menu-button { width: 2.75rem; height: 2.75rem; border: 0; background: transparent; color: var(--ink); }
.sidebar-close { font-size: 1.6rem; line-height: 1; }
.menu-button { display: none; place-content: center; gap: 5px; margin-left: -10px; }
.menu-button i { display: block; width: 1.15rem; height: 1.5px; background: var(--ink); }
.menu-overlay { display: none; }
.sidebar-new { width: 100%; }
.sidebar-new .ui-icon { width: 1rem; height: 1rem; }

.main-nav { display: grid; margin-top: 18px; }
.main-nav p { margin: 0 0 6px; font-size: 11px; font-weight: 500; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.main-nav button, .sidebar-bottom > button {
  display: flex; align-items: center; min-height: 2.25rem; padding: 0; border: 0; background: transparent;
  color: var(--muted); font-size: 14px; text-align: left;
}
.main-nav button span, .sidebar-bottom > button span { display: none; }
.main-nav button:hover, .sidebar-bottom > button:hover { color: var(--ink); }
.main-nav button.active, .sidebar-bottom > button.active { color: var(--ink); font-weight: 600; text-decoration: underline; text-decoration-thickness: 1.5px; text-underline-offset: 4px; }

.sidebar-section { margin-top: 18px; min-height: 0; }
.sidebar-label { display: flex; align-items: center; justify-content: space-between; min-height: 2rem; font-size: 11px; font-weight: 500; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); border-top: 1px solid var(--line); padding-top: 6px; }
.sidebar-label button { width: 2rem; height: 2rem; border: 0; border-radius: 6px; background: transparent; color: var(--muted); font-size: 13px; }
.sidebar-label button:hover { color: var(--ink); }
.sidebar-items { display: grid; max-height: 9rem; overflow-y: auto; scrollbar-width: thin; }
.sidebar-item, .project-chat {
  width: 100%; min-width: 0; min-height: 2.1rem; display: flex; align-items: center; gap: 8px; padding: 0; border: 0;
  background: transparent; color: var(--muted); font-size: 13px; text-align: left;
}
.sidebar-item > span:first-child { display: none; }
.sidebar-item strong, .project-chat strong { min-width: 0; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 400; }
.sidebar-item:hover, .project-chat:hover { color: var(--ink); }
.sidebar-item.active, .project-chat.active { color: var(--ink); }
.sidebar-item.active strong, .project-chat.active strong { font-weight: 600; }
.sidebar-item small { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.sidebar-item.project { gap: 6px; padding-right: 4px; }
/* disclosure chevron drawn in CSS (the ⌄ / › glyphs from app.js sit on different baselines); count is plain muted text */
.sidebar-item.project b { order: -1; flex: 0 0 1rem; height: 1rem; display: grid; place-items: center; font-size: 0; color: var(--muted); }
.sidebar-item.project b::before { content: ""; width: 5px; height: 5px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: translateX(-1px) rotate(-45deg); }
.sidebar-item.project[aria-expanded="true"] b::before { transform: translateY(-1px) rotate(45deg); }
.sidebar-item.project small { min-width: 1.25rem; font-size: 12px; text-align: right; }
.sidebar-item.project { color: var(--ink); }
.sidebar-empty { margin: 4px 0; color: var(--muted); font-size: 13px; }
.project-group { display: grid; }
.project-line { display: grid; grid-template-columns: minmax(0, 1fr) 2rem; align-items: center; gap: 2px; }
.project-add-chat { width: 2rem; height: 2rem; border: 0; border-radius: 6px; background: transparent; color: var(--muted); font-size: 13px; }
.project-add-chat:hover { color: var(--ink); }
.project-chats { display: grid; margin: 0 0 6px 0.45rem; padding-left: 14px; border-left: 1px solid var(--line); }
.project-chat span { display: none; }
.project-chats p { margin: 4px 0; color: var(--muted); font-size: 12px; }

.sidebar-bottom { margin-top: auto; padding-top: 18px; display: grid; gap: 10px; }
.profile { display: flex; align-items: center; gap: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.profile > span { width: 2rem; height: 2rem; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 50%; color: var(--muted); font-size: 13px; }
.profile div { display: grid; }
.profile strong { font-size: 13px; font-weight: 600; }
.profile small { color: var(--muted); font-size: 12px; }

.topbar {
  flex: 0 0 var(--topbar);
  height: var(--topbar);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 28px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
  position: relative;
  z-index: 10;
}
.mobile-brand { display: flex; align-items: center; gap: 4px; min-width: 0; }
.topbar .brand { display: none; }
.header-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.top-icon {
  position: relative; min-width: 2.5rem; height: 2.5rem; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 0 10px; border: 1px solid var(--line); border-radius: 6px; background: transparent; color: var(--ink); font-size: 13px;
}
.top-icon:hover { border-color: var(--ink); }
.top-icon small { color: var(--muted); font-size: 12px; }
.top-icon i { position: absolute; right: -6px; top: -6px; min-width: 1.15rem; height: 1.15rem; padding: 0 4px; border-radius: 999px; background: var(--accent); color: var(--paper); font: 600 11px/1.15rem var(--sans); font-style: normal; }
.top-icon i[hidden] { display: none; }
.status { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.pulse { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); }
.new-chat {
  min-height: 2.5rem; min-width: 2.5rem; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 0 12px; border: 1px solid var(--line); border-radius: 6px; background: transparent; color: var(--ink); font-size: 13px;
}
/* hairline like the other top controls: the sidebar's "Yeni sohbet" is the one ink button of the shell */
.new-chat:hover { border-color: var(--ink); }
.new-chat b { font-weight: 500; }

/* views: one scroll container per view, content column max 960px */
.app-view { display: none; }
.app-view.active { display: flex; }
.page-view {
  flex-direction: column;
  width: 100%;
  height: calc(var(--visual-height, 100dvh) - var(--topbar));
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 32px max(28px, calc((100% - 904px) / 2)) 64px;
}

/* ---------- page heads ---------- */
.page-head, .home-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 20px;
  align-items: end;
  padding-bottom: 18px;
  border-bottom: 1.5px solid var(--ink);
}
.page-kicker { margin-bottom: 8px; }
.page-head h1, .home-hero h1 { overflow-wrap: anywhere; }
.page-head p:not(.page-kicker), .home-hero p:not(.page-kicker) { margin-top: 12px; max-width: 60ch; color: var(--muted); font-size: 14px; line-height: 1.6; }
.task-count { font-size: 11px; font-weight: 500; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); white-space: nowrap; }

/* ---------- home ---------- */
.home-primary span { margin-left: 4px; }
.home-grid .rule-row:first-child { border-top: 0; }
.rule-meta { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 6px; min-width: 0; margin-top: 2px; }
.rule-meta small { overflow-wrap: anywhere; }
.rule-meta small::before { content: "· "; color: var(--muted); }
.quick-section { margin-top: 32px; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px 20px; align-items: end; }
.quick-section h2 { font-size: 11px; font-weight: 500; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.quick-section p { margin-top: 4px; color: var(--muted); font-size: 14px; }
.quick-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.quick-actions span { color: var(--muted); }

/* ---------- tasks ---------- */
.task-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; margin: 20px 0; } /* same air above and below, as on the schedule form */
.task-form .btn { min-height: 2.75rem; padding: 0 18px; }
.task-list { display: grid; }
.task-item {
  display: grid; grid-template-columns: 32px minmax(0, 1fr) auto; gap: 14px; align-items: center;
  min-height: 3.5rem; padding: 8px 0; border-top: 1px solid var(--line);
}
.task-item:last-child { border-bottom: 1px solid var(--line); }
.task-item input { width: 1.1rem; height: 1.1rem; margin: 0; accent-color: var(--ink); }
.task-item label { min-width: 0; font-size: 17px; line-height: 1.35; overflow-wrap: anywhere; }
.task-item.done label { text-decoration: line-through; color: var(--muted); }
.task-item button, .schedule-item button { width: 2.75rem; height: 2.75rem; border: 0; border-radius: 6px; background: transparent; color: var(--muted); font-size: 1.2rem; }
.task-item button:hover, .schedule-item button:hover { color: var(--ink); }
.task-empty, .schedule-empty { padding: 24px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); color: var(--muted); font-size: 14px; margin: 0; }

/* ---------- tools ---------- */
.tool-grid { margin-top: 0; }
.tool-grid .rule-row:first-child { border-top: 0; }

/* ---------- schedule ---------- */
.schedule-form {
  display: grid; grid-template-columns: minmax(12rem, 1fr) minmax(12rem, 0.8fr) minmax(8rem, 0.55fr) auto;
  gap: 12px; align-items: end; margin: 20px 0 28px;
}
.schedule-form select { appearance: auto; }
.schedule-form .btn { min-height: 2.75rem; padding: 0 18px; }
.schedule-list-head { padding-top: 10px; border-top: 1.5px solid var(--ink); margin-bottom: 4px; }
.schedule-list { display: grid; padding-bottom: 32px; }
.schedule-item {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; align-items: center;
  padding: 12px 0; border-top: 1px solid var(--line);
}
.schedule-list-head + .schedule-list .schedule-item:first-child { border-top: 0; }
.schedule-item:last-child { border-bottom: 1px solid var(--line); }
.schedule-item > div { display: grid; gap: 2px; min-width: 0; }
.schedule-item strong { font-family: var(--serif); font-weight: 800; letter-spacing: -0.03em; font-size: 20px; line-height: 1.2; overflow-wrap: anywhere; }
.schedule-item small { color: var(--muted); font-size: 13px; }
.schedule-item .repeat { font-size: 11px; font-weight: 500; letter-spacing: 0.08em; text-transform: uppercase; }
/* a due item keeps the row alignment; its one accent mark is a dot before "Zamanı geldi" (as on the approval card) */
.schedule-item.due small:not(.repeat) { display: flex; align-items: center; gap: 8px; color: var(--accent); font-weight: 600; }
.schedule-item.due small:not(.repeat)::before { content: ""; flex: 0 0 7px; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

/* ---------- settings ---------- */
.settings-list { display: grid; }
.setting-row {
  width: 100%; min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 14px; align-items: center;
  padding: 14px 0; border: 0; border-top: 1px solid var(--line); border-radius: 0; background: none; text-align: left;
}
.settings-list .setting-row:first-child { border-top: 0; }
.setting-row:last-child { border-bottom: 1px solid var(--line); }
.setting-row div { display: grid; gap: 2px; min-width: 0; }
.setting-row strong { font-size: 17px; font-weight: 600; }
.setting-row small { color: var(--muted); font-size: 13px; line-height: 1.4; overflow-wrap: anywhere; }
.setting-row > span { font-size: 11px; font-weight: 500; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); white-space: nowrap; }
button.setting-row:hover > span { color: var(--ink); }
.connection-badge.ready { color: var(--ink); font-weight: 600; }
.connection-badge.offline { color: var(--accent); font-weight: 600; }
.setting-row.danger > span { color: var(--ink); font-weight: 600; }
.integration-head { margin-top: 36px; padding-top: 10px; border-top: 1.5px solid var(--ink); }
.integration-head h2 { font-family: var(--serif); font-weight: 800; letter-spacing: -0.03em; font-size: 28px; line-height: 1.1; }
.integration-head p { margin: 4px 0 6px; color: var(--muted); font-size: 14px; }
.integration-grid { display: grid; }
.integration-grid button {
  display: grid; grid-template-columns: 32px minmax(0, 1fr) auto; gap: 14px; align-items: center; width: 100%;
  padding: 14px 0; border: 0; border-top: 1px solid var(--line); background: none; text-align: left;
}
.integration-grid button:last-child { border-bottom: 1px solid var(--line); }
.integration-grid b { font-size: 12px; font-weight: 500; color: var(--muted); letter-spacing: 0.04em; }
.integration-grid span { display: grid; gap: 2px; min-width: 0; }
/* same row type as the settings list above (sans 17/600); the serif stays on the section title */
.integration-grid strong { font-size: 17px; font-weight: 600; line-height: 1.35; }
.integration-grid small { color: var(--muted); font-size: 13px; line-height: 1.4; }
.integration-grid em { font-style: normal; font-size: 11px; font-weight: 500; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }

/* =====================================================================
   chat · approval card · dialogs · command menu · notifications · toast · auth
   ===================================================================== */

/* ---------- chat ---------- */
.workspace { flex-direction: column; min-height: 0; flex: 1; }
/* the chat's one h1: a small head while messages show; the empty chat's welcome title replaces it */
.chat-head { flex: 0 0 auto; width: 100%; max-width: 46rem; margin: 0 auto; padding: 20px 24px 0; }
.chat-head h1 { font-size: 22px; line-height: 1.2; padding-bottom: 10px; border-bottom: 1.5px solid var(--ink); }
#chatView:has(.welcome) .chat-head { display: none; }
.messages {
  width: 100%; max-width: 46rem; min-height: 0; flex: 1; margin: 0 auto; overflow-y: auto; overflow-x: hidden;
  padding: 36px 24px 32px; display: flex; flex-direction: column; gap: 28px; scrollbar-width: thin;
}
.welcome { margin: auto 0; width: 100%; padding: 32px 0 16px; }
.welcome-mark { display: grid; place-items: center; width: 2.5rem; height: 2.5rem; margin: 0 0 22px; border-radius: 6px; background: var(--ink); color: var(--bg); font-family: var(--serif); font-weight: 800; font-size: 1.3rem; }
.welcome h1 { font-size: clamp(36px, 5vw, 56px); line-height: 1; padding-bottom: 16px; border-bottom: 1.5px solid var(--ink); }
.welcome p { max-width: 34rem; margin: 14px 0 22px; color: var(--muted); font-size: 15px; line-height: 1.6; }
.suggestions { display: flex; flex-wrap: wrap; gap: 8px; }
.suggestions button { min-height: 2.5rem; padding: 7px 14px; border: 1px solid var(--line); border-radius: 6px; background: transparent; font-size: 13px; font-weight: 500; }
.suggestions button:hover { border-color: var(--ink); }

/* a message is a label (KANKA / SEN) over its text; avatars stay in the DOM but are not shown */
.message { display: flex; width: 100%; min-width: 0; }
.avatar { display: none; }
.message > div:last-child { min-width: 0; width: 100%; display: flex; flex-direction: column; align-items: flex-start; }
.message > div:last-child > span { display: block; margin-bottom: 6px; font-size: 11px; font-weight: 500; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.message p { max-width: 100%; font-size: 16px; line-height: 1.7; white-space: pre-wrap; overflow-wrap: anywhere; }
/* Kanka: plain reading text on the page background */
.message.assistant p { color: var(--ink); }
.message.assistant > div:last-child > span { color: var(--ink); font-weight: 600; }
/* you: a right-aligned paper block */
.message.user { justify-content: flex-end; }
.message.user > div:last-child { width: auto; max-width: min(36rem, 88%); align-items: flex-end; }
.message.user p { padding: 10px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--paper); font-size: 15px; line-height: 1.6; }
.message.loading p { color: var(--muted); }
.message.loading p::after { content: "…"; margin-left: 2px; }
.message > div:last-child > span.typing-stage { display: inline-flex; align-items: center; gap: 6px; }
.typing-stage::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: kanka-pulse 1s ease-in-out infinite; }
@keyframes kanka-pulse { 50% { opacity: 0.3; } }

.message-attachment { display: grid; gap: 6px; margin-bottom: 8px; }
.message-attachment img { display: block; width: min(17rem, 70vw); max-height: 18rem; object-fit: cover; border: 1px solid var(--line); border-radius: 6px; }
.message-attachment small { max-width: 17rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 12px; }
.message.user .message-attachment { justify-items: end; }
.message-file { width: min(20rem, 100%); display: grid; grid-template-columns: 2.5rem minmax(0, 1fr); align-items: center; gap: 10px; margin-bottom: 8px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; }
.message-file > span, .file-icon { display: grid; place-items: center; margin: 0; border: 1px solid var(--line); border-radius: 6px; color: var(--muted); font-size: 11px; font-weight: 600; letter-spacing: 0.06em; }
.message-file > span { width: 2.5rem; height: 2.5rem; }
.message-file div { display: grid; gap: 2px; min-width: 0; }
.message-file strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; font-weight: 500; }
.message-file small { color: var(--muted); font-size: 12px; }

/* composer: one hairline box, ink send button; 43rem = the message column (46rem) minus its 24px gutters, so edges line up */
.composer-wrap { flex: 0 0 auto; padding: 8px 24px max(14px, env(safe-area-inset-bottom)); background: var(--bg); }
.attachment-preview { width: 100%; max-width: 43rem; margin: 0 auto 8px; padding: 6px 6px 6px 8px; display: grid; grid-template-columns: 3rem minmax(0, 1fr) 2.75rem; align-items: center; gap: 12px; border: 1px solid var(--line); border-radius: 6px; }
.attachment-preview[hidden], .file-icon[hidden], .attachment-preview img[hidden] { display: none; }
.attachment-preview img, .file-icon { width: 3rem; height: 3rem; object-fit: cover; border-radius: 6px; }
.attachment-preview div { min-width: 0; display: grid; gap: 2px; }
.attachment-preview strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; font-weight: 500; }
.attachment-preview small { font-size: 11px; font-weight: 500; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.attachment-preview button { width: 2.75rem; height: 2.75rem; border: 0; border-radius: 6px; background: transparent; color: var(--muted); font-size: 1.3rem; }
.attachment-preview button:hover { color: var(--ink); }
.composer { width: 100%; max-width: 43rem; margin: 0 auto; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: end; gap: 6px; padding: 6px; border: 1px solid var(--line); border-radius: 6px; background: var(--paper); }
/* focus is shown by the textarea ring; no second (ink) frame on the composer */
.composer textarea { width: 100%; min-height: 2.5rem; max-height: 8.75rem; padding: 9px 6px; border: 0; border-radius: 4px; resize: none; background: transparent; color: var(--ink); font-size: 15px; line-height: 1.45; }
.composer textarea::placeholder, input::placeholder, textarea::placeholder { color: var(--muted); opacity: 1; }
.attach-button { width: 2.5rem; height: 2.5rem; display: grid; place-items: center; border-radius: 6px; color: var(--muted); font-size: 1.15rem; cursor: pointer; }
.attach-button:hover { color: var(--ink); }
/* the file input is visually hidden; its label carries the focus ring */
#imageInput:focus-visible + .attach-button { outline: 2px solid var(--focus); outline-offset: 2px; color: var(--ink); }
.composer button { width: 2.5rem; height: 2.5rem; border: 1px solid var(--ink); border-radius: 6px; background: var(--ink); color: var(--bg); font-size: 1.05rem; font-weight: 600; }
.composer button:disabled { opacity: 0.45; cursor: wait; }
.privacy { margin: 8px auto 0; text-align: center; color: var(--muted); font-size: 12px; }

/* ---------- approval card: hairline block, small label, one accent mark ---------- */
.approval-card { width: 100%; max-width: 36rem; display: block; padding: 14px 16px 16px; border: 1px solid var(--line); border-radius: 6px; }
.approval-icon { display: none; }
.approval-card > div:last-child > span { display: flex; align-items: center; gap: 8px; color: var(--accent); font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; }
.approval-card > div:last-child > span::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.approval-card strong { display: block; margin: 8px 0 2px; font-family: var(--serif); font-weight: 800; letter-spacing: -0.03em; font-size: 22px; line-height: 1.2; overflow-wrap: anywhere; }
.approval-card p { color: var(--muted); font-size: 14px; overflow-wrap: anywhere; }
.approval-card > div:last-child > div { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.approval-card button { min-height: 2.5rem; padding: 0 14px; border: 1px solid var(--line); border-radius: 6px; background: transparent; font-size: 13px; font-weight: 500; }
.approval-card button:hover { border-color: var(--ink); }
.approval-card button[data-approve] { border-color: var(--ink); background: var(--ink); color: var(--bg); }
.approval-card.resolved > div:last-child > span { color: var(--muted); }

/* ---------- dialogs: paper, one hairline, no shadow ---------- */
dialog { width: min(32rem, calc(100% - 32px)); max-height: calc(100dvh - 32px); padding: 0; overflow: auto; box-shadow: none; }
dialog::backdrop { background: var(--scrim); }
.dialog-card { padding: 22px 24px 24px; }
.dialog-head { display: flex; justify-content: space-between; align-items: end; gap: 12px; padding-bottom: 12px; margin-bottom: 6px; border-bottom: 1.5px solid var(--ink); }
.dialog-head h2 { font-family: var(--serif); font-weight: 800; letter-spacing: -0.03em; font-size: 28px; line-height: 1.05; }
.eyebrow { margin-bottom: 6px; }
.close { width: 2.5rem; height: 2.5rem; margin: 0 -8px -4px 0; border: 0; border-radius: 6px; background: transparent; color: var(--muted); font-size: 1.6rem; line-height: 1; }
.close:hover { color: var(--ink); }
.dialog-card label { display: grid; gap: 6px; margin: 14px 0 0; font-size: 11px; font-weight: 500; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.dialog-card textarea { resize: vertical; line-height: 1.5; }
.dialog-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-top: 22px; }
.dialog-actions.spread { display: grid; grid-template-columns: auto 1fr auto auto; }
.danger-text { border-color: transparent; padding-left: 0; padding-right: 0; color: var(--ink); font-weight: 600; text-decoration: underline; text-underline-offset: 4px; }
.dialog-card > small { display: block; margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; line-height: 1.45; }

/* ---------- command menu: opens near the top ---------- */
.command-dialog { width: min(36rem, calc(100% - 32px)); margin: 12vh auto auto; }
.command-box { padding: 0; }
.command-search { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1.5px solid var(--ink); color: var(--muted); }
.command-search input { min-width: 0; min-height: 2.75rem; padding: 0 6px; border: 0; border-radius: 4px; background: transparent; color: var(--ink); font-size: 16px; }
.command-search kbd { padding: 2px 6px; border: 1px solid var(--line); border-radius: 4px; color: var(--muted); font: 500 11px var(--sans); letter-spacing: 0.06em; }
.command-list { padding: 0 14px; max-height: min(22rem, 60dvh); overflow: auto; }
.command-list .sidebar-empty { padding: 14px 0; }
.command-item { width: 100%; min-height: 2.75rem; display: grid; grid-template-columns: 1.75rem minmax(0, 1fr) auto; align-items: center; gap: 8px; padding: 6px 0; border: 0; border-top: 1px solid var(--line); border-radius: 0; background: transparent; text-align: left; font-size: 14px; }
.command-item:first-child { border-top: 0; }
.command-item span { color: var(--muted); text-align: center; }
.command-item::after { content: "→"; color: transparent; }
.command-item:hover, .command-item.selected { font-weight: 600; }
.command-item:hover::after, .command-item.selected::after { color: var(--ink); }

/* ---------- notification panel ---------- */
.notification-panel { position: fixed; z-index: 12; right: 28px; top: calc(var(--topbar) + 8px); width: min(22rem, calc(100% - 32px)); max-height: calc(100dvh - var(--topbar) - 24px); overflow: auto; padding: 12px 16px 6px; }
.notification-panel[hidden] { display: none; }
.notification-panel > div:first-child { display: flex; justify-content: space-between; align-items: center; padding-bottom: 8px; border-bottom: 1.5px solid var(--ink); }
.notification-panel > div:first-child strong { font-size: 11px; font-weight: 500; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.notification-panel #clearNotifications { min-height: 2.25rem; padding: 0; border: 0; background: transparent; color: var(--ink); font-size: 13px; text-decoration: underline; text-underline-offset: 3px; }
.notification-panel .enable-push { width: 100%; min-height: 2.5rem; margin: 12px 0 4px; border: 1px solid var(--line); border-radius: 6px; background: transparent; color: var(--ink); font-size: 13px; font-weight: 500; }
.notification-panel .enable-push:hover:not(:disabled) { border-color: var(--ink); }
.notification-panel .enable-push:disabled { color: var(--muted); cursor: default; }
.notification-panel p { padding: 10px 0; color: var(--muted); font-size: 14px; }
.notice { padding: 10px 0; border-top: 1px solid var(--line); }
#notificationList .notice:first-child { border-top: 0; }
.notice strong, .notice small { display: block; overflow-wrap: anywhere; }
.notice strong { font-weight: 500; font-size: 14px; }
.notice small { margin-top: 2px; color: var(--muted); font-size: 12px; }

/* ---------- toast ---------- */
.toast { position: fixed; left: 50%; bottom: max(16px, env(safe-area-inset-bottom)); z-index: 30; transform: translate(-50%, 6rem); max-width: calc(100% - 32px); padding: 10px 16px; border: 1px solid var(--ink); border-radius: 6px; background: var(--ink); color: var(--bg); font-size: 14px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; opacity: 0; transition: transform 0.25s ease, opacity 0.25s ease; pointer-events: none; }
.toast.show { transform: translate(-50%, 0); opacity: 1; }
/* dark: a paper toast, not an inverted light slab (which turned a pale grey under a dialog scrim) */
[data-theme="dark"] .toast { border-color: var(--line); background: var(--paper); color: var(--ink); }
@media (prefers-color-scheme: dark) { :root:not([data-theme]) .toast { border-color: var(--line); background: var(--paper); color: var(--ink); } }
/* in chat the toast sits above the composer instead of covering it */
body[data-view="chat"] .toast { bottom: calc(max(16px, env(safe-area-inset-bottom)) + 4.5rem); }

/* ---------- auth screen: same structure as the Arena login ---------- */
.auth-screen {
  position: fixed; inset: 0; z-index: 1000; overflow: auto; background: var(--bg);
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-content: center;
  padding: 0 max(0px, calc((100% - 960px) / 2));
}
.auth-screen[hidden] { display: none; }
.auth-brand { display: flex; flex-direction: column; justify-content: center; gap: 10px; padding: 48px; min-width: 0; }
.auth-brand .brand { margin-bottom: 18px; }
.auth-brand .display { font-size: clamp(56px, 8vw, 88px); line-height: 0.95; }
.auth-brand .muted { max-width: 24rem; font-size: 15px; line-height: 1.55; }
.auth-form-wrap { display: flex; align-items: center; justify-content: center; padding: 32px; min-width: 0; }
.auth-card { width: 100%; max-width: 360px; padding: 24px; }
.auth-card h2 { font-family: var(--serif); font-weight: 800; letter-spacing: -0.03em; font-size: 24px; line-height: 1.15; }
.auth-card #authCopy { margin: 6px 0 14px; color: var(--muted); font-size: 14px; line-height: 1.5; }
.auth-card .field { margin-bottom: 12px; }
.auth-card .field[hidden] { display: none; }
.auth-card .btn { width: 100%; min-height: 2.75rem; margin-top: 4px; font-size: 14px; }
.auth-card > small { display: block; margin-top: 12px; color: var(--muted); font-size: 12px; }
.auth-error { color: var(--ink); font-size: 13px; font-weight: 500; }
.auth-error:empty { margin: 0; }
.auth-error:not(:empty) { margin: 0 0 12px; padding-left: 10px; border-left: 2px solid var(--ink); }

/* ---------- responsive ---------- */
/* drawer sidebar at ≤ 900 px */
@media (max-width: 900px) {
  .sidebar {
    position: fixed; inset: 0 auto 0 0; z-index: 20; width: min(18rem, 86vw); height: 100dvh;
    padding-bottom: max(14px, env(safe-area-inset-bottom));
    transform: translateX(-102%); overscroll-behavior: contain;
    /* closed drawer: off-canvas and out of the tab order (visibility flips after the slide) */
    visibility: hidden; transition: transform 0.22s ease, visibility 0s linear 0.22s;
  }
  .sidebar.open { transform: translateX(0); visibility: visible; transition: transform 0.22s ease; }
  .sidebar-head, .sidebar-new, .main-nav, .sidebar-section, .sidebar-bottom { flex-shrink: 0; }
  .menu-overlay { display: block; position: fixed; inset: 0; z-index: 19; border: 0; background: var(--scrim); opacity: 0; pointer-events: none; visibility: hidden; transition: opacity 0.22s, visibility 0s linear 0.22s; }
  .menu-open .menu-overlay { opacity: 1; pointer-events: auto; visibility: visible; transition: opacity 0.22s; }
  .menu-button { display: grid; }
  .topbar .brand { display: inline-flex; }
  .topbar { padding: 0 16px; }
  .notification-panel { right: 16px; } /* panel edge follows the topbar gutter */
}
@media (min-width: 901px) {
  .sidebar-close { display: none; }
}
@media (max-width: 767px) {
  .command-trigger, .header-actions .status, #chatOptions { display: none; }
  .new-chat { width: 2.75rem; padding: 0; }
  .new-chat b { display: none; }
  body[data-view="home"] #clearButton { display: none; }
  .top-icon { min-width: 2.75rem; height: 2.75rem; }
  .page-view { padding: 22px 16px 40px; }
  .page-head, .home-hero { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .display { font-size: 40px; line-height: 1; }
  .home-primary { justify-self: start; }
  .quick-section { grid-template-columns: minmax(0, 1fr); }
  .rule-row, .integration-grid button { grid-template-columns: 28px minmax(0, 1fr) auto; gap: 10px; }
  .task-item { grid-template-columns: 28px minmax(0, 1fr) auto; gap: 10px; }
  .rule-body strong { font-size: 20px; }
  .schedule-form { grid-template-columns: minmax(0, 1fr); }
  .schedule-form .btn { justify-self: start; }
  .chat-head { padding: 14px 16px 0; }
  .chat-head h1 { font-size: 20px; padding-bottom: 8px; }
  .messages { padding: 22px 16px 24px; gap: 24px; }
  .message.user > div:last-child { max-width: 92%; }
  .message p { font-size: 15px; }
  .composer-wrap { padding: 6px 16px 10px; }
  .privacy { display: none; }
  .notification-panel { left: 16px; right: 16px; width: auto; }
  .command-dialog { margin-top: 10vh; }
  .auth-screen { grid-template-columns: minmax(0, 1fr); align-content: start; }
  .auth-brand { padding: 40px 20px 8px; gap: 8px; }
  .auth-brand .brand { margin-bottom: 10px; }
  .auth-brand .display { font-size: 56px; }
  .auth-form-wrap { padding: 16px 16px 32px; }
  .auth-card { max-width: none; padding: 20px; }
  .dialog-card { padding: 18px 16px 20px; }
  .dialog-head h2 { font-size: 24px; }
  .dialog-actions.spread { grid-template-columns: auto 1fr; }
  .dialog-actions.spread > span { display: none; }
  /* on-screen keyboard (app.js sets body.keyboard-open, --visual-height, --keyboard-offset) */
  .keyboard-open .messages { padding-bottom: 6.25rem; scroll-padding-block: 1rem 6.25rem; overscroll-behavior: contain; touch-action: pan-y; }
  .keyboard-open .composer-wrap { position: fixed; left: 0; right: 0; bottom: calc(var(--keyboard-offset, 0px) + 0.625rem); z-index: 60; padding: 6px 16px max(6px, env(safe-area-inset-bottom)); background: var(--bg); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
