:root {
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #575279;
  background: #faf4ed;
  font-synthesis: none;
  text-rendering: geometricPrecision;
  --base: #faf4ed;
  --surface: #fffaf5;
  --overlay: #f2e9e1;
  --muted: #9893a5;
  --text: #575279;
  --accent: #d7827e;
  --accent-soft: rgba(215, 130, 126, 0.12);
  --border: rgba(87, 82, 121, 0.12);
  --border-strong: rgba(87, 82, 121, 0.2);
  --foam: #56949f;
  --pine: #286983;
  --gold: #ea9d34;
  --love: #b4637a;
  --iris: #907aa9;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--base);
}

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

button {
  cursor: pointer;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 18px;
}

.login-box {
  width: min(360px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 22px;
  box-shadow: 0 18px 45px rgba(87, 82, 121, 0.08);
}

.login-box h1,
.page-header h1 {
  font-size: 18px;
  margin: 0 0 3px;
  font-weight: 560;
}

.login-box p,
.page-header p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.login-box form,
.modal form {
  margin-top: 18px;
  display: grid;
  gap: 10px;
}

label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 550;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--border-strong);
  background: rgba(255, 250, 245, 0.78);
  border-radius: 7px;
  padding: 8px 10px;
  outline: none;
}

textarea {
  resize: vertical;
  min-height: 96px;
}

.speech-field {
  position: relative;
  display: block;
}

.speech-field textarea {
  padding-right: 46px;
}

.speech-button {
  position: absolute;
  top: 7px;
  right: 7px;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  background: var(--surface);
  color: var(--pine);
}

.speech-button:hover {
  background: var(--overlay);
}

.speech-button svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.speech-button.recording {
  border-color: var(--love);
  background: rgba(180, 99, 122, 0.12);
  color: var(--love);
}

.speech-button.transcribing {
  opacity: 0.62;
  cursor: wait;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.shell {
  display: flex;
  min-height: 100vh;
  background: var(--base);
}

.sidebar {
  width: 236px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  background: rgba(242, 233, 225, 0.42);
  padding: 14px 10px;
  transition: width 140ms ease, padding 140ms ease;
}

.workspace {
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 5px 8px;
  font-size: 13px;
  position: relative;
}

.workspace strong {
  display: block;
  font-weight: 560;
}

.workspace small {
  color: var(--muted);
  font-size: 11px;
}

.workspace-mark {
  height: 26px;
  width: 26px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  overflow: hidden;
  background: #ef7a2f;
}

.workspace-mark img {
  width: 100%;
  height: 100%;
  display: block;
}

.workspace-copy {
  min-width: 0;
}

.project-list {
  margin-top: 18px;
  flex: 1;
  overflow: auto;
}

.nav-group {
  margin: 18px 10px 7px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 550;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.project-button {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 0;
  text-align: left;
  background: transparent;
  border-radius: 6px;
  padding: 7px 8px;
  font-size: 13px;
  margin-bottom: 2px;
  min-height: 34px;
}

.project-button.active {
  background: var(--accent-soft);
  color: var(--accent);
}

.project-button small {
  display: block;
  color: var(--muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.project-initial {
  width: 22px;
  height: 22px;
  flex: 0 0 22px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  background: rgba(87, 82, 121, 0.08);
  color: var(--text);
  font-size: 12px;
  font-weight: 650;
  text-transform: uppercase;
}

.project-copy {
  min-width: 0;
}

.project-copy > span {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-footer {
  border-top: 1px solid var(--border);
  padding: 12px 8px 3px;
  display: grid;
  gap: 8px;
}

.content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  min-height: 48px;
  flex-shrink: 0;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 8px 20px;
  gap: 12px;
  font-size: 12px;
}

.crumb {
  flex: 1;
  min-width: 0;
}

.project-select {
  display: none;
}

.mobile-sidebar-toggle {
  display: none;
}

.board-page {
  display: flex;
  min-height: 0;
  flex: 1;
}

.board-area {
  display: flex;
  min-width: 0;
  flex: 1;
  flex-direction: column;
}

.page-header {
  min-height: 74px;
  flex-shrink: 0;
  padding: 15px 22px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
}

.header-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.primary-button,
.quiet-button,
.danger-button {
  min-height: 32px;
  border-radius: 7px;
  padding: 0 13px;
  border: 1px solid var(--border-strong);
  background: transparent;
  font-size: 13px;
}

.primary-button {
  border-color: var(--accent);
  color: #fffaf5;
  background: var(--accent);
}

.primary-button:hover {
  border-color: #c36f6c;
  background: #c97874;
}

.quiet-button:hover {
  background: var(--overlay);
}

.danger-button {
  color: var(--love);
}

.primary-button:disabled,
.danger-button:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

.board {
  flex: 1;
  min-height: 0;
  display: flex;
  overflow-x: auto;
}

.column {
  min-width: 228px;
  width: 20%;
  max-width: 20%;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: background 130ms ease;
}

.column.drop-target {
  background: rgba(215, 130, 126, 0.055);
}

.column > header {
  height: 45px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 12px;
  gap: 8px;
  font-size: 12px;
  font-weight: 550;
}

.column > header small {
  min-width: 19px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 3px 6px;
  line-height: 1;
  border-radius: 10px;
  background: var(--overlay);
  color: var(--muted);
}

.task-list {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 10px;
  display: grid;
  align-content: start;
  gap: 8px;
  min-width: 0;
}

.task-card {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  text-align: left;
  border: 1px solid var(--border);
  background: rgba(255, 250, 245, 0.9);
  border-radius: 8px;
  padding: 10px;
  display: grid;
  gap: 8px;
  overflow: hidden;
  cursor: pointer;
}

.task-card-top {
  display: flex;
  gap: 8px;
  min-width: 0;
}

.task-card-top small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

.priority-badge {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  border-radius: 10px;
  padding: 3px 8px;
  line-height: 1;
}

.priority-p0 {
  color: #fffaf5;
  background: var(--love);
}

.priority-p1 {
  color: #5c3b00;
  background: rgba(234, 157, 52, 0.26);
}

.priority-p2 {
  color: var(--pine);
  background: rgba(86, 148, 159, 0.16);
}

.priority-p3 {
  color: var(--muted);
  background: var(--overlay);
}

.task-card:hover,
.task-card.selected {
  border-color: rgba(215, 130, 126, 0.45);
  box-shadow: 0 8px 20px rgba(87, 82, 121, 0.06);
}

.task-card.dragging {
  opacity: 0.35;
}

.task-card strong {
  color: var(--text);
  font-size: 13px;
  line-height: 1.3;
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.task-description {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
  white-space: pre-wrap;
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.task-description.clamped {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 4;
  overflow: hidden;
}

.description-toggle {
  justify-self: start;
  border: 0;
  background: transparent;
  color: var(--love);
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
  padding: 0;
  cursor: pointer;
}

.description-toggle:hover {
  color: var(--gold);
}

.drawer {
  width: 360px;
  flex-shrink: 0;
  border-left: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  flex-direction: column;
}

.drawer header {
  min-height: 52px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
}

.drawer-body {
  padding: 14px;
  display: grid;
  gap: 12px;
  overflow: auto;
}

.drawer-body h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 560;
}

.drawer-body p {
  margin: 0;
  white-space: pre-wrap;
  line-height: 1.45;
}

.activity {
  border-top: 1px solid var(--border);
  padding-top: 12px;
  display: grid;
  gap: 7px;
}

.activity-row {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.35;
}

.settings-page {
  min-height: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.dashboard-page {
  min-height: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.dashboard-body {
  flex: 1;
  overflow: auto;
  padding: 18px 22px 28px;
  display: grid;
  gap: 18px;
  align-content: start;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(120px, 1fr));
  gap: 10px;
}

.metric-card {
  border-top: 1px solid var(--border);
  padding-top: 10px;
  display: grid;
  gap: 7px;
}

.metric-card span,
.pace-list span {
  color: var(--muted);
  font-size: 12px;
}

.metric-card strong {
  color: var(--text);
  font-size: 24px;
  font-weight: 560;
  line-height: 1.1;
}

.dashboard-panel {
  max-width: 840px;
  display: grid;
  gap: 12px;
}

.dashboard-panel h2 {
  margin: 0;
  font-size: 14px;
  font-weight: 560;
}

.metric-bars {
  display: grid;
  gap: 9px;
}

.metric-bar-row {
  display: grid;
  grid-template-columns: 150px minmax(120px, 1fr) 36px;
  gap: 10px;
  align-items: center;
  font-size: 12px;
}

.metric-bar-row span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.metric-bar-row strong {
  text-align: right;
  font-weight: 560;
}

.metric-bar-track {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--overlay);
}

.metric-bar-fill {
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}

.pace-list {
  display: grid;
  gap: 8px;
  max-width: 520px;
}

.pace-list div {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  border-top: 1px solid var(--border);
  padding-top: 8px;
}

.pace-list strong {
  font-weight: 560;
}

.settings-body {
  flex: 1;
  overflow: auto;
  padding: 18px 22px 28px;
  display: grid;
  gap: 18px;
  align-content: start;
}

.settings-panel {
  display: grid;
  gap: 12px;
  max-width: 840px;
}

.settings-panel h2 {
  margin: 0;
  font-size: 14px;
  font-weight: 560;
}

.settings-form {
  display: grid;
  gap: 10px;
  max-width: 520px;
}

.project-admin-list {
  display: grid;
  gap: 10px;
}

.project-admin-row {
  border-top: 1px solid var(--border);
  padding-top: 12px;
  display: grid;
  grid-template-columns: minmax(160px, 220px) minmax(120px, 180px) minmax(220px, 1fr) auto;
  gap: 10px;
  align-items: end;
}

.project-admin-row textarea {
  min-height: 42px;
}

.project-admin-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.agent-key-list {
  display: grid;
  gap: 10px;
}

.agent-key-row {
  border-top: 1px solid var(--border);
  padding-top: 12px;
  display: grid;
  grid-template-columns: minmax(160px, 220px) minmax(220px, 1fr) minmax(140px, 190px);
  gap: 10px;
  align-items: end;
}

.agent-key-row.revoked {
  opacity: 0.64;
}

.key-meta {
  display: grid;
  gap: 5px;
  font-size: 12px;
}

.key-meta strong {
  font-size: 13px;
  font-weight: 560;
}

.key-meta small {
  color: var(--muted);
  line-height: 1.35;
}

.secret-box {
  max-width: 640px;
  display: grid;
  gap: 6px;
  padding: 10px 12px;
  border: 1px solid rgba(234, 157, 52, 0.42);
  border-radius: 8px;
  background: rgba(234, 157, 52, 0.12);
}

.secret-box strong {
  font-size: 13px;
  font-weight: 560;
}

.secret-box code {
  overflow-wrap: anywhere;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
}

.secret-box small {
  color: var(--muted);
  font-size: 12px;
}

.project-access {
  margin: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
  display: grid;
  gap: 6px;
  max-height: 145px;
  overflow: auto;
}

.agent-key-row .project-access {
  grid-column: 1 / -1;
}

.agent-key-row .project-admin-actions {
  grid-column: 1 / -1;
}

.project-access legend {
  color: var(--muted);
  font-size: 12px;
  font-weight: 550;
  padding: 0 4px;
}

.checkbox-row {
  display: flex;
  grid-template-columns: none;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-size: 12px;
  font-weight: 400;
}

.checkbox-row input {
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(87, 82, 121, 0.18);
  display: grid;
  place-items: center;
  padding: 16px;
  z-index: 20;
}

.modal {
  width: min(520px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 18px;
  box-shadow: 0 24px 60px rgba(87, 82, 121, 0.16);
}

.modal h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 560;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--surface);
  border: 0;
  border-radius: 7px;
  padding: 9px 12px;
  font-size: 13px;
}

.empty {
  color: var(--muted);
  font-size: 12px;
  text-align: center;
  padding: 18px 8px;
}

@media (max-width: 820px) {
  .sidebar {
    display: none;
    height: 100vh;
    width: min(280px, 82vw);
    position: fixed;
    top: 0;
    left: 0;
    z-index: 12;
    box-shadow: 18px 0 42px rgba(87, 82, 121, 0.16);
  }

  .sidebar.mobile-open {
    display: flex;
  }

  .mobile-sidebar-toggle {
    display: grid;
    place-items: center;
    width: 30px;
    height: 30px;
    border: 1px solid var(--border);
    border-radius: 7px;
    background: rgba(255, 250, 245, 0.72);
    color: var(--accent);
    line-height: 1;
    font-size: 20px;
    padding: 0;
  }

  .topbar {
    position: sticky;
    top: 0;
    background: var(--base);
    z-index: 5;
  }

  .project-select {
    display: block;
    width: min(240px, 48vw);
  }

  .page-header {
    align-items: flex-start;
    padding: 12px;
  }

  .settings-body {
    padding: 14px 12px 22px;
  }

  .dashboard-body {
    padding: 14px 12px 22px;
  }

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

  .metric-bar-row {
    grid-template-columns: 105px minmax(70px, 1fr) 32px;
  }

  .project-admin-row {
    grid-template-columns: 1fr;
  }

  .agent-key-row {
    grid-template-columns: 1fr;
  }

  .project-admin-actions {
    justify-content: flex-start;
  }

  .board-page {
    display: block;
  }

  .board {
    min-height: calc(100vh - 137px);
    scroll-snap-type: x mandatory;
  }

  .column {
    min-width: min(82vw, 360px);
    max-width: min(82vw, 360px);
    scroll-snap-align: start;
  }

  .drawer {
    position: fixed;
    inset: 0;
    width: auto;
    z-index: 15;
  }
}
