*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; overflow: hidden; }

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: #f7f6f3;
  color: #111;
  display: flex;
  flex-direction: column;
}

/* ── App shell ──────────────────────────────────────────────── */

#app {
  display: flex;
  flex: 1;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

/* ── Left sidebar ───────────────────────────────────────────── */

#sidebar {
  width: 240px;
  flex-shrink: 0;
  background: #ebebeb;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width 0.2s ease;
  border-right: 1px solid #d5d5d5;
}

#sidebar.collapsed { width: 52px; }
#sidebar.collapsed .sidebar-top    { justify-content: center; padding-left: 0; padding-right: 0; }
#sidebar.collapsed .sidebar-brand  { display: none; }
#sidebar.collapsed .sidebar-nav    { padding-left: 0; padding-right: 0; }
#sidebar.collapsed .sidebar-library { padding-left: 0; padding-right: 0; }
#sidebar.collapsed .sidebar-footer { padding-left: 0; padding-right: 0; }

.sidebar-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 0.75rem 0.6rem;
  flex-shrink: 0;
  min-width: 0;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  overflow: hidden;
}

.logo-mark {
  color: #0e1f3d;
  flex-shrink: 0;
  opacity: 1;
  display: block;
}

.logo-wordmark {
  font-family: 'Raleway', sans-serif;
  font-size: 0.76rem;
  font-weight: 600;
  color: #0e1f3d;
  letter-spacing: 0.2em;
}

#sidebar-toggle {
  background: none;
  border: none;
  color: rgba(14,31,61,0.3);
  cursor: pointer;
  padding: 0.2rem;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: color 0.15s, transform 0.2s ease;
}
#sidebar-toggle:hover { color: rgba(14,31,61,0.7); background: none; }
#sidebar.collapsed #sidebar-toggle { transform: rotate(180deg); }

/* Hide labels when collapsed */
.sidebar-label {
  white-space: nowrap;
  overflow: hidden;
  transition: opacity 0.15s, max-width 0.2s;
  max-width: 160px;
}
#sidebar.collapsed .sidebar-label {
  opacity: 0;
  max-width: 0;
  pointer-events: none;
}

.create-btn {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin: 0.25rem 0.6rem 0.5rem;
  padding: 0.48rem 0.7rem;
  background: none;
  border: none;
  border-radius: 8px;
  color: rgba(14,31,61,0.7);
  font-size: 0.81rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
}
.create-btn:hover { background: rgba(14,31,61,0.06); color: #0e1f3d; }
#sidebar.collapsed .create-btn { justify-content: center; padding: 0.48rem 0; margin: 0.25rem 0 0.6rem; gap: 0; }

.sidebar-nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.08rem;
  padding: 0.15rem 0.5rem;
  overflow-y: auto;
  overflow-x: hidden;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.52rem 0.7rem;
  border: none;
  border-radius: 7px;
  background: none;
  color: rgba(14,31,61,0.45);
  font-size: 0.83rem;
  font-family: inherit;
  cursor: pointer;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
  flex-shrink: 0;
  width: 100%;
}
.nav-item:hover { background: rgba(14,31,61,0.05); color: rgba(14,31,61,0.8); }
.nav-item.active { background: rgba(14,31,61,0.07); color: #0e1f3d; font-weight: 600; }
.nav-item svg { flex-shrink: 0; }
#sidebar.collapsed .nav-item { justify-content: center; padding: 0.52rem 0; gap: 0; }

/* Sidebar workflow sub-items */
.sidebar-workflows { display: flex; flex-direction: column; gap: 0.08rem; padding: 0.1rem 0; }
.sidebar-workflow-item { font-size: 0.78rem; padding: 0.42rem 0.7rem 0.42rem 1.2rem; color: rgba(14,31,61,0.4); }
.sidebar-wf-icon { display: flex; align-items: center; flex-shrink: 0; }
.sidebar-wf-icon svg { width: 15px; height: 15px; }
.sidebar-workflow-item.active { color: #0e1f3d; background: rgba(14,31,61,0.07); font-weight: 600; }
#sidebar.collapsed .sidebar-workflow-item { justify-content: center; padding: 0.42rem 0; gap: 0; }
.sidebar-tools-divider { font-size: 0.65rem; font-weight: 600; letter-spacing: 0.07em; text-transform: uppercase; color: rgba(14,31,61,0.28); padding: 0.8rem 1.2rem 0.3rem; }
#sidebar.collapsed .sidebar-tools-divider { display: none; }
.sidebar-tool-item { padding-left: 0.85rem; }

/* ── Vertical phase stepper ───────────────────────────────── */
.phase-track { display: flex; flex-direction: column; padding: 0.5rem 0 0.2rem; }
.phase-track-item { display: flex; align-items: center; gap: 0.7rem; background: none; border: none; cursor: pointer; padding: 0.28rem 0.7rem 0.28rem 0.85rem; text-align: left; width: 100%; transition: background 0.12s; }
.phase-track-item:hover { background: rgba(14,31,61,0.04); }
.phase-track-icon { display: flex; align-items: center; flex-shrink: 0; color: rgba(14,31,61,0.3); transition: color 0.15s; }
.phase-track-icon svg { width: 15px; height: 15px; }
.phase-track-connector { width: 1.5px; height: 12px; background: rgba(14,31,61,0.12); margin-left: calc(0.85rem + 7px); }
.phase-track-label { font-size: 0.78rem; color: rgba(14,31,61,0.4); transition: color 0.15s; }
.phase-track-item.active .phase-track-icon { color: #0e1f3d; }
.phase-track-item.active .phase-track-label { color: #0e1f3d; font-weight: 600; }
.phase-track-item:hover .phase-track-icon { color: rgba(14,31,61,0.6); }
#sidebar.collapsed .phase-track-item { justify-content: center; padding: 0.28rem 0; }
#sidebar.collapsed .phase-track-label { display: none; }
#sidebar.collapsed .phase-track-connector { margin-left: calc(50% - 0.75px); }


.sidebar-spacer {
  flex: 1;
}

.sidebar-library {
  flex-shrink: 0;
  padding: 0.25rem 0.5rem 0.75rem;
  max-height: 50%;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(14,31,61,0.1) transparent;
}

.sidebar-footer {
  flex-shrink: 0;
  padding: 0.5rem;
  border-top: 1px solid #d5d5d5;
}

.avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #0e1f3d;
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  letter-spacing: 0.02em;
}

/* ── Main area ──────────────────────────────────────────────── */

#main-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

/* ── Top bar ────────────────────────────────────────────────── */

#topbar {
  height: 48px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0 1rem;
  background: #fff;
  border-bottom: 1px solid #e0ddd8;
}

.topbar-left { flex-shrink: 0; }

.topbar-workflow-id {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  color: #0e1f3d;
}

.topbar-workflow-star {
  color: #c8102e;
  font-size: 0.6rem;
  line-height: 1;
}

.topbar-nautilus {
  font-family: 'Raleway', sans-serif;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: #0e1f3d;
}

#topbar-workflow-label {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 0.82rem;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  color: #0e1f3d;
}


.topbar-center {
  flex: 1;
  display: flex;
  justify-content: center;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  flex-shrink: 0;
}

.topbar-link {
  background: none;
  border: none;
  font-size: 0.8rem;
  color: #999;
  font-family: inherit;
  cursor: pointer;
  padding: 0.25rem 0.45rem;
  border-radius: 4px;
  transition: color 0.12s;
}
.topbar-link:hover { color: #111; background: #eeece8; }
.topbar-matter-summary { color: #0e1f3d; font-weight: 600; }
.topbar-matter-summary:hover { background: rgba(14,31,61,0.08); }

/* Hide chat panel on chatless phases */
body.phase-chatless #chat-panel { display: none !important; }

/* Thread regenerate bar */
.thread-regen-bar { display: flex; align-items: center; justify-content: space-between; padding: 0.45rem 1rem 0.45rem 1.1rem; border-bottom: 1px solid #e8e5e0; background: #f8f7f5; gap: 0.75rem; flex-shrink: 0; }
.thread-regen-label { font-size: 0.72rem; color: rgba(14,31,61,0.45); letter-spacing: 0.02em; }
.thread-regen-btn { display: inline-flex; align-items: center; gap: 0.35rem; font-size: 0.72rem; font-weight: 600; color: #0e1f3d; background: none; border: 1px solid rgba(14,31,61,0.22); border-radius: 4px; padding: 0.28rem 0.65rem; cursor: pointer; transition: background 0.12s, border-color 0.12s; }
.thread-regen-btn:hover { background: rgba(14,31,61,0.06); border-color: rgba(14,31,61,0.4); }
.draft-regen-btn { border: none; font-size: 0.7rem; padding: 0.2rem 0.5rem; }

.analytics-btn {
  background: none;
  border: none;
  color: #999;
  padding: 0.25rem 0.45rem;
  font-size: 0.8rem;
  font-family: inherit;
  cursor: pointer;
  border-radius: 4px;
  transition: color 0.12s, background 0.12s;
}
.analytics-btn:hover { color: #111; background: #eeece8; }

/* ── Language selector ──────────────────────────────────────── */

.lang-dropdown {
  position: relative;
  margin-left: 0.4rem;
}
.lang-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: 1px solid transparent;
  border-radius: 5px;
  padding: 0.25rem 0.35rem;
  cursor: pointer;
  line-height: 1;
  transition: border-color 0.15s, background 0.15s;
}
.lang-code {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: #444;
}
.lang-btn:hover {
  border-color: #d5d2cc;
  background: #f5f4f1;
}
.lang-menu {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: #fff;
  border: 1px solid #e0ddd8;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.10);
  padding: 0.3rem;
  min-width: 140px;
  z-index: 200;
}
.lang-menu.open { display: block; }
.lang-option {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  width: 100%;
  background: none;
  border: none;
  border-radius: 5px;
  padding: 0.45rem 0.6rem;
  cursor: pointer;
  font-size: 0.82rem;
  color: #333;
  text-align: left;
  white-space: nowrap;
  transition: background 0.12s;
}

.lang-option:hover { background: #f5f4f1; }
.lang-option.active { background: #eef0f7; font-weight: 500; color: #0e1f3d; }

@media (max-width: 640px) {
  .lang-dropdown { display: none; }
}

/* ── Domain toggle ──────────────────────────────────────────── */

.domain-toggle {
  display: flex;
  border: 1px solid #d5d2cc;
  border-radius: 6px;
  overflow: hidden;
}
.domain-btn {
  background: none;
  border: none;
  color: #888;
  padding: 0.28rem 0.8rem;
  font-size: 0.78rem;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}
.domain-btn + .domain-btn { border-left: 1px solid #d5d2cc; }
.domain-btn:hover  { color: #111; background: #f5f3ef; }
.domain-btn.active { color: #0e1f3d; background: #e5ecf8; font-weight: 600; }

/* ── Workspace ──────────────────────────────────────────────── */

#workspace {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  padding: 0;
  gap: 0;
  margin: 0;
  border: none;
}

/* ── Workspace panels (3-pane collapsible layout) ───────────── */

.workspace-panel {
  display: flex;
  flex-direction: row;
  overflow: hidden;
  transition: flex 0.2s ease;
  min-width: 0;
}

.workspace-panel.panel-collapsed { flex: 0 0 36px !important; }

/* Collapsed strip: hidden by default, grows to 36px when panel collapses */
.panel-collapsed-strip {
  flex: 0 0 0px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  cursor: pointer;
  transition: flex 0.2s ease;
  background: #fff;
  border-right: 1px solid #d5d2cc;
  color: #c0bdba;
}
.workspace-panel.panel-collapsed .panel-collapsed-strip {
  flex: 0 0 36px;
}
.panel-collapsed-strip:hover { color: #888; background: #fafaf8; }

.panel-strip-label {
  writing-mode: vertical-rl;
  text-orientation: mixed;
  transform: rotate(180deg);
  font-size: 0.6rem;
  font-weight: 700;
  color: inherit;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

/* Panel main: inner column container */
.panel-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
  transition: flex 0.2s ease;
}
.workspace-panel.panel-collapsed .panel-main { flex: 0 0 0px; }

/* Panel collapse/expand buttons */
.panel-collapse-btn {
  background: none;
  border: none;
  color: #ccc;
  padding: 0.2rem 0.3rem;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.12s, background 0.12s;
  flex-shrink: 0;
}
.panel-collapse-btn:hover { color: #555; background: #f0ede8; }

#pane-toggles {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}
.pane-toggle-btn {
  background: none;
  border: none;
  color: #aaa;
  padding: 0.25rem 0.65rem;
  border-radius: 5px;
  font-size: 0.78rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
  position: relative;
}
.pane-toggle-btn::after {
  content: '';
  display: block;
  height: 2px;
  border-radius: 1px;
  background: #0e1f3d;
  position: absolute;
  bottom: 2px;
  left: 0.65rem;
  right: 0.65rem;
  transform: scaleX(0);
  transition: transform 0.15s;
}
.pane-toggle-btn:hover { color: #555; background: #f4f2ef; }
.pane-toggle-btn.active { color: #0e1f3d; font-weight: 600; background: none; }
.pane-toggle-btn.active::after { transform: scaleX(1); }


/* ── Chat panel ─────────────────────────────────────────────── */

#chat-panel { flex: 1 1 0; }

#chat-panel .panel-main {
  background: #fff;
  border: none;
  overflow: hidden;
  position: relative;
}

/* Chat collapse button: absolute top-right, visible in chat mode */
.chat-collapse-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 5;
  display: none;
}
body.chatting-active #chat-main .chat-collapse-btn { display: flex; }

#messages {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-height: 0;
}

.msg {
  display: flex;
  flex-direction: column;
  max-width: 88%;
}

.msg-user      { align-self: flex-end; }
.msg-assistant { align-self: flex-start; }

.msg-label {
  font-size: 0.67rem;
  font-weight: 600;
  color: #999;
  margin-bottom: 0.2rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.msg-content {
  padding: 0.75rem 1rem;
  border-radius: 8px;
  font-size: 0.875rem;
  line-height: 1.6;
}

.msg-user .msg-content {
  background: #eeecf0;
  color: #111;
  border-bottom-right-radius: 3px;
}

.msg-assistant .msg-content {
  background: #eeecf0;
  color: #111;
  border-bottom-left-radius: 3px;
}

/* Markdown in AI messages */
.msg-assistant .msg-content h1,
.msg-assistant .msg-content h2,
.msg-assistant .msg-content h3 {
  font-size: 0.92rem;
  font-weight: 700;
  margin: 0.8rem 0 0.3rem;
}
.msg-assistant .msg-content h1:first-child,
.msg-assistant .msg-content h2:first-child,
.msg-assistant .msg-content h3:first-child { margin-top: 0; }
.msg-assistant .msg-content p { margin-bottom: 0.5rem; }
.msg-assistant .msg-content p:last-child { margin-bottom: 0; }
.msg-assistant .msg-content ul,
.msg-assistant .msg-content ol { padding-left: 1.25rem; margin-bottom: 0.5rem; }
.msg-assistant .msg-content li { margin-bottom: 0.2rem; }
.msg-assistant .msg-content strong { font-weight: 600; }

/* Typing indicator */
.msg-typing {
  display: flex;
  gap: 0.35rem;
  align-items: center;
  min-height: 2rem;
}

.dot {
  width: 6px;
  height: 6px;
  background: #bbb;
  border-radius: 50%;
  animation: bounce 1.2s infinite ease-in-out;
}
.dot:nth-child(2) { animation-delay: 0.2s; }
.dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.6; }
  40%            { transform: translateY(-5px); opacity: 1; }
}

/* Chat form */
#chat-form {
  flex: none;
  border-top: 1px solid #e0ddd8;
  padding: 0.75rem;
  background: #f9f8f5;
}

#chat-form textarea {
  display: block;
  width: 100%;
  padding: 0.55rem 0.75rem;
  font-size: 0.875rem;
  border: 1px solid #ccc;
  border-radius: 6px;
  resize: none;
  font-family: inherit;
  background: #fff;
  margin-bottom: 0.5rem;
}

#chat-form textarea:focus {
  outline: none;
  border-color: #1c3d7a;
}

.form-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

#status {
  font-size: 0.8rem;
  color: #888;
}

button {
  padding: 0.45rem 1.25rem;
  font-size: 0.875rem;
  font-weight: 600;
  background: #1c3d7a;
  color: #fff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
}

button:hover    { background: #163162; }
button:disabled { background: #aaa; cursor: not-allowed; }

/* ── Draft panel ─────────────────────────────────────────────── */

#draft-panel { flex: 1 1 0; }

#draft-panel .panel-main {
  background: #fff;
  border-right: 1px solid #d5d2cc;
  overflow: hidden;
}

.draft-panel-header {
  display: flex;
  align-items: center;
  padding: 0 0.75rem;
  border-bottom: 1px solid #e0ddd8;
  background: #fafaf8;
  flex-shrink: 0;
  gap: 0.5rem;
  height: 38px;
}

.draft-panel-title {
  font-size: 0.78rem;
  font-weight: 600;
  color: #666;
}

.draft-doc-type-tag {
  font-size: 0.72rem;
  color: #1c3d7a;
  background: #e5ecf8;
  padding: 0.1rem 0.45rem;
  border-radius: 4px;
  font-weight: 500;
}
.draft-doc-type-tag:empty { display: none; }

.draft-header-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.15rem;
}

/* Draft setup screen */
#draft-setup {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1.5rem 1rem 2rem;
}
#draft-panel.draft-active #draft-setup { display: none; }

.draft-setup-inner {
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
}

.draft-setup-icon { color: #1c3d7a; opacity: 0.5; }

.draft-setup-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: #111;
  margin: 0;
}

.draft-setup-sub {
  font-size: 0.82rem;
  color: #999;
  margin: -0.75rem 0 0;
}

.draft-setup-section {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.draft-setup-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #aaa;
}

.draft-type-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.draft-type-pill {
  background: none;
  border: 1px solid #d5d2cc;
  color: #666;
  font-size: 0.78rem;
  font-weight: 400;
  font-family: inherit;
  padding: 0.28rem 0.65rem;
  border-radius: 99px;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.draft-type-pill:hover { background: #eeece8; color: #111; border-color: #bbb; }
.draft-type-pill.active { background: #e5ecf8; border-color: #1c3d7a; color: #1c3d7a; font-weight: 500; }

.draft-type-input {
  width: 100%;
  padding: 0.45rem 0.7rem;
  font-family: inherit;
  font-size: 0.83rem;
  border: 1px solid #d5d2cc;
  border-radius: 7px;
  background: #fff;
  color: #111;
  outline: none;
  transition: border-color 0.15s;
  box-sizing: border-box;
}
.draft-type-input:focus { border-color: #1c3d7a; }
.draft-type-input::placeholder { color: #ccc; }

.draft-tpl-opts {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.draft-tpl-opt {
  display: flex;
  flex-direction: column;
  gap: 0.08rem;
  padding: 0.5rem 0.65rem;
  border: 1px solid #d5d2cc;
  border-radius: 7px;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
}
.draft-tpl-opt:hover { border-color: #aaa; background: #fafaf8; }
.draft-tpl-opt.draft-tpl-selected { border-color: #1c3d7a; background: #f0f4fb; cursor: default; }
.draft-tpl-opt.draft-tpl-soon { opacity: 0.4; cursor: default; }
.draft-tpl-opt.draft-tpl-soon:hover { border-color: #d5d2cc; background: none; }

.draft-tpl-name {
  font-size: 0.82rem;
  font-weight: 500;
  color: #333;
}
.draft-tpl-opt.draft-tpl-selected .draft-tpl-name { color: #1c3d7a; }

.draft-tpl-desc { font-size: 0.72rem; color: #aaa; }

.draft-generate-btn {
  background: #1c3d7a;
  color: #fff;
  border: none;
  padding: 0.6rem 1.25rem;
  border-radius: 7px;
  font-size: 0.85rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.12s;
  width: 100%;
}
.draft-generate-btn:hover { background: #163162; }

.draft-upload-zone {
  border: 1.5px dashed #d5d2cc;
  border-radius: 8px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  color: #aaa;
  text-align: center;
}
.draft-upload-zone:hover,
.draft-upload-zone.drag-over { border-color: #1c3d7a; background: #f5f7fc; color: #1c3d7a; }
.draft-upload-text { font-size: 0.8rem; }
.draft-upload-browse { color: #1c3d7a; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.draft-upload-hint { font-size: 0.69rem; color: #ccc; }
#draft-file-input { display: none; }

.draft-upload-list {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin-top: 0.4rem;
}
.draft-upload-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.55rem;
  background: #f5f7fc;
  border: 1px solid #d5e0f0;
  border-radius: 6px;
  font-size: 0.78rem;
  color: #1c3d7a;
}
.draft-upload-item-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.draft-upload-remove {
  background: none;
  border: none;
  color: #aaa;
  cursor: pointer;
  padding: 0;
  font-size: 0.75rem;
  line-height: 1;
  flex-shrink: 0;
}
.draft-upload-remove:hover { color: #c8102e; background: none; }

.draft-setup-note {
  font-size: 0.73rem;
  color: #ccc;
  line-height: 1.5;
  text-align: center;
  margin: -0.5rem 0 0;
}

/* ── Shared panel header (all 4 Argument Builder panes) ──────── */

.panel-header {
  display: flex;
  align-items: center;
  padding: 0 0.75rem;
  border-bottom: 1px solid #e0ddd8;
  background: #fafaf8;
  flex-shrink: 0;
  gap: 0.5rem;
  height: 38px;
  width: 100%;
}


.panel-header-title {
  font-size: 0.78rem;
  font-weight: 600;
  color: #666;
  flex: 1;
}

.panel-header-title--raleway {
  font-family: 'Raleway', sans-serif;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

/* ── Argument Builder layout ──────────────────────────────────── */

#workspace.argbuilder-active #sources-panel,
#workspace.argbuilder-active #draft-panel { display: none !important; }

#workspace.argbuilder-active #chat-panel    { flex: 1 1 0; order: -1; }
#workspace.argbuilder-active #outline-panel { display: flex !important; flex: 1 1 0; order: 0; }
#workspace.argbuilder-active #argmap-panel  { display: flex !important; flex: 1 1 0; order: 1; }

#workspace.argbuilder-active #chat-panel .panel-main    { border-right: 1px solid #d5d2cc; }
#workspace.argbuilder-active #outline-panel .panel-main { border-right: 1px solid #d5d2cc; }
#workspace.argbuilder-active #argmap-panel .panel-main  { border-right: none; }

/* Draft Submission: chat, sources, draft */
#workspace.drafting #chat-panel    { order: 0; }
#workspace.drafting #sources-panel { order: 1; }
#workspace.drafting #draft-panel   { order: 2; }

/* Argument Outline: chat, sources, outline */
#workspace.outlining #chat-panel     { order: 0; }
#workspace.outlining #sources-panel  { order: 1; }
#workspace.outlining #outline-panel  { display: flex !important; flex: 1 1 0; order: 2; }

/* Remove home-state horizontal padding so the full-width header aligns to panel edges */
#chat-panel .panel-main { padding: 0; }

/* Hide the floating absolute collapse button — header has its own */
#chat-panel.chatting .chat-collapse-btn { display: none !important; }

#chat-panel-header { display: none; }
#chat-panel.chatting #chat-panel-header { display: flex; }
#sources-panel-header { display: flex; }

/* ── Argument Builder: Outline panel ────────────────────────── */

#outline-panel { flex: 1 1 0; }

#outline-panel .panel-main {
  background: #fff;
  border-right: 1px solid #d5d2cc;
  overflow: hidden;
}


.outline-body {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.outline-section {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.outline-label {
  font-size: 0.7rem;
  font-weight: 600;
  color: #999;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.outline-claim-input {
  width: 100%;
  box-sizing: border-box;
  resize: vertical;
  min-height: 70px;
  border: 1px solid #e0ddd8;
  border-radius: 6px;
  padding: 0.6rem 0.75rem;
  font-size: 0.85rem;
  font-family: inherit;
  color: #111;
  background: #fafaf8;
  transition: border-color 0.12s, background 0.12s;
}
.outline-claim-input:focus { outline: none; border-color: #0e1f3d; background: #fff; }

.outline-entry {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.35rem;
}

.outline-entry-num {
  font-size: 0.7rem;
  font-weight: 600;
  color: #ccc;
  min-width: 14px;
  text-align: right;
  flex-shrink: 0;
}

.outline-entry-input {
  flex: 1;
  min-width: 0;
  border: 1px solid #e0ddd8;
  border-radius: 6px;
  padding: 0.42rem 0.6rem;
  font-size: 0.83rem;
  font-family: inherit;
  color: #111;
  background: #fafaf8;
  transition: border-color 0.12s, background 0.12s;
}
.outline-entry-input:focus { outline: none; border-color: #0e1f3d; background: #fff; }
.outline-entry-counter { border-color: #f0d5d5; background: #fff8f8; }
.outline-entry-counter:focus { border-color: #c8102e !important; }

.outline-entry-remove {
  background: none;
  border: none;
  color: #ddd;
  cursor: pointer;
  padding: 0.2rem;
  border-radius: 4px;
  display: flex;
  align-items: center;
  flex-shrink: 0;
  transition: color 0.1s;
}
.outline-entry-remove:hover { color: #c8102e; }

.outline-add-btn {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  background: none;
  border: 1px dashed #d5d2cc;
  border-radius: 6px;
  padding: 0.32rem 0.65rem;
  font-size: 0.78rem;
  font-family: inherit;
  color: #aaa;
  cursor: pointer;
  align-self: flex-start;
  transition: border-color 0.12s, color 0.12s;
}
.outline-add-btn:hover { border-color: #0e1f3d; color: #0e1f3d; }

.outline-build-btn {
  padding: 0.58rem 1rem;
  background: #0e1f3d;
  color: #fff;
  border: none;
  border-radius: 7px;
  font-size: 0.85rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.12s;
  margin-top: 0.25rem;
}
.outline-build-btn:hover { background: #1a3460; }

/* ── Argument Builder: Map panel ─────────────────────────────── */

#argmap-panel { flex: 1 1 0; }

#argmap-panel .panel-main {
  background: #fff;
  border-right: 1px solid #d5d2cc;
  overflow: hidden;
}


.argmap-body {
  flex: 1;
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  min-height: 0;
}

.argmap-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  color: #bbb;
  text-align: center;
  font-size: 0.82rem;
  line-height: 1.6;
}
.argmap-empty strong { color: #888; }

.argmap-svg {
  width: 100%;
  height: auto;
  max-width: 580px;
}

/* ── Client Alert panels ─────────────────────────────────────── */

#workspace.client-alert-active #draft-panel,
#workspace.client-alert-active #outline-panel,
#workspace.client-alert-active #argmap-panel,
#workspace.client-alert-active #chat-panel,
#workspace.client-alert-active #sources-panel { display: none !important; }

#workspace.client-alert-active #alert-form-panel,
#workspace.client-alert-active #alert-preview-panel { display: flex !important; }

#alert-form-panel  { flex: 1 1 0; }
#alert-preview-panel { flex: 1 1 0; }

#alert-form-panel .panel-main {
  background: #fff;
  border-right: 1px solid #d5d2cc;
  overflow: hidden;
}

#alert-preview-panel .panel-main {
  background: #fff;
  overflow: hidden;
}

.alert-form-body {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

.alert-field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.alert-label {
  font-size: 0.7rem;
  font-weight: 600;
  color: #999;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.alert-input {
  width: 100%;
  padding: 0.45rem 0.6rem;
  border: 1px solid #d5d2cc;
  border-radius: 5px;
  font-size: 0.82rem;
  font-family: inherit;
  color: #111;
  background: #fafaf8;
  outline: none;
  transition: border-color 0.12s, background 0.12s;
}
.alert-input:focus { border-color: #0e1f3d; background: #fff; }

.alert-textarea {
  width: 100%;
  padding: 0.45rem 0.6rem;
  border: 1px solid #d5d2cc;
  border-radius: 5px;
  font-size: 0.82rem;
  font-family: inherit;
  color: #111;
  background: #fafaf8;
  resize: vertical;
  outline: none;
  transition: border-color 0.12s, background 0.12s;
}
.alert-textarea:focus { border-color: #0e1f3d; background: #fff; }

.alert-tone-pills {
  display: flex;
  gap: 0.4rem;
}

.alert-tone-pill {
  padding: 0.32rem 0.8rem;
  border: 1px solid #d5d2cc;
  border-radius: 20px;
  background: none;
  font-size: 0.78rem;
  font-family: inherit;
  color: #666;
  cursor: pointer;
  transition: border-color 0.12s, color 0.12s, background 0.12s;
}
.alert-tone-pill:hover { border-color: #aaa; color: #111; }
.alert-tone-pill.active { border-color: #0e1f3d; color: #0e1f3d; background: #eef0f7; font-weight: 500; }

.alert-preview-body {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.alert-preview-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  color: #bbb;
  text-align: center;
  font-size: 0.82rem;
  line-height: 1.6;
}
.alert-preview-empty strong { color: #888; }

.alert-preview-content {
  flex: 1;
  padding: 2rem;
  font-size: 0.88rem;
  line-height: 1.75;
  color: #111;
  overflow-y: auto;
}
.alert-preview-content h1 { font-size: 1.05rem; font-weight: 700; margin-bottom: 0.25rem; color: #0e1f3d; }
.alert-preview-content h2 { font-size: 0.9rem; font-weight: 600; margin: 1.2rem 0 0.3rem; color: #0e1f3d; }
.alert-preview-content h3 { font-size: 0.85rem; font-weight: 600; margin: 1rem 0 0.2rem; }
.alert-preview-content p  { margin-bottom: 0.75rem; }
.alert-preview-content ul { margin: 0.4rem 0 0.75rem 1.2rem; }
.alert-preview-content li { margin-bottom: 0.3rem; }
.alert-preview-content .alert-meta { font-size: 0.75rem; color: #888; margin-bottom: 1.5rem; border-bottom: 1px solid #e0ddd8; padding-bottom: 0.75rem; }

/* ── Generate Chronology panels ─────────────────────────────── */

#workspace.chronology-active #draft-panel,
#workspace.chronology-active #outline-panel,
#workspace.chronology-active #argmap-panel,
#workspace.chronology-active #alert-form-panel,
#workspace.chronology-active #alert-preview-panel,
#workspace.chronology-active #chat-panel,
#workspace.chronology-active #sources-panel { display: none !important; }

#workspace.chronology-active #chrono-input-panel,
#workspace.chronology-active #chrono-timeline-panel { display: flex !important; }

#chrono-input-panel   { flex: 1 1 0; }
#chrono-timeline-panel { flex: 1 1 0; }

#chrono-input-panel .panel-main {
  background: #fff;
  border-right: 1px solid #d5d2cc;
  overflow: hidden;
}

#chrono-timeline-panel .panel-main {
  background: #fff;
  overflow: hidden;
}

.chrono-input-body {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.chrono-upload-zone {
  border: 1.5px dashed #d5d2cc;
  border-radius: 7px;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  cursor: pointer;
  color: #888;
  font-size: 0.82rem;
  transition: border-color 0.12s, background 0.12s;
}
.chrono-upload-zone:hover,
.chrono-upload-zone.drag-over { border-color: #0e1f3d; background: #f5f7fc; color: #0e1f3d; }
.chrono-upload-hint { font-size: 0.72rem; color: #bbb; }
.chrono-upload-zone input[type="file"] { display: none; }

.chrono-or {
  text-align: center;
  font-size: 0.72rem;
  color: #bbb;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.chrono-paste {
  width: 100%;
  flex: 1;
  padding: 0.6rem 0.75rem;
  border: 1px solid #d5d2cc;
  border-radius: 5px;
  font-size: 0.82rem;
  font-family: inherit;
  color: #111;
  background: #fafaf8;
  resize: none;
  outline: none;
  min-height: 160px;
  transition: border-color 0.12s, background 0.12s;
}
.chrono-paste:focus { border-color: #0e1f3d; background: #fff; }

.chrono-timeline-body {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.chrono-timeline-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  color: #bbb;
  text-align: center;
  font-size: 0.82rem;
  line-height: 1.6;
}
.chrono-timeline-empty strong { color: #888; }

.chrono-timeline-list {
  padding: 1.25rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.chrono-event {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 0 1rem;
  position: relative;
  padding-bottom: 1.5rem;
}

.chrono-event::before {
  content: '';
  position: absolute;
  left: 148px;
  top: 6px;
  bottom: 0;
  width: 1px;
  background: #e0ddd8;
}
.chrono-event:last-child::before { display: none; }

.chrono-event-date {
  font-size: 0.75rem;
  font-weight: 600;
  color: #888;
  text-align: right;
  padding-top: 2px;
  line-height: 1.4;
}

.chrono-event-dot {
  position: absolute;
  left: 144px;
  top: 5px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #0e1f3d;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px #0e1f3d;
}

.chrono-event-content {
  padding-left: 1.25rem;
}

.chrono-event-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: #111;
  margin-bottom: 0.2rem;
}

.chrono-event-desc {
  font-size: 0.8rem;
  color: #555;
  line-height: 1.55;
}

/* ── Transcribe Hearing panels ───────────────────────────────── */

#workspace.transcribe-active #draft-panel,
#workspace.transcribe-active #outline-panel,
#workspace.transcribe-active #argmap-panel,
#workspace.transcribe-active #alert-form-panel,
#workspace.transcribe-active #alert-preview-panel,
#workspace.transcribe-active #chrono-input-panel,
#workspace.transcribe-active #chrono-timeline-panel,
#workspace.transcribe-active #chat-panel,
#workspace.transcribe-active #sources-panel { display: none !important; }

#workspace.transcribe-active #transcribe-input-panel,
#workspace.transcribe-active #transcribe-output-panel { display: flex !important; }

#transcribe-input-panel  { flex: 1 1 0; }
#transcribe-output-panel { flex: 1 1 0; }

#transcribe-input-panel .panel-main  { background: #fff; border-right: 1px solid #d5d2cc; overflow: hidden; }
#transcribe-output-panel .panel-main { background: #fff; overflow: hidden; }

.transcribe-input-body {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.transcribe-upload-zone {
  border: 1.5px dashed #d5d2cc;
  border-radius: 7px;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  cursor: pointer;
  color: #888;
  font-size: 0.82rem;
  transition: border-color 0.12s, background 0.12s, color 0.12s;
}
.transcribe-upload-zone:hover,
.transcribe-upload-zone.drag-over { border-color: #0e1f3d; background: #f5f7fc; color: #0e1f3d; }
.transcribe-upload-zone input[type="file"] { display: none; }

.transcribe-file-info {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: #f0f4fb;
  border: 1px solid #c5d3ec;
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  font-size: 0.82rem;
  color: #0e1f3d;
}
.transcribe-file-info span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.transcribe-file-remove {
  background: none; border: none; cursor: pointer; color: #888; font-size: 0.9rem; padding: 0 0.2rem;
  line-height: 1; flex-shrink: 0;
}
.transcribe-file-remove:hover { color: #c8102e; }

.transcribe-divider {
  text-align: center;
  font-size: 0.72rem;
  color: #bbb;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.transcribe-record-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.transcribe-record-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border: 1.5px solid #d5d2cc;
  border-radius: 6px;
  background: none;
  font-size: 0.82rem;
  font-family: inherit;
  color: #444;
  cursor: pointer;
  transition: border-color 0.12s, color 0.12s, background 0.12s;
}
.transcribe-record-btn:hover { border-color: #0e1f3d; color: #0e1f3d; }
.transcribe-record-btn.recording { border-color: #c8102e; color: #c8102e; background: #fff5f5; }
.transcribe-record-btn.recording svg { animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity:1; } 50% { opacity:0.4; } }

.transcribe-timer {
  font-size: 0.85rem;
  font-weight: 600;
  color: #c8102e;
  font-variant-numeric: tabular-nums;
}

.transcribe-progress-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.transcribe-progress-label { font-size: 0.78rem; color: #666; }
.transcribe-progress-bar { height: 4px; background: #e8e5df; border-radius: 2px; overflow: hidden; }
.transcribe-progress-fill {
  height: 100%;
  background: #0e1f3d;
  border-radius: 2px;
  width: 0%;
  transition: width 0.3s ease;
}

.transcribe-output-body {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.transcribe-output-content {
  flex: 1;
  padding: 1.25rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.transcribe-section-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #999;
  margin-top: 0.75rem;
}
.transcribe-section-label:first-child { margin-top: 0; }

.transcribe-summary {
  font-size: 0.85rem;
  line-height: 1.7;
  color: #111;
  background: #f7f6f3;
  border-left: 3px solid #0e1f3d;
  padding: 0.75rem 1rem;
  border-radius: 0 5px 5px 0;
}

.transcribe-transcript {
  font-size: 0.82rem;
  line-height: 1.8;
  color: #333;
  white-space: pre-wrap;
  font-family: inherit;
}

/* ── Closing Checklist panels ────────────────────────────────── */

#workspace.checklist-active #draft-panel,
#workspace.checklist-active #outline-panel,
#workspace.checklist-active #argmap-panel,
#workspace.checklist-active #alert-form-panel,
#workspace.checklist-active #alert-preview-panel,
#workspace.checklist-active #chrono-input-panel,
#workspace.checklist-active #chrono-timeline-panel,
#workspace.checklist-active #transcribe-input-panel,
#workspace.checklist-active #transcribe-output-panel,
#workspace.checklist-active #chat-panel,
#workspace.checklist-active #sources-panel { display: none !important; }

#workspace.checklist-active #checklist-setup-panel,
#workspace.checklist-active #checklist-list-panel { display: flex !important; }

#checklist-setup-panel { flex: 0 0 320px; }
#checklist-list-panel  { flex: 1 1 0; }

#checklist-setup-panel .panel-main { background: #fff; border-right: 1px solid #d5d2cc; overflow: hidden; }
#checklist-list-panel  .panel-main { background: #fff; overflow: hidden; }

.checklist-list-body {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.checklist-list-content {
  flex: 1;
  padding: 0.75rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.checklist-category {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.checklist-category-title {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: #0e1f3d;
  padding: 0.5rem 0 0.4rem;
  border-bottom: 1px solid #e0ddd8;
  margin-bottom: 0.25rem;
}

.checklist-item {
  display: grid;
  grid-template-columns: 20px 1fr auto auto;
  align-items: start;
  gap: 0.5rem;
  padding: 0.55rem 0;
  border-bottom: 1px solid #f0ede8;
}
.checklist-item:last-child { border-bottom: none; }

.checklist-checkbox {
  width: 15px;
  height: 15px;
  accent-color: #0e1f3d;
  cursor: pointer;
  margin-top: 2px;
  flex-shrink: 0;
}

.checklist-item-main {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 0;
}

.checklist-item-label {
  font-size: 0.82rem;
  color: #111;
  line-height: 1.4;
}
.checklist-item.done .checklist-item-label { text-decoration: line-through; color: #aaa; }

.checklist-item-note {
  font-size: 0.75rem;
  color: #888;
  font-style: italic;
}

.checklist-assignee {
  font-size: 0.72rem;
  color: #888;
  white-space: nowrap;
  padding-top: 2px;
}

.checklist-due {
  font-size: 0.72rem;
  color: #888;
  white-space: nowrap;
  padding-top: 2px;
}

/* ── Assess Risk panels ──────────────────────────────────────── */

#workspace.risk-active #draft-panel,
#workspace.risk-active #outline-panel,
#workspace.risk-active #argmap-panel,
#workspace.risk-active #alert-form-panel,
#workspace.risk-active #alert-preview-panel,
#workspace.risk-active #chrono-input-panel,
#workspace.risk-active #chrono-timeline-panel,
#workspace.risk-active #transcribe-input-panel,
#workspace.risk-active #transcribe-output-panel,
#workspace.risk-active #checklist-setup-panel,
#workspace.risk-active #checklist-list-panel,
#workspace.risk-active #chat-panel,
#workspace.risk-active #sources-panel { display: none !important; }

#workspace.risk-active #risk-input-panel,
#workspace.risk-active #risk-register-panel,
#workspace.risk-active #risk-matrix-panel { display: flex !important; }

#risk-input-panel    { flex: 0 0 280px; }
#risk-register-panel { flex: 1 1 0; }
#risk-matrix-panel   { flex: 0 0 360px; }

#risk-input-panel    .panel-main { background: #fff; border-right: 1px solid #d5d2cc; overflow: hidden; }
#risk-register-panel .panel-main { background: #fff; border-right: 1px solid #d5d2cc; overflow: hidden; }
#risk-matrix-panel   .panel-main { background: #fff; overflow: hidden; }

.risk-register-body {
  flex: 1;
  overflow: auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
}

.risk-register-table-wrap {
  flex: 1;
  overflow: auto;
}

.risk-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
}
.risk-table th {
  position: sticky;
  top: 0;
  background: #fafaf8;
  border-bottom: 1px solid #d5d2cc;
  padding: 0.5rem 0.65rem;
  text-align: left;
  font-weight: 600;
  color: #666;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
  z-index: 1;
}
.risk-table td {
  padding: 0.55rem 0.65rem;
  border-bottom: 1px solid #f0ede8;
  vertical-align: top;
  color: #111;
  line-height: 1.4;
}
.risk-table tr:last-child td { border-bottom: none; }
.risk-table tr:hover td { background: #fafaf8; }

.risk-badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 10px;
  font-size: 0.7rem;
  font-weight: 600;
  white-space: nowrap;
}
.risk-badge-critical { background: #fde8e8; color: #c8102e; }
.risk-badge-high     { background: #fdf0e0; color: #b45309; }
.risk-badge-medium   { background: #fef9e0; color: #92690a; }
.risk-badge-low      { background: #e8f5ee; color: #166534; }

.risk-score {
  display: inline-block;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  text-align: center;
  line-height: 20px;
  font-size: 0.68rem;
  font-weight: 700;
  color: #fff;
}
.risk-score-critical { background: #c8102e; }
.risk-score-high     { background: #d97706; }
.risk-score-medium   { background: #ca8a04; }
.risk-score-low      { background: #16a34a; }

.risk-matrix-body {
  flex: 1;
  overflow: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  min-height: 0;
}

.risk-matrix-svg-wrap {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.risk-matrix-svg {
  width: 100%;
  max-width: 340px;
  height: auto;
}

/* ── Sources panel ───────────────────────────────────────────── */

#sources-panel { flex: 1 1 0; }

#sources-panel .panel-main {
  background: #fff;
  border: none;
  overflow: hidden;
}

/* Collapse btn sits at end of tab-bar */
.sources-collapse-btn { margin-left: auto; }

/* ── Results panel ──────────────────────────────────────────── */

#results-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

#tab-bar {
  display: flex;
  gap: 0.2rem;
  border-bottom: 1px solid #d5d2cc;
  padding: 0.35rem 0;
  flex-shrink: 0;
}

#tab-bar .tab {
  flex: 1;
  padding: 0.45rem 0.5rem;
  font-size: 0.8rem;
  font-weight: 500;
  background: none;
  color: rgba(14,31,61,0.4);
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: color 0.12s, background 0.12s;
}

#tab-bar .tab:hover { color: rgba(14,31,61,0.7); background: rgba(14,31,61,0.05); }

#tab-bar .tab.active {
  color: #0e1f3d;
  background: rgba(14,31,61,0.07);
  font-weight: 600;
}

.tab-pane {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 0.25rem 1rem 0;
  min-height: 0;
}

/* ── Cards ──────────────────────────────────────────────────── */

.card {
  background: #fff;
  border: 1px solid #d5d2cc;
  border-left: 3px solid #1c3d7a;
  border-radius: 6px;
  padding: 0.85rem;
  margin-bottom: 0.65rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.card-header {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-bottom: 0.35rem;
}

.source-badge {
  font-size: 0.68rem;
  font-weight: 700;
  color: #1c3d7a;
  background: #e5ecf8;
  padding: 0.1rem 0.45rem;
  border-radius: 4px;
}

.rank-badge {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  background: #dcfce7;
  color: #166534;
  letter-spacing: 0.02em;
  flex-shrink: 0;
}

.via-badge {
  font-size: 0.65rem;
  font-weight: 600;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
}
.via-vector { background: #f0f0f0; color: #666; }
.via-graph  { background: #f3eaff; color: #6b21a8; }

.score {
  font-size: 0.68rem;
  color: #aaa;
  margin-left: auto;
}

.path {
  font-size: 0.75rem;
  font-weight: 600;
  color: #1c3d7a;
  margin-bottom: 0.35rem;
  word-break: break-word;
}

.article-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: #1a1a2e;
  margin-bottom: 0.3rem;
}

.via-reason {
  font-size: 0.7rem;
  color: #888;
  margin-bottom: 0.35rem;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-bottom: 0.45rem;
}

.chip {
  display: inline-block;
  padding: 0.1rem 0.4rem;
  border-radius: 99px;
  font-size: 0.67rem;
  font-weight: 600;
}

.chip-law        { background: #e5ecf8; color: #1c3d7a; }
.chip-type       { background: #f0fdf4; color: #15803d; }
.chip-year       { background: #f5f5f5; color: #555;    }
.chip-parties    { background: #fff7ed; color: #92400e; }
.chip-obligation { background: #fef3c7; color: #78350f; font-style: italic; }
.chip-subject    { background: #f3e8ff; color: #6b21a8; }

.excerpt {
  font-size: 0.8rem;
  color: #333;
  line-height: 1.55;
  display: -webkit-box;
  -webkit-line-clamp: 5;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.pdf-link {
  display: inline-block;
  margin-top: 0.75rem;
  font-size: 0.78rem;
  color: #666;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.pdf-link:hover { color: #0e1f3d; }

.doc-link {
  display: inline-block;
  margin-top: 0.75rem;
  font-size: 0.78rem;
  color: #666;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.doc-link:hover { color: #0e1f3d; }

.graph-ctx {
  margin-top: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.graph-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.7rem;
}

.graph-label { color: #999; white-space: nowrap; }

.tag {
  display: inline-block;
  padding: 0.08rem 0.4rem;
  border-radius: 4px;
  font-size: 0.67rem;
  font-weight: 500;
}

.tag-law  { background: #e5ecf8; color: #1c3d7a; }
.tag-case { background: #fef3e8; color: #b45309; }

.no-results { font-size: 0.85rem; color: #aaa; }

/* ── Sources / manifest tab ─────────────────────────────────── */

.manifest-meta {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  margin-bottom: 1.1rem;
  padding-bottom: 0.8rem;
  border-bottom: 1px solid #e0ddd8;
}

.manifest-label {
  font-size: 0.85rem;
  font-weight: 700;
  color: #0e1f3d;
}

.manifest-total {
  font-size: 0.75rem;
  color: #999;
}

.manifest-section {
  margin-bottom: 1.25rem;
}

.manifest-section-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
}

.manifest-section-title {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: #888;
}

.manifest-section-count {
  font-size: 0.68rem;
  font-weight: 600;
  color: #fff;
  background: #1c3d7a;
  padding: 0.05rem 0.45rem;
  border-radius: 99px;
}

.manifest-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.35rem 0;
  border-bottom: 1px solid #f0ede8;
}

.manifest-row:last-child { border-bottom: none; }

.manifest-name {
  font-size: 0.8rem;
  color: #222;
  line-height: 1.4;
  word-break: break-word;
  flex: 1;
}

a.manifest-name {
  color: #1c3d7a;
  text-decoration: none;
  text-underline-offset: 2px;
}

a.manifest-name:hover { text-decoration: underline; }

.manifest-count {
  font-size: 0.7rem;
  color: #aaa;
  white-space: nowrap;
  flex-shrink: 0;
}

/* ── Modal ──────────────────────────────────────────────────── */

#modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

#modal-overlay[hidden] { display: none; }

#modal {
  background: #fff;
  border-radius: 10px;
  width: 100%;
  max-width: 720px;
  max-height: 85vh;
  overflow-y: auto;
  padding: 1.75rem 1.75rem 1.5rem;
  position: relative;
  box-shadow: 0 8px 40px rgba(0,0,0,0.22);
}

#modal-close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  background: none;
  border: none;
  font-size: 1rem;
  color: #aaa;
  cursor: pointer;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  line-height: 1;
}
#modal-close:hover { background: #f0f0f0; color: #333; }

.modal-path {
  font-size: 0.75rem;
  font-weight: 600;
  color: #1c3d7a;
  margin-bottom: 0.25rem;
}

.modal-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: #0e1f3d;
  margin-bottom: 0.6rem;
  line-height: 1.35;
}

.modal-excerpt {
  font-size: 0.845rem;
  color: #222;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid #eee;
}

/* Card clickability */
.card {
  cursor: pointer;
  transition: box-shadow 0.12s, border-left-color 0.12s;
}
.card:hover {
  border-left-color: #2d5abf;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}
.card.is-pinned {
  border-left-color: #c8960c;
  background: #fffdf5;
}

/* Vote buttons */
.vote-row {
  display: flex;
  gap: 0.2rem;
  margin-left: 0.3rem;
  flex-shrink: 0;
}
.vote-btn {
  background: none;
  border: 1px solid #ddd;
  padding: 0.1rem 0.4rem;
  font-size: 0.75rem;
  color: #bbb;
  cursor: pointer;
  border-radius: 3px;
  line-height: 1.4;
  min-width: 1.6rem;
  text-align: center;
  font-weight: 400;
}
.vote-btn:hover { border-color: #aaa; color: #666; background: #f5f5f5; }
.vote-btn.vote-accept.voted { background: #dcfce7; border-color: #4ade80; color: #15803d; }
.vote-btn.vote-reject.voted { background: #fee2e2; border-color: #f87171; color: #b91c1c; }

/* Modal vote row */
.modal-vote-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid #eee;
}
.modal-vote-label {
  font-size: 0.78rem;
  color: #888;
}

/* Pin button */
.pin-btn {
  background: none;
  border: none;
  padding: 0.1rem 0.35rem;
  font-size: 0.8rem;
  color: #ccc;
  cursor: pointer;
  border-radius: 3px;
  line-height: 1;
  margin-left: 0.2rem;
  flex-shrink: 0;
}
.pin-btn:hover    { color: #1c3d7a; background: #f0f0f0; }
.pin-btn.is-pinned { color: #c8960c; }

/* ── Responsive ─────────────────────────────────────────────── */

.mobile-indicator { display: none; }

/* Settings gear: hidden on desktop */
.topbar-settings-btn { display: none; }

/* Swipe dots: hidden on desktop */
.workspace-swipe-dots { display: none; }

/* Mobile shortcuts: hidden everywhere except mobile home */
#mobile-shortcuts { display: none; }

/* Mobile tab bar: hidden on desktop */
#mobile-tab-bar { display: none; }

/* Mobile history view: hidden by default (JS-managed) */
#mobile-history-view { display: none; }


@media (max-width: 640px) {
  html, body { overflow-x: hidden; }

  /* Hide desktop sidebar — bottom tab bar handles nav */
  #sidebar { display: none; }

  /* Topbar: compact, show settings gear */
  #topbar { padding: 0 0.75rem; }
  .topbar-link { display: none; }
  .analytics-btn { display: none; }
  .topbar-settings-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: rgba(255,255,255,0.75);
    cursor: pointer;
    padding: 0.3rem;
    border-radius: 6px;
    transition: color 0.15s, background 0.15s;
  }
  .topbar-settings-btn:hover { color: #fff; background: rgba(255,255,255,0.1); }

  /* Main area: column with tab bar at bottom */
  #main-area { padding-bottom: 0; }

  /* Workspace: horizontal slide between chat and sources */
  #workspace {
    flex-direction: column;
    padding: 0;
    gap: 0;
    overflow: clip;
    position: relative;
  }

  /* On mobile: panels fill the workspace absolutely (like before),
     strips and collapse buttons hidden — swipe dots handle navigation */
  .panel-collapse-btn { display: none; }
  .panel-collapsed-strip { display: none; }
  #draft-panel { display: none !important; } /* Draft hidden on mobile for now */

  #chat-panel, #sources-panel {
    position: absolute;
    inset: 0;
    flex: none;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
  }

  #chat-panel .panel-main {
    overflow-y: auto;
    height: 100%;
  }

  #sources-panel .panel-main {
    overflow-y: auto;
    height: 100%;
  }

  #workspace.show-chat    #chat-panel    { transform: translateX(0); }
  #workspace.show-chat    #sources-panel { transform: translateX(100%); }
  #workspace.show-sources #chat-panel    { transform: translateX(-100%); }
  #workspace.show-sources #sources-panel { transform: translateX(0); }

  /* Swipe dots inside workspace */
  .workspace-swipe-dots {
    display: flex;
    justify-content: center;
    gap: 6px;
    padding: 5px 0 6px;
    flex-shrink: 0;
    background: #f7f6f3;
    border-top: 1px solid #e5e2dc;
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 10;
  }
  .mobile-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #ccc;
    transition: background 0.2s, transform 0.2s;
  }
  .mobile-dot.active { background: #1c3d7a; transform: scale(1.3); }

  /* Only show swipe dots when in chatting + results visible state */
  #workspace:not(.results-ready) .workspace-swipe-dots { display: none; }

  /* Sources panel: tab pane padding */
  .tab-pane { padding: 0.75rem 0.5rem; }

  /* Mobile history view: full-height scrollable */
  #mobile-history-view {
    flex: 1;
    flex-direction: column;
    overflow-y: auto;
    background: #faf9f7;
    min-height: 0;
  }

  .mvh-header {
    padding: 1.25rem 1.1rem 0.75rem;
    border-bottom: 1px solid #e8e5df;
    flex-shrink: 0;
  }

  .mvh-title {
    font-size: 1rem;
    font-weight: 700;
    color: #111;
    margin: 0;
  }

  .mvh-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem 0;
  }

  .mvh-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.65rem 1.1rem;
    border-bottom: 1px solid #f0ede8;
    cursor: pointer;
    transition: background 0.1s;
  }
  .mvh-item:hover { background: #f5f3ef; }
  .mvh-item-name {
    flex: 1;
    font-size: 0.85rem;
    color: #111;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .mvh-item-time {
    font-size: 0.72rem;
    color: #aaa;
    flex-shrink: 0;
  }
  .mvh-empty {
    padding: 2rem 1.1rem;
    font-size: 0.83rem;
    color: #aaa;
    text-align: center;
  }

  /* Workflows view on mobile */
  #workflows-view { padding: 1.25rem 1rem; }
  .wfv-grid { grid-template-columns: repeat(2, 1fr); }
  .wfv-header { max-width: 100%; }

  /* Mobile bottom tab bar */
  #mobile-tab-bar {
    display: flex;
    flex-shrink: 0;
    background: #fff;
    border-top: 1px solid #e0ddd8;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  .mob-tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 0.5rem 0.25rem 0.4rem;
    background: none;
    border: none;
    cursor: pointer;
    color: #aaa;
    font-family: inherit;
    font-size: 0.65rem;
    font-weight: 500;
    transition: color 0.15s;
  }
  .mob-tab:hover { color: #555; }
  .mob-tab.active { color: #0e1f3d; }
  .mob-tab.active svg { stroke: #0e1f3d; }

  /* Mobile home: centered, input pinned to bottom */
  #chat-panel:not(.chatting) .panel-main {
    display: flex;
    flex-direction: column;
    padding: 0;
  }
  #chat-panel:not(.chatting) #home-header {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1.5rem 1rem 0.5rem;
  }
  #chat-panel:not(.chatting) #chat-form {
    order: 10;
    padding: 0 0.75rem 0.5rem;
    border-top: 1px solid #e8e5df;
  }
  #chat-panel:not(.chatting) #home-pills {
    order: 9;
    padding: 0.5rem 0.75rem 0;
    justify-content: flex-start;
    overflow-x: auto;
    flex-wrap: nowrap;
    scrollbar-width: none;
  }
  #chat-panel:not(.chatting) #home-pills::-webkit-scrollbar { display: none; }
  #chat-panel:not(.chatting) #home-workflows { display: none; }
  #chat-panel:not(.chatting) #home-action-row { display: none; }

  /* Mobile shortcuts: shown on mobile home state */
  #chat-panel:not(.chatting) #mobile-shortcuts {
    display: flex;
    gap: 0.5rem;
    padding: 0.6rem 0 0.4rem;
    justify-content: center;
    flex-wrap: wrap;
  }
  .mob-shortcut-btn {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    background: #f5f3ef;
    border: 1px solid #e0ddd8;
    border-radius: 20px;
    padding: 0.38rem 0.75rem;
    font-family: inherit;
    font-size: 0.75rem;
    color: #444;
    cursor: pointer;
    white-space: nowrap;
  }
  .mob-shortcut-btn:hover { background: #edeae4; }
}

/* ── Phase 2: Home screen ───────────────────────────────────── */

/* Home state: scrollable column, content centered */
#chat-panel:not(.chatting) .panel-main {
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0 2rem 2.5rem;
}

/* Hide messages and chat footer in home state */
#messages                    { display: none; }
.form-footer                 { display: none; }

/* Chat state: restore panel layout */
#chat-panel.chatting .panel-main { overflow: hidden; }
#chat-panel.chatting #messages       { display: flex; flex: 1; }
#chat-panel.chatting .form-footer    { display: flex; }
#chat-panel.chatting #home-header    { display: none; }
#chat-panel.chatting #home-action-row { display: none; }
#chat-panel.chatting #home-pills     { display: none; }
#chat-panel.chatting #home-workflows { display: none; }

/* Chat state: restore form styling */
#chat-panel.chatting #chat-form {
  border: none;
  border-top: 1px solid #e0ddd8;
  border-radius: 0;
  background: #f9f8f5;
  padding: 0.75rem;
  max-width: none;
  margin: 0;
  overflow: visible;
}
#chat-panel.chatting #chat-form textarea {
  border: 1px solid #ccc;
  border-radius: 6px;
  padding: 0.55rem 0.75rem;
  font-size: 0.875rem;
  margin-bottom: 0.5rem;
  min-height: unset;
}
#chat-panel.chatting #chat-form textarea:focus {
  border-color: #1c3d7a;
}

/* ── Home header: brand mark ── */

#home-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 3.5rem 0 2rem;
  max-width: 700px;
  margin: 0 auto;
  width: 100%;
}

.home-brand-mark {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.7rem;
  margin-bottom: 1.75rem;
}

.home-brand-title {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.home-star {
  color: #c8102e;
  font-size: 0.72rem;
  line-height: 1;
}

.home-wordmark {
  font-family: 'Raleway', sans-serif;
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: #0e1f3d;
}

/* Context buttons */

.home-context-btns {
  display: flex;
  gap: 0.5rem;
}

.home-ctx-btn {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.38rem 0.8rem;
  border: 1px solid #d5d2cc;
  border-radius: 6px;
  background: none;
  color: #666;
  font-size: 0.8rem;
  font-weight: 400;
  font-family: inherit;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s, color 0.12s;
}
.home-ctx-btn:hover { background: #f5f3ef; color: #111; border-color: #bbb; }
.home-ctx-btn.vault-active { border-color: #0e1f3d; color: #0e1f3d; }

.vault-dropdown { position: relative; }
.vault-menu {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  background: #fff;
  border: 1px solid #e0ddd8;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.10);
  padding: 0.3rem;
  min-width: 160px;
  z-index: 200;
}
.vault-menu.open { display: block; }
.vault-option {
  display: block;
  width: 100%;
  background: none;
  border: none;
  border-radius: 5px;
  padding: 0.45rem 0.7rem;
  cursor: pointer;
  font-size: 0.82rem;
  font-family: inherit;
  color: #333;
  text-align: left;
  white-space: nowrap;
  transition: background 0.12s;
}
.vault-option:hover { background: #f5f4f1; }
.vault-option.active { background: #eef0f7; font-weight: 500; color: #0e1f3d; }

/* ── Home form: unified input box ── */

#chat-panel:not(.chatting) #chat-form {
  max-width: 700px;
  width: 100%;
  margin: 0 auto;
  border: 1px solid #d5d2cc;
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
  flex-shrink: 0;
  padding: 0;
  border-top: 1px solid #d5d2cc;
  box-shadow: 0 1px 6px rgba(0,0,0,0.06);
}

#chat-panel:not(.chatting) #chat-form textarea {
  border: none;
  border-bottom: 1px solid #e8e5e0;
  border-radius: 0;
  padding: 1rem 1.1rem;
  font-size: 0.93rem;
  margin-bottom: 0;
  min-height: 80px;
  background: #fff;
}
#chat-panel:not(.chatting) #chat-form textarea:focus {
  outline: none;
  border-color: #e8e5e0;
}

/* Home action row */
#home-action-row {
  display: flex;
  align-items: center;
  padding: 0.5rem 0.75rem;
  background: #fafaf8;
  gap: 0.4rem;
}

.home-action-btns {
  display: flex;
  flex: 1;
  gap: 0.3rem;
  flex-wrap: wrap;
}

.home-action-btn {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  background: none;
  border: 1px solid #d5d2cc;
  color: #666;
  font-size: 0.76rem;
  font-weight: 400;
  font-family: inherit;
  padding: 0.25rem 0.55rem;
  border-radius: 5px;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.home-action-btn:hover { background: #eeece8; color: #111; }

#home-ask-btn {
  background: #0e1f3d;
  color: #fff;
  border: none;
  padding: 0.38rem 1.2rem;
  border-radius: 6px;
  font-size: 0.83rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.12s;
}
#home-ask-btn:hover { background: #1a3460; }
#home-ask-btn:disabled { background: #aaa; cursor: not-allowed; }

/* ── Source pills ── */

#home-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  padding: 0.85rem 0 0;
  max-width: 700px;
  width: 100%;
  margin: 0 auto;
}

.home-pill {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.28rem 0.7rem;
  border: 1px solid #d5d2cc;
  border-radius: 99px;
  background: none;
  color: #666;
  font-size: 0.76rem;
  font-weight: 400;
  font-family: inherit;
  cursor: pointer;
  transition: border-color 0.12s, color 0.12s;
}
.home-pill:hover { border-color: #1c3d7a; color: #1c3d7a; background: none; }
.pill-add { color: #bbb; font-size: 0.8rem; }
.home-pill:hover .pill-add { color: #1c3d7a; }

/* ── Workflow cards ── */

#home-workflows {
  max-width: 700px;
  width: 100%;
  margin: 0 auto;
  padding-top: 1.75rem;
}

.home-workflows-title {
  font-size: 0.72rem;
  font-weight: 700;
  color: #aaa;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  margin-bottom: 0.7rem;
}

.home-workflows-scroll {
  display: flex;
  gap: 0.65rem;
  overflow-x: auto;
  padding-bottom: 0.5rem;
  scrollbar-width: thin;
  scrollbar-color: #d5d2cc transparent;
}

.workflow-card {
  flex-shrink: 0;
  width: 162px;
  background: #fff;
  border: 1px solid #d5d2cc;
  border-radius: 8px;
  padding: 0.9rem;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  transition: box-shadow 0.12s, border-color 0.12s;
}
.workflow-card:hover { box-shadow: 0 2px 10px rgba(0,0,0,0.08); border-color: #bbb; }

.wf-icon { color: #777; flex-shrink: 0; }
.wf-title { font-size: 0.83rem; font-weight: 600; color: #111; line-height: 1.3; }
.wf-meta  { display: flex; align-items: center; gap: 0.4rem; margin-top: auto; padding-top: 0.25rem; }
.wf-badge {
  font-size: 0.62rem;
  font-weight: 700;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.wf-draft  { background: #e5ecf8; color: #1c3d7a; }
.wf-output { background: #f0fdf4; color: #15803d; }
.wf-review { background: #fef3c7; color: #78350f; }
.wf-steps  { font-size: 0.69rem; color: #bbb; }

/* ── Workflows full-view (Phase 7) ── */

#workflows-view {
  flex: 1;
  overflow-y: auto;
  padding: 2rem 2.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  background: #faf9f7;
  min-height: 0;
}

.wfv-header {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-width: 860px;
}

.wfv-title-row {
  display: flex;
  align-items: baseline;
  gap: 1rem;
}

.wfv-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: #111;
  margin: 0;
}

.wfv-view-all {
  background: none;
  border: none;
  font-size: 0.78rem;
  color: #1c3d7a;
  cursor: pointer;
  padding: 0;
  font-family: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.wfv-view-all:hover { color: #0e1f3d; }

.wfv-search-wrap {
  position: relative;
  max-width: 320px;
}

.wfv-search-icon {
  position: absolute;
  left: 0.65rem;
  top: 50%;
  transform: translateY(-50%);
  color: #aaa;
  pointer-events: none;
}

.wfv-search-input {
  width: 100%;
  padding: 0.42rem 0.75rem 0.42rem 2rem;
  font-family: inherit;
  font-size: 0.82rem;
  border: 1px solid #d5d2cc;
  border-radius: 7px;
  background: #fff;
  color: #111;
  outline: none;
  box-sizing: border-box;
  transition: border-color 0.15s;
}
.wfv-search-input:focus { border-color: #1c3d7a; }

.wfv-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(185px, 1fr));
  gap: 0.9rem;
  max-width: 860px;
}

.wfv-card {
  background: #fff;
  border: 1px solid #d5d2cc;
  border-radius: 10px;
  padding: 1.1rem 1rem 0.9rem;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  transition: box-shadow 0.12s, border-color 0.12s;
  min-height: 120px;
}
.wfv-card:hover { box-shadow: 0 2px 12px rgba(0,0,0,0.09); border-color: #aaa; }
.wfv-card-actionable:hover { border-color: #0e1f3d; box-shadow: 0 2px 14px rgba(14,31,61,0.13); }

.wfv-card .wf-icon { color: #6b7280; }
.wfv-card .wf-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: #111;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.wfv-card .wf-meta { margin-top: auto; padding-top: 0.3rem; }

/* Extract badge */
.wf-extract { background: #f3e8ff; color: #6b21a8; }

/* ── Shared library view base ── */

#history-view, #templates-view, #favourites-view {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 2rem 2.5rem 2rem;
  max-width: 900px;
  margin: 0 auto;
  width: 100%;
  box-sizing: border-box;
}

.lib-header {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  margin-bottom: 1.5rem;
}

.lib-title-row { display: flex; align-items: baseline; gap: 1rem; }

.lib-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: #0e1f3d;
  margin: 0;
}

.lib-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
}

.lib-type-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.lib-type-pill {
  background: none;
  border: 1px solid #d5d2cc;
  border-radius: 999px;
  padding: 0.22rem 0.7rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: #555;
  cursor: pointer;
  transition: background 0.1s, border-color 0.1s, color 0.1s;
}
.lib-type-pill:hover { border-color: #0e1f3d; color: #0e1f3d; }
.lib-type-pill.active { background: #0e1f3d; border-color: #0e1f3d; color: #fff; }

/* ── History view ── */

.hist-clear-all-btn {
  margin-left: auto;
  background: none;
  border: none;
  font-size: 0.78rem;
  color: #999;
  cursor: pointer;
  padding: 0.15rem 0.3rem;
  border-radius: 3px;
  transition: color 0.12s, background 0.12s;
}
.hist-clear-all-btn:hover { color: #c0392b; background: #fdf0ef; }

.hist-list {
  display: flex;
  flex-direction: column;
  gap: 0;
  border: 1px solid #e5e2dc;
  border-radius: 8px;
  overflow: hidden;
}

.hist-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #f0ede8;
  cursor: pointer;
  transition: background 0.1s;
}
.hist-item:last-child { border-bottom: none; }
.hist-item:hover { background: #f7f5f1; }

.hist-item-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}
.hist-item-meta {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.hist-phase-dots {
  display: flex;
  align-items: center;
  gap: 3px;
}
.hist-phase-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #ddd;
  flex-shrink: 0;
}
.hist-phase-dot.visited {
  background: #0e1f3d;
}

.hist-item-title {
  font-size: 0.845rem;
  color: #111;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}

.hist-item-time {
  font-size: 0.72rem;
  color: #aaa;
  white-space: nowrap;
  flex-shrink: 0;
}

.hist-domain-tag {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.12rem 0.45rem;
  border-radius: 999px;
  flex-shrink: 0;
}
.hist-domain-maritime      { background: #e5ecf8; color: #1c3d7a; }
.hist-domain-swiss         { background: #fdecea; color: #9b1c1c; }
.hist-domain-swiss_family  { background: #fff3e0; color: #7c4700; }
.hist-domain-montenegro    { background: #e6f4ea; color: #166534; }

.hist-workflow-tag {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.12rem 0.45rem;
  border-radius: 999px;
  flex-shrink: 0;
}
.hist-wf-legal-research      { background: #f0ede8; color: #5a4f3e; }
.hist-wf-draft-submission    { background: #e5ecf8; color: #1c3d7a; }
.hist-wf-support-argument    { background: #e5ecf8; color: #1c3d7a; }
.hist-wf-client-alert        { background: #f0fdf4; color: #15803d; }
.hist-wf-generate-chronology { background: #f0fdf4; color: #15803d; }
.hist-wf-transcribe-hearing  { background: #f0fdf4; color: #15803d; }
.hist-wf-closing-checklist   { background: #fef3c7; color: #78350f; }
.hist-wf-assess-risk         { background: #fef3c7; color: #78350f; }

/* ── Templates view ── */

.tpl-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.85rem;
}

.tpl-card {
  background: #fff;
  border: 1px solid #d5d2cc;
  border-radius: 8px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  cursor: pointer;
  transition: box-shadow 0.15s, border-color 0.15s;
  min-height: 110px;
}
.tpl-card:hover { box-shadow: 0 2px 12px rgba(0,0,0,0.09); border-color: #0e1f3d; }

.tpl-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.tpl-badge {
  font-size: 0.62rem;
  font-weight: 700;
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.tpl-submission { background: #e5ecf8; color: #1c3d7a; }
.tpl-brief      { background: #fef3c7; color: #78350f; }
.tpl-letter     { background: #f0fdf4; color: #15803d; }
.tpl-contract   { background: #fdecea; color: #9b1c1c; }
.tpl-notice     { background: #f3e8ff; color: #6b21a8; }

.tpl-name {
  font-size: 0.845rem;
  font-weight: 600;
  color: #111;
  line-height: 1.35;
  flex: 1;
}

.tpl-jurisdiction {
  font-size: 0.72rem;
  color: #888;
}

.tpl-modified {
  font-size: 0.69rem;
  color: #bbb;
  margin-top: auto;
}

/* ── Favourites view ── */

.fav-tabs {
  display: flex;
  gap: 0.2rem;
  border-bottom: 1px solid #e5e2dc;
  margin-top: 0.25rem;
  padding-bottom: 0.35rem;
}

.fav-tab {
  background: none;
  border: none;
  padding: 0.35rem 0.9rem;
  font-size: 0.83rem;
  font-weight: 500;
  color: rgba(14,31,61,0.4);
  cursor: pointer;
  border-radius: 6px;
  transition: color 0.12s, background 0.12s;
}
.fav-tab:hover  { color: rgba(14,31,61,0.7); background: rgba(14,31,61,0.05); }
.fav-tab.active { color: #0e1f3d; background: rgba(14,31,61,0.07); font-weight: 600; }

.fav-content { margin-top: 1.25rem; }
.fav-list { display: flex; flex-direction: column; gap: 0; border: 1px solid #e5e2dc; border-radius: 8px; overflow: hidden; }

.fav-extract {
  padding: 1rem;
  border-bottom: 1px solid #f0ede8;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  background: #fff;
  cursor: pointer;
  transition: background 0.1s;
}
.fav-extract:last-child { border-bottom: none; }
.fav-extract:hover { background: #f7f5f1; }

.fav-extract-text {
  font-size: 0.845rem;
  color: #333;
  line-height: 1.55;
  font-style: italic;
  margin: 0;
}

.fav-extract-foot {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.fav-extract-source {
  font-size: 0.72rem;
  color: #888;
  font-weight: 500;
}

/* Panels hidden until triggered */
#sources-panel                  { display: none; }
#sources-panel.sources-visible  { display: flex; }
#draft-panel                    { display: none; }
#draft-panel.draft-visible      { display: flex; }

/* ── Phase 3: Sidebar content ───────────────────────────────── */

.sidebar-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0 0.5rem 0.5rem;
  min-height: 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.1) transparent;
}

#sidebar.collapsed .sidebar-content { display: none; }

.sidebar-collapsed-char {
  display: none;
  font-size: 0.68rem;
  font-weight: 700;
  color: rgba(14,31,61,0.35);
  letter-spacing: 0.05em;
}
#sidebar.collapsed .sidebar-collapsed-char { display: block; }
#sidebar.collapsed .sidebar-library {
  padding: 0.25rem 0 0.75rem;
}
#sidebar.collapsed #sidebar-history { display: none; }

#sidebar-history {
  flex: 1 1 0;
  overflow-y: auto;
  min-height: 0;
  padding: 0.4rem 0.5rem;
}

/* Section labels (static headers + details summaries) */
.sidebar-section-label { text-transform: uppercase; letter-spacing: 0.1em; font-size: 0.63rem; }
.sidebar-section-label.active { background: none; box-shadow: none; color: #0e1f3d; font-weight: 600; }

.sidebar-tools-chevron { margin-left: auto; flex-shrink: 0; transition: transform 0.18s ease; }
#sidebar-tools-toggle.active .sidebar-tools-chevron { transform: rotate(180deg); }
#sidebar-history-toggle.active .sidebar-tools-chevron { transform: rotate(180deg); }

.sidebar-tools-list { display: none; flex-direction: column; padding-bottom: 0.2rem; }
.sidebar-tools-list.open { display: flex; }
#sidebar.collapsed .sidebar-tools-list { display: none !important; }
#sidebar.collapsed .sidebar-tools-chevron { display: none; }

/* details summary inherits .sidebar-section-label and is clickable */
details.sidebar-details > summary.sidebar-section-label {
  cursor: pointer;
  margin-top: 0.35rem;
}
details.sidebar-details > summary.sidebar-section-label::-webkit-details-marker { display: none; }
details.sidebar-details > summary.sidebar-section-label:hover { color: rgba(14,31,61,0.6); }

.sidebar-chevron {
  flex-shrink: 0;
  transition: transform 0.18s ease;
  transform: rotate(0deg);
}
details.sidebar-details[open] > summary .sidebar-chevron { transform: rotate(90deg); }

.sidebar-details-body {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding-bottom: 0.3rem;
}

/* Items inside details sections (templates, favourites) */
.sidebar-item-btn {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  color: rgba(14,31,61,0.55);
  font-size: 0.78rem;
  font-weight: 400;
  font-family: inherit;
  padding: 0.38rem 0.55rem;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background 0.15s, color 0.15s;
}
.sidebar-item-btn:hover { background: rgba(14,31,61,0.05); color: rgba(14,31,61,0.85); }

/* History list */
.sidebar-history-list {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  margin-bottom: 0.25rem;
}

.history-empty {
  font-size: 0.75rem;
  color: rgba(14,31,61,0.28);
  padding: 0.3rem 0.5rem 0.5rem;
  font-style: italic;
}

.history-item {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.4rem 0.55rem;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s;
  min-width: 0;
}
.history-item:hover { background: rgba(14,31,61,0.05); }
.history-item.active { background: rgba(14,31,61,0.07); }
.history-item.active .history-name { color: #0e1f3d; font-weight: 600; }

.history-name {
  flex: 1;
  font-size: 0.78rem;
  color: rgba(14,31,61,0.6);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.history-time {
  font-size: 0.67rem;
  color: rgba(14,31,61,0.28);
  white-space: nowrap;
  flex-shrink: 0;
}

.history-delete {
  background: none;
  border: none;
  padding: 0.1rem 0.25rem;
  font-size: 0.7rem;
  color: rgba(14,31,61,0.25);
  cursor: pointer;
  border-radius: 3px;
  flex-shrink: 0;
  opacity: 0;
  transition: opacity 0.12s, color 0.12s, background 0.12s;
  line-height: 1;
}
.history-item:hover .history-delete { opacity: 1; }
.history-delete:hover { color: #c8102e; background: rgba(14,31,61,0.05); }

/* ── Phase 5: Message actions + follow-ups ──────────────────── */

.msg-actions {
  display: flex;
  gap: 0.3rem;
  margin-top: 0.5rem;
  flex-wrap: wrap;
}

.msg-action-btn {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  background: none;
  border: 1px solid #e0ddd8;
  color: #888;
  font-size: 0.73rem;
  font-weight: 400;
  font-family: inherit;
  padding: 0.22rem 0.6rem;
  border-radius: 5px;
  cursor: pointer;
  transition: border-color 0.12s, color 0.12s, background 0.12s;
}
.msg-action-btn:hover  { border-color: #bbb; color: #333; background: #f5f3ef; }
.msg-action-btn.copied { border-color: #86efac; color: #166534; background: #f0fdf4; }
.msg-action-btn.dim    { color: #ccc; cursor: default; }
.msg-action-btn.dim:hover { border-color: #e0ddd8; color: #ccc; background: none; }


/* ── Phase 5: Input bar upgrade ─────────────────────────────── */

.footer-icons {
  display: flex;
  gap: 0.1rem;
  flex-shrink: 0;
}

.footer-icon-btn {
  background: none;
  border: none;
  color: #bbb;
  padding: 0.3rem 0.4rem;
  border-radius: 5px;
  cursor: pointer;
  display: flex;
  align-items: center;
  transition: color 0.12s, background 0.12s;
}
.footer-icon-btn:hover { color: #555; background: #eeece8; }
.footer-icon-btn:disabled { color: #ddd; cursor: not-allowed; background: none; }
.draft-trigger-btn:not(:disabled) { color: #1c3d7a; }

.footer-right {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-shrink: 0;
}

/* Client-ready Summary shortcut */
.sidebar-shortcut-link {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  border-top: 1px solid #d5d5d5;
  color: rgba(14,31,61,0.35);
  font-size: 0.77rem;
  font-weight: 400;
  font-family: inherit;
  padding: 0.65rem 0.25rem 0.4rem;
  margin-top: 0.5rem;
  cursor: pointer;
  transition: color 0.15s;
}
.sidebar-shortcut-link:hover { color: rgba(14,31,61,0.7); background: none; }

/* ── Phase 6: Draft Editor (lives in #draft-panel) ──────────── */

/* Editor toolbar: hidden until draft-active */
#editor-toolbar {
  display: none;
  align-items: center;
  flex-wrap: wrap;
  row-gap: 0.2rem;
  gap: 0.08rem;
  padding: 0.3rem 0.45rem;
  border-bottom: 1px solid #e0ddd8;
  background: #f9f8f5;
  flex-shrink: 0;
}

.editor-style-select {
  font-family: inherit;
  font-size: 0.72rem;
  color: #555;
  background: #fff;
  border: 1px solid #d5d2cc;
  border-radius: 4px;
  padding: 0.15rem 0.3rem;
  cursor: pointer;
  height: 24px;
  outline: none;
  flex-shrink: 0;
}
.editor-style-select:focus { border-color: #1c3d7a; }

.editor-sep {
  width: 1px;
  height: 16px;
  background: #e0ddd8;
  margin: 0 0.1rem;
  flex-shrink: 0;
  align-self: center;
}

.editor-tool-group {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.editor-toolbar-spacer {
  flex: 1;
  min-width: 0.2rem;
}

.editor-tool-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: 1px solid transparent;
  color: #666;
  font-size: 0.72rem;
  font-family: inherit;
  font-weight: 400;
  padding: 0.15rem 0.28rem;
  border-radius: 4px;
  cursor: pointer;
  height: 24px;
  min-width: 24px;
  line-height: 1;
  flex-shrink: 0;
  transition: background 0.1s, border-color 0.1s, color 0.1s;
}
.editor-tool-btn:hover  { background: #eeece8; color: #111; border-color: #d5d2cc; }
.editor-tool-btn.active { background: #e8ecf5; color: #1c3d7a; border-color: #c5d0e8; }
.editor-fmt { font-size: 0.78rem; }

.editor-uci-toggle {
  font-size: 0.69rem;
  padding: 0.15rem 0.45rem;
  white-space: nowrap;
}
.editor-uci-toggle.active { background: #fff8e6; color: #92400e; border-color: #fde68a; }


/* Editor shown only in draft-active state */
#draft-panel.draft-active #editor-toolbar { display: flex; }

/* Editor body: editable content area, hidden until draft-active */
#editor-body {
  display: none;
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1.1rem;
  font-size: 0.875rem;
  line-height: 1.7;
  color: #111;
  outline: none;
  min-height: 0;
}
#draft-panel.draft-active #editor-body { display: block; }
/* copy btn in header also shown in draft-active */
#draft-panel.draft-active #editor-copy-btn { display: inline-flex !important; }

#editor-body h1 { font-size: 1.05rem; font-weight: 700; margin: 0.9rem 0 0.4rem; }
#editor-body h2 { font-size: 0.93rem; font-weight: 700; margin: 0.8rem 0 0.35rem; }
#editor-body h3 { font-size: 0.86rem; font-weight: 600; margin: 0.7rem 0 0.3rem; }
#editor-body h1:first-child,
#editor-body h2:first-child,
#editor-body h3:first-child { margin-top: 0; }
#editor-body p { margin-bottom: 0.5rem; }
#editor-body p:last-child { margin-bottom: 0; }
#editor-body ul,
#editor-body ol { padding-left: 1.3rem; margin-bottom: 0.5rem; }
#editor-body li { margin-bottom: 0.15rem; }
#editor-body strong { font-weight: 600; }
#editor-body code {
  font-family: 'Courier New', monospace;
  font-size: 0.81rem;
  background: #f0ede8;
  padding: 0.1rem 0.3rem;
  border-radius: 3px;
}
#editor-body a { color: #1c3d7a; text-underline-offset: 2px; }

/* UCI (tracked changes / redline) mode */
#editor-body.uci-mode ins {
  background: #dcfce7;
  color: #15803d;
  text-decoration: none;
  border-radius: 2px;
}
#editor-body.uci-mode del {
  background: #fee2e2;
  color: #b91c1c;
  text-decoration: line-through;
  border-radius: 2px;
}

/* Per-section priority badges */
.priority-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 15px;
  height: 15px;
  border-radius: 3px;
  font-size: 0.6rem;
  font-weight: 700;
  line-height: 1;
  margin-right: 0.3rem;
  vertical-align: middle;
  cursor: help;
  user-select: none;
  flex-shrink: 0;
}
.priority-badge[data-priority="1"] { background: #fee2e2; color: #b91c1c; }
.priority-badge[data-priority="2"] { background: #fef3c7; color: #92400e; }
.priority-badge[data-priority="3"] { background: #f0f0f0; color: #666; }

