:root {
  color-scheme: light;
  --bg: #eef4f7;
  --surface: #ffffff;
  --surface-elevated: rgba(255, 255, 255, 0.92);
  --surface-strong: #e7eef2;
  --field: #ffffff;
  --field-strong: #f7fafb;
  --border: #d6e0e7;
  --border-strong: #b8c8d3;
  --text: #17232e;
  --muted: #637281;
  --accent: #247764;
  --accent-strong: #0f4b41;
  --accent-soft: #e6f4ef;
  --accent-alt: #356ec9;
  --accent-warm: #c97c22;
  --button-text: #ffffff;
  --danger: #b42318;
  --danger-strong: #8f1b13;
  --danger-soft: #fff1ef;
  --warn: #a15c00;
  --planned: #5e748a;
  --progress: #247764;
  --blocked: #b42318;
  --done: #5c7822;
  --chrome-bg: rgba(255, 255, 255, 0.84);
  --panel-bg: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(250, 253, 252, 0.94));
  --panel-accent: linear-gradient(135deg, rgba(36, 119, 100, 0.14), rgba(53, 110, 201, 0.10));
  --track: #eef4f6;
  --track-alt: #e6edf1;
  --gridline: rgba(99, 114, 129, 0.20);
  --gridline-major: rgba(36, 119, 100, 0.34);
  --bar-handle: rgba(255, 255, 255, 0.88);
  --message-user: #e8f6f2;
  --code-bg: #111827;
  --code-text: #e5e7eb;
  --focus-ring: rgba(36, 119, 100, 0.28);
  --shadow-sm: 0 8px 22px rgba(31, 47, 58, 0.08);
  --shadow-md: 0 16px 42px rgba(31, 47, 58, 0.12);
  --shadow-lg: 0 24px 70px rgba(31, 47, 58, 0.16);
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1413;
  --surface: #171d1c;
  --surface-elevated: rgba(23, 29, 28, 0.92);
  --surface-strong: #222b2a;
  --field: #121817;
  --field-strong: #1b2322;
  --border: #2a3836;
  --border-strong: #3f5551;
  --text: #eef6f2;
  --muted: #9cadab;
  --accent: #44d0ad;
  --accent-strong: #91f2d7;
  --accent-soft: rgba(68, 208, 173, 0.14);
  --accent-alt: #86aefe;
  --accent-warm: #f5b85c;
  --button-text: #08110f;
  --danger: #ff6b5e;
  --danger-strong: #ff948b;
  --danger-soft: rgba(255, 107, 94, 0.13);
  --warn: #f5b85c;
  --planned: #89a2b8;
  --progress: #44d0ad;
  --blocked: #ff6b5e;
  --done: #b5d86c;
  --chrome-bg: rgba(17, 23, 22, 0.84);
  --panel-bg: linear-gradient(180deg, rgba(24, 31, 30, 0.98), rgba(18, 24, 23, 0.94));
  --panel-accent: linear-gradient(135deg, rgba(68, 208, 173, 0.16), rgba(134, 174, 254, 0.12));
  --track: #1d2726;
  --track-alt: #25302f;
  --gridline: rgba(156, 173, 171, 0.18);
  --gridline-major: rgba(68, 208, 173, 0.36);
  --bar-handle: rgba(255, 255, 255, 0.78);
  --message-user: rgba(68, 208, 173, 0.13);
  --code-bg: #070b0b;
  --code-text: #d9efe9;
  --focus-ring: rgba(68, 208, 173, 0.35);
  --shadow-sm: 0 8px 22px rgba(0, 0, 0, 0.28);
  --shadow-md: 0 16px 42px rgba(0, 0, 0, 0.34);
  --shadow-lg: 0 24px 70px rgba(0, 0, 0, 0.44);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(36, 119, 100, 0.12) 0, rgba(36, 119, 100, 0) 240px),
    linear-gradient(125deg, rgba(53, 110, 201, 0.10), rgba(36, 119, 100, 0.08) 42%, rgba(201, 124, 34, 0.08)),
    var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: var(--button-text);
  padding: 0 14px;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 6px 18px rgba(36, 119, 100, 0.16);
  transition:
    background 150ms ease,
    border-color 150ms ease,
    box-shadow 150ms ease,
    color 150ms ease,
    transform 150ms ease;
}

button.secondary,
.button-link.secondary {
  background: var(--surface);
  color: var(--accent);
  box-shadow: none;
}

button:hover:not(:disabled),
.button-link:hover:not(.is-disabled) {
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(36, 119, 100, 0.18);
}

button.secondary:hover:not(:disabled),
.button-link.secondary:hover:not(.is-disabled) {
  border-color: var(--border-strong);
  background: var(--field-strong);
  color: var(--accent-strong);
}

button.danger {
  border-color: var(--danger);
  background: linear-gradient(135deg, var(--danger), var(--danger-strong));
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.button-link.is-disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--chrome-bg);
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(16px);
}

.topbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 14px;
  min-width: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 6px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0)),
    linear-gradient(135deg, var(--accent-strong), var(--accent-alt));
  color: #fff;
  font-weight: 700;
  box-shadow: 0 10px 28px rgba(15, 75, 65, 0.22);
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 20px;
  line-height: 1.2;
}

h2 {
  font-size: 17px;
  line-height: 1.2;
}

h3 {
  font-size: 14px;
}

.brand p,
.muted {
  color: var(--muted);
}

.project-switcher,
.button-row,
.section-head,
.panel-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.project-switcher label {
  color: var(--muted);
  font-size: 13px;
}

.project-switcher {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-elevated);
  padding: 6px;
  box-shadow: var(--shadow-sm);
}

.theme-toggle {
  gap: 8px;
  min-width: 86px;
  background: var(--surface-elevated);
}

.theme-toggle-icon {
  position: relative;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-warm) 0 50%, var(--accent-alt) 50% 100%);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.42);
}

.theme-toggle-icon::after {
  content: "";
  position: absolute;
  inset: 3px 3px 3px 9px;
  border-radius: 999px;
  background: var(--surface);
}

select,
input,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--field);
  color: var(--text);
  padding: 9px 10px;
}

select:focus,
input:focus,
textarea:focus,
button:focus-visible,
.button-link:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

textarea {
  resize: vertical;
}

.tabs {
  display: flex;
  gap: 6px;
  padding: 10px 24px 0;
  background: var(--chrome-bg);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(16px);
}

.tab {
  border: 0;
  border-radius: 6px 6px 0 0;
  background: transparent;
  color: var(--muted);
  box-shadow: none;
}

.tab.is-active {
  background: var(--bg);
  color: var(--text);
  box-shadow: inset 0 2px 0 var(--accent);
}

main {
  padding: 18px 24px 44px;
}

.welcome-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px;
  background:
    linear-gradient(135deg, rgba(36, 119, 100, 0.16), rgba(53, 110, 201, 0.10), rgba(201, 124, 34, 0.10)),
    var(--bg);
}

.welcome-shell {
  width: min(980px, 100%);
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(300px, 0.85fr);
  gap: 22px;
  align-items: stretch;
}

.welcome-copy {
  display: flex;
  align-items: flex-start;
  gap: 18px;
  padding: 28px 0;
}

.welcome-mark {
  width: 54px;
  height: 54px;
}

.eyebrow {
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
}

.welcome-copy h1 {
  margin-top: 8px;
  font-size: 38px;
  line-height: 1.05;
}

.welcome-copy p:last-child {
  max-width: 560px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.5;
}

.signin-panel {
  display: grid;
  align-content: space-between;
  gap: 28px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-elevated);
  box-shadow: var(--shadow-lg);
  padding: 22px;
}

.signin-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.provider-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent-alt), var(--accent));
  color: #fff;
  font-weight: 800;
}

.signin-head h2 {
  margin-bottom: 6px;
}

.signin-button {
  width: 100%;
}

.view {
  display: none;
}

.view.is-active {
  display: block;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.metric {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel-bg);
  box-shadow: var(--shadow-sm);
  padding: 14px 16px;
}

.metric::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--accent-alt), var(--accent-warm));
}

.metric strong {
  display: block;
  margin-top: 3px;
  font-size: 24px;
}

.planning-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
  align-items: start;
  margin-bottom: 14px;
}

.planning-layout.has-panel {
  grid-template-columns: minmax(0, 1fr) minmax(320px, 380px);
}

.planning-main {
  min-width: 0;
}

.planning-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.planning-tabs {
  display: flex;
  gap: 6px;
  min-width: 0;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-elevated);
  padding: 4px;
}

button.planning-tab {
  min-height: 34px;
  border-color: transparent;
  background: transparent;
  color: var(--muted);
  box-shadow: none;
}

button.planning-tab.is-active {
  border-color: var(--accent);
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: var(--button-text);
  box-shadow: 0 8px 20px rgba(36, 119, 100, 0.16);
}

.planning-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.planning-page {
  display: none;
}

.planning-page.is-active {
  display: block;
}

.epic-side-panel {
  position: sticky;
  top: 18px;
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
  margin-bottom: 14px;
}

.tool-panel,
.work-area,
.three-columns > section {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel-bg);
  box-shadow: var(--shadow-sm);
  padding: 16px;
}

.tool-panel label {
  display: grid;
  gap: 6px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 13px;
}

.tool-panel button[type="submit"] {
  width: 100%;
  margin-top: 14px;
}

.epic-config-panel button[type="submit"] {
  width: auto;
  margin-top: 0;
}

.epic-form-actions {
  align-items: stretch;
  margin-top: 14px;
}

.epic-form-actions button {
  flex: 1 1 140px;
}

.dependency-field {
  position: relative;
  display: grid;
  gap: 6px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 13px;
}

.dependency-field > button {
  justify-content: space-between;
  width: 100%;
  min-height: 38px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dependency-field > button::after {
  content: "";
  width: 0;
  height: 0;
  margin-left: 10px;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 5px solid currentColor;
}

.dependency-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 12;
  display: grid;
  gap: 4px;
  max-height: 240px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow-md);
  padding: 6px;
}

.dependency-option {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: start;
  gap: 8px;
  margin: 0;
  border-radius: 6px;
  padding: 8px;
  color: var(--text);
  cursor: pointer;
}

.dependency-option:hover {
  background: var(--field-strong);
}

.dependency-option input {
  width: auto;
  margin-top: 2px;
}

.dependency-option span {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.dependency-option strong,
.dependency-option small {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dependency-option small,
.dependency-empty {
  color: var(--muted);
  font-size: 12px;
}

.dependency-empty {
  padding: 8px;
}

.project-settings-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 2px;
}

.project-id-hint {
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  opacity: 0.72;
}

.project-settings-form button[type="submit"] {
  width: auto;
  margin-top: 0;
}

.project-form-actions {
  align-items: stretch;
  justify-content: flex-start;
  margin-top: 14px;
}

.project-form-actions button {
  flex: 0 0 auto;
}

.split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.section-head,
.panel-head {
  justify-content: space-between;
  margin-bottom: 12px;
}

.legend {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  flex-wrap: wrap;
}

.timeline-head-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.gantt-zoom-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}

.gantt-zoom-controls output {
  min-width: 48px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

#ganttEditToggle.is-active {
  border-color: var(--accent);
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: var(--button-text);
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

.planned {
  background: var(--planned);
}

.in_progress {
  background: var(--progress);
}

.blocked {
  background: var(--blocked);
}

.done {
  background: var(--done);
}

.gantt {
  --gantt-label-width: 220px;
  display: block;
  min-height: 120px;
  overflow-x: auto;
  padding: 2px 0 4px;
}

.gantt-canvas {
  display: grid;
  gap: 8px;
  min-width: calc(var(--gantt-label-width) + var(--timeline-width));
}

.gantt-row {
  display: grid;
  grid-template-columns: var(--gantt-label-width) var(--timeline-width);
  align-items: center;
}

.gantt-label {
  position: sticky;
  left: 0;
  z-index: 3;
  display: grid;
  align-content: center;
  height: 34px;
  min-width: 0;
  border-right: 1px solid var(--border);
  background: var(--surface-elevated);
  color: var(--muted);
  font-size: 13px;
  padding-right: 12px;
  overflow: hidden;
}

.gantt-label span,
.gantt-label small {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gantt-label small {
  margin-top: 2px;
  font-size: 11px;
}

.gantt-scale-label {
  height: 34px;
}

.gantt-track {
  position: relative;
  height: 34px;
  border-radius: 6px;
  background: var(--track);
  overflow: visible;
}

.gantt-scale-track {
  background: var(--track-alt);
}

.gantt-gridline,
.gantt-tick {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  background: var(--gridline);
  pointer-events: none;
}

.gantt-gridline.is-major,
.gantt-tick.is-major {
  background: var(--gridline-major);
}

.gantt-date-line {
  position: absolute;
  top: 0;
  bottom: 0;
  z-index: 1;
  width: 1px;
  border-left: 1px dashed var(--accent-warm);
  opacity: 0.74;
  pointer-events: none;
}

.gantt-important-date {
  position: absolute;
  top: 4px;
  z-index: 4;
  display: grid;
  place-items: center;
  width: 18px;
  height: 26px;
  min-height: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--accent-warm);
  padding: 0;
  box-shadow: none;
  transform: translateX(-9px);
  touch-action: none;
}

.gantt-important-date span {
  width: 12px;
  height: 12px;
  border: 2px solid var(--surface);
  border-radius: 50%;
  background: var(--accent-warm);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent-warm) 34%, transparent);
}

.gantt-important-date:hover,
.gantt-important-date:focus-visible {
  color: var(--accent-warm);
  background: transparent;
  box-shadow: none;
  transform: translateX(-9px) translateY(-1px);
}

.gantt.is-adjusting .gantt-important-date {
  cursor: ew-resize;
}

.gantt-important-date.is-dragging span {
  box-shadow:
    0 0 0 3px color-mix(in srgb, var(--accent-warm) 36%, transparent),
    0 8px 18px rgba(0, 0, 0, 0.22);
}

.gantt-tick span {
  position: absolute;
  top: 4px;
  left: 6px;
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}

.gantt-bar {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  appearance: none;
  top: 7px;
  height: 20px;
  min-width: 14px;
  min-height: 0;
  border: 0;
  border-radius: 4px;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 0;
  cursor: pointer;
  overflow: hidden;
  touch-action: none;
  user-select: none;
  z-index: 2;
}

.gantt-bar:hover,
.gantt-bar:focus-visible {
  filter: brightness(0.92);
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

.gantt.is-adjusting .gantt-bar {
  cursor: grab;
}

.gantt.is-adjusting .gantt-bar.is-dragging {
  cursor: grabbing;
  filter: brightness(0.9);
  z-index: 5;
}

.gantt.is-dragging {
  user-select: none;
}

.gantt-row.is-dependency-dimmed .gantt-label,
.gantt-row.is-dependency-dimmed .gantt-bar {
  opacity: 0.38;
}

.gantt-row.is-dependency-source .gantt-label {
  color: var(--text);
}

.gantt-bar.is-dependency-source {
  outline: 2px solid var(--accent-warm);
  outline-offset: 2px;
}

.gantt-bar.is-dependency-dependent {
  box-shadow:
    0 0 0 2px color-mix(in srgb, var(--accent-warm) 72%, transparent),
    0 8px 18px rgba(201, 124, 34, 0.24);
  filter: saturate(1.16);
}

.gantt-bar-label {
  min-width: 0;
  overflow: hidden;
  padding: 0 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
  pointer-events: none;
}

.gantt-handle {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 10px;
  opacity: 0;
  pointer-events: none;
}

.gantt-handle::after {
  content: "";
  position: absolute;
  top: 4px;
  bottom: 4px;
  left: 4px;
  width: 2px;
  border-radius: 999px;
  background: var(--bar-handle);
}

.gantt-handle.is-start {
  left: 0;
}

.gantt-handle.is-end {
  right: 0;
}

.gantt.is-adjusting .gantt-handle {
  cursor: ew-resize;
  opacity: 0.8;
  pointer-events: auto;
}

.board,
.three-columns {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.planning-page .board {
  margin-top: 0;
}

.board-column {
  min-height: 120px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--field-strong);
  padding: 10px;
}

.board-column h3 {
  margin-bottom: 8px;
}

.list {
  display: grid;
  gap: 10px;
}

.item {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-elevated);
  padding: 12px;
  box-shadow: 0 8px 20px rgba(31, 47, 58, 0.05);
}

.item-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.item-title {
  font-weight: 700;
}

.item-meta {
  color: var(--muted);
  font-size: 13px;
}

.item-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.compact .item {
  padding: 10px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 0 9px;
  color: #fff;
  font-size: 12px;
}

.status-box {
  display: grid;
  gap: 6px;
  color: var(--muted);
}

.email-status-card {
  display: grid;
  gap: 10px;
  color: var(--text);
}

.email-page {
  display: grid;
  gap: 14px;
}

.email-account-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel-bg);
  box-shadow: var(--shadow-sm);
  padding: 16px;
}

.email-account-bar h2 {
  margin-bottom: 8px;
}

.email-account-summary {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.email-account-copy {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.email-account-copy strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.email-account-copy span:not(.email-account-label) {
  color: var(--muted);
  font-size: 13px;
}

.email-account-label {
  color: var(--muted);
  font-size: 12px;
}

.email-account-actions {
  justify-content: flex-end;
  flex-wrap: wrap;
}

.email-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 420px);
  gap: 14px;
  align-items: start;
}

.email-inbox-panel {
  min-height: 360px;
}

.email-list {
  display: grid;
  gap: 8px;
}

.email-message {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-elevated);
  padding: 12px;
}

.email-message-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.email-message-sender,
.email-message-subject {
  overflow-wrap: anywhere;
}

.email-message-sender {
  font-weight: 700;
}

.email-message-subject {
  margin-top: 2px;
}

.email-message-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 12px;
}

.email-message-preview {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.email-empty-state {
  display: grid;
  gap: 4px;
  border: 1px dashed var(--border);
  border-radius: 8px;
  color: var(--muted);
  padding: 14px;
}

.email-empty-state strong {
  color: var(--text);
}

.email-compose-form label,
.email-import-form label {
  display: grid;
  gap: 6px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 13px;
}

.email-import-section {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel-bg);
  box-shadow: var(--shadow-sm);
  padding: 0;
}

.email-import-section summary {
  cursor: pointer;
  padding: 14px 16px;
  font-weight: 700;
}

.email-import-grid {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  gap: 16px;
  border-top: 1px solid var(--border);
  padding: 16px;
}

.email-import-form {
  display: grid;
  align-content: start;
}

.email-import-form button[type="submit"] {
  justify-self: start;
  margin-top: 14px;
}

.analyzed-email-item .item-meta:last-child {
  margin-top: 6px;
}

.config-grid.compact-config {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 0;
}

.config-grid.compact-config .config-row {
  padding: 9px;
}

.identity-chip,
.user-summary,
.auth-current {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.identity-chip {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-elevated);
  padding: 6px;
  box-shadow: var(--shadow-sm);
}

.identity-copy {
  display: grid;
  min-width: 0;
}

.identity-copy strong {
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}

.identity-copy span {
  color: var(--muted);
  font-size: 12px;
}

.compact-button {
  min-height: 32px;
  padding: 0 10px;
}

.user-symbol {
  position: relative;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
}

.user-symbol small {
  position: absolute;
  right: -4px;
  bottom: -4px;
  display: grid;
  place-items: center;
  width: 17px;
  height: 17px;
  border: 2px solid var(--surface);
  border-radius: 999px;
  background: var(--text);
  color: #fff;
  font-size: 9px;
  line-height: 1;
}

.user-symbol.role-admin {
  background: linear-gradient(135deg, #7b5ba6, var(--accent-alt));
}

.user-symbol.role-member {
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
}

.user-symbol.role-viewer {
  background: linear-gradient(135deg, var(--accent-alt), #4f6f1f);
}

.user-symbol.role-inactive {
  background: linear-gradient(135deg, #7d8790, #3f4750);
}

.auth-current {
  color: var(--text);
}

.auth-current .user-symbol {
  width: 30px;
  height: 30px;
  flex-basis: 30px;
  font-size: 11px;
}

.auth-current > div {
  display: grid;
  gap: 1px;
  min-width: 0;
}

.auth-current strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
}

.auth-current span {
  color: var(--muted);
  font-size: 12px;
}

.access-work-area {
  display: grid;
  gap: 16px;
}

.access-section-head {
  align-items: start;
  margin-bottom: 0;
}

.access-section-head p {
  margin-top: 4px;
  font-size: 13px;
}

.access-status {
  gap: 12px;
}

.access-status-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.access-status-item {
  display: grid;
  gap: 4px;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--field-strong);
  padding: 10px;
}

.access-status-item span {
  color: var(--muted);
  font-size: 12px;
}

.access-status-item strong {
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--text);
  font-size: 13px;
  font-weight: 650;
}

.access-subhead {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
}

.access-subhead h3 {
  font-size: 14px;
}

.invite-status {
  min-height: 18px;
  overflow-wrap: anywhere;
  font-size: 13px;
  text-align: right;
}

.user-item select {
  max-width: 160px;
}

.user-item {
  padding: 14px;
}

.user-item .item-head {
  align-items: center;
  margin-bottom: 0;
}

.user-copy {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.user-copy .item-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-meta-row {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
  flex-wrap: wrap;
}

.user-meta-row span {
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-meta-row span:not(:last-child)::after {
  content: "";
  display: inline-block;
  width: 3px;
  height: 3px;
  margin-left: 6px;
  border-radius: 999px;
  background: var(--border-strong);
  vertical-align: middle;
}

.user-role-controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.invite-user-form {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(140px, 180px) minmax(96px, 120px) auto;
  gap: 10px 12px;
  align-items: end;
  border: 1px solid var(--border);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(68, 208, 173, 0.08), rgba(134, 174, 254, 0.05)),
    var(--field);
  padding: 12px;
}

.invite-user-form label {
  display: grid;
  gap: 6px;
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.invite-user-form input,
.invite-user-form select {
  min-height: 40px;
}

.invite-user-form button {
  min-height: 40px;
}

.access-user-list {
  margin-top: -4px;
}

.empty-state {
  border: 1px dashed var(--border-strong);
  border-radius: 8px;
  background: var(--field-strong);
  padding: 14px;
  text-align: center;
}

.admin-layout {
  display: grid;
  grid-template-columns: minmax(180px, 220px) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.questions-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 380px);
  gap: 14px;
  align-items: start;
}

.question-chat,
.question-sources {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel-bg);
  box-shadow: var(--shadow-sm);
  padding: 16px;
}

.question-status {
  margin-bottom: 12px;
}

.chat-log {
  display: grid;
  align-content: start;
  gap: 10px;
  min-height: 360px;
  max-height: min(58vh, 640px);
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--field-strong);
  padding: 12px;
}

.chat-empty {
  align-self: center;
  justify-self: center;
}

.chat-message {
  display: grid;
  gap: 6px;
  max-width: min(760px, 88%);
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-elevated);
  padding: 10px 12px;
}

.chat-message.user {
  justify-self: end;
  border-color: var(--accent);
  background: var(--message-user);
}

.chat-message.assistant {
  justify-self: start;
}

.chat-message.is-pending {
  color: var(--muted);
}

.chat-message.is-error {
  border-color: var(--danger);
  background: var(--danger-soft);
}

.chat-role {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.chat-role span {
  font-weight: 500;
}

.chat-content {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.45;
}

.question-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
  margin-top: 12px;
}

.question-form label {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 13px;
}

.question-form textarea {
  min-height: 76px;
}

.question-form button {
  min-width: 88px;
  min-height: 76px;
}

.plan-message-dock {
  position: fixed;
  left: 18px;
  bottom: 18px;
  z-index: 30;
  display: grid;
  gap: 10px;
  width: min(420px, calc(100vw - 36px));
  pointer-events: none;
}

.plan-message-toggle,
.plan-message-panel {
  pointer-events: auto;
}

.plan-message-toggle {
  justify-self: start;
  min-width: 112px;
  box-shadow: var(--shadow-md);
}

.plan-message-panel {
  display: grid;
  gap: 10px;
  max-height: min(560px, calc(100vh - 112px));
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel-bg);
  box-shadow: var(--shadow-lg);
  padding: 14px;
}

.plan-message-status {
  font-size: 13px;
}

.plan-message-log {
  display: grid;
  align-content: start;
  gap: 10px;
  min-height: 150px;
  max-height: min(260px, 34vh);
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--field-strong);
  padding: 10px;
}

.plan-message-log .chat-message {
  max-width: 100%;
}

.plan-message-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
}

.plan-message-form label {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 13px;
}

.plan-message-form textarea {
  min-height: 72px;
}

.plan-message-form button {
  min-width: 78px;
  min-height: 72px;
}

.source-item .item-head {
  margin-bottom: 6px;
}

.admin-menu {
  display: grid;
  gap: 8px;
  align-content: start;
}

.admin-menu-item {
  width: 100%;
  justify-content: flex-start;
  border-color: var(--border);
  background: var(--surface-elevated);
  color: var(--text);
  box-shadow: none;
}

.admin-menu-item.is-active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.admin-panel {
  display: none;
}

.admin-panel.is-active {
  display: block;
}

.admin-panels {
  min-width: 0;
}

.admin-denied p {
  margin-top: 6px;
}

.config-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.config-row {
  display: grid;
  gap: 5px;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--field-strong);
  padding: 11px;
}

.config-row span {
  color: var(--muted);
  font-size: 12px;
}

.config-row strong {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 14px;
}

.admin-account-list {
  margin-top: 12px;
}

pre {
  min-height: 80px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--code-bg);
  color: var(--code-text);
  padding: 12px;
}

.hidden {
  display: none !important;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(420px, calc(100vw - 36px));
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-elevated);
  box-shadow: var(--shadow-md);
  padding: 12px 14px;
  transform: translateY(120%);
  transition: transform 160ms ease;
}

.toast.is-visible {
  transform: translateY(0);
}

@media (max-width: 1100px) {
  .planning-layout.has-panel {
    grid-template-columns: 1fr;
  }

  .epic-side-panel {
    position: static;
  }
}

@media (max-width: 900px) {
  .topbar,
  .workspace-grid,
  .admin-layout,
  .welcome-shell,
  .board,
  .three-columns,
  .questions-layout,
  .email-workspace,
  .email-import-grid,
  .metrics,
  .config-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    display: grid;
  }

  .topbar-actions {
    justify-content: stretch;
    flex-wrap: wrap;
  }

  .identity-chip {
    flex: 1 1 280px;
  }

  .theme-toggle {
    flex: 0 0 auto;
  }

  .project-switcher,
  .tabs {
    overflow-x: auto;
  }

  .planning-toolbar {
    align-items: stretch;
    flex-wrap: wrap;
  }

  .planning-actions {
    justify-content: stretch;
    width: 100%;
  }

  .access-status-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .invite-user-form {
    grid-template-columns: minmax(0, 1fr) minmax(140px, 180px) minmax(96px, 120px);
  }

  .invite-user-form label:first-child {
    grid-column: 1 / -1;
  }

  .invite-user-form button {
    grid-column: 1 / -1;
  }

  .user-item .item-head {
    align-items: stretch;
    display: grid;
  }

  .user-role-controls {
    justify-content: start;
  }

  .planning-actions button {
    flex: 1 1 140px;
  }
}

@media (max-width: 640px) {
  main,
  .topbar {
    padding-left: 16px;
    padding-right: 16px;
  }

  .tabs {
    padding-left: 16px;
    padding-right: 16px;
  }

  .welcome-view {
    padding: 18px;
  }

  .welcome-copy {
    display: grid;
    padding: 10px 0;
  }

  .welcome-copy h1 {
    font-size: 30px;
  }

  .welcome-copy p:last-child {
    font-size: 15px;
  }

  .identity-chip,
  .project-switcher,
  .theme-toggle {
    width: 100%;
  }

  .planning-actions,
  .planning-tabs {
    width: 100%;
  }

  .metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .planning-tab {
    flex: 1 0 auto;
  }

  .gantt {
    --gantt-label-width: 160px;
  }

  .split,
  .question-form,
  .plan-message-form,
  .invite-user-form {
    grid-template-columns: 1fr;
  }

  .access-section-head,
  .access-subhead {
    align-items: stretch;
    display: grid;
  }

  .access-status-grid {
    grid-template-columns: 1fr;
  }

  .invite-status {
    text-align: left;
  }

  .user-role-controls {
    align-items: stretch;
    display: grid;
    grid-template-columns: 1fr;
  }

  .user-item select {
    max-width: none;
  }

  .chat-log {
    min-height: 320px;
    max-height: none;
  }

  .chat-message {
    max-width: 100%;
  }

  .question-form button {
    min-height: 42px;
  }

  .email-account-bar,
  .email-account-summary,
  .email-message-head {
    display: grid;
  }

  .email-account-actions,
  .email-account-actions button,
  .email-message-meta {
    width: 100%;
  }

  .email-message-meta {
    justify-content: flex-start;
  }

  .plan-message-dock {
    left: 12px;
    right: 12px;
    bottom: 12px;
    width: auto;
  }

  .plan-message-panel {
    max-height: calc(100vh - 88px);
  }

  .plan-message-form button {
    min-height: 42px;
  }
}
