:root {
  --bg: #f7f8fa;
  --surface: #ffffff;
  --surface-2: #eef2f6;
  --line: #d8dee8;
  --text: #1d2633;
  --muted: #657181;
  --blue: #2563eb;
  --green: #16835c;
  --pink: #b83280;
  --amber: #b7791f;
  --danger: #b42318;
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
}

body {
  margin: 0;
  color: var(--text);
  background: var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.45;
  letter-spacing: 0;
}

body.mode-play {
  --bg: #f6f7fb;
  --surface-2: #edf7f2;
  --blue: #0f766e;
  --green: #5b7c23;
  --pink: #a21caf;
  --amber: #c2410c;
}

a {
  color: inherit;
  text-decoration: none;
}

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

button,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
}

button:hover,
.button:hover {
  border-color: var(--blue);
}

.primary {
  border-color: var(--blue);
  background: var(--blue);
  color: #fff;
}

input,
textarea,
select {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  background: #fff;
  color: var(--text);
}

textarea {
  resize: vertical;
}

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

label input,
label textarea,
label select {
  color: var(--text);
}

fieldset {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
}

legend {
  color: var(--muted);
  padding: 0 6px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 14px;
  padding: 10px 18px;
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(8px);
}

.brand {
  font-weight: 800;
  letter-spacing: 0;
}

.nav {
  display: flex;
  align-items: center;
  gap: 2px;
  overflow-x: auto;
  scrollbar-width: thin;
}

.nav a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 0 9px;
  border-radius: 6px;
  color: var(--muted);
  white-space: nowrap;
}

.nav a:hover {
  color: var(--text);
  background: var(--surface-2);
}

.nav span {
  min-width: 20px;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--pink);
  color: #fff;
  font-size: 12px;
  text-align: center;
}

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

.page {
  max-width: 1440px;
  margin: 0 auto;
  padding: 24px;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

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

h1 {
  margin-bottom: 2px;
  font-size: 30px;
  line-height: 1.1;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 12px;
  font-size: 16px;
  letter-spacing: 0;
}

p {
  color: var(--muted);
}

.flash-stack {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
}

.flash {
  padding: 10px 12px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--surface);
}

.flash-success {
  border-color: #96d4bc;
  color: #064e3b;
}

.flash-error {
  border-color: #f2aaa2;
  color: var(--danger);
}

.auth-panel {
  max-width: 520px;
  margin: 70px auto;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.stack {
  display: grid;
  gap: 12px;
}

.tight {
  gap: 8px;
}

.row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.row.shrink {
  justify-content: flex-end;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  align-items: end;
}

.form-grid.compact {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.span-2 {
  grid-column: span 2;
}

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  color: var(--text);
}

.check input {
  width: 16px;
  min-height: 16px;
}

.panel,
.capture-band,
.capture-focus {
  margin-bottom: 16px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.capture-band textarea,
.capture-focus textarea {
  font-size: 18px;
}

.capture-focus {
  max-width: 920px;
  margin: 30px auto;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  align-items: start;
}

.wide {
  grid-column: span 2;
}

.two-col {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

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

.item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  min-height: 42px;
  padding: 9px 0;
  border-top: 1px solid var(--line);
}

.item:first-child {
  border-top: 0;
}

.item strong {
  min-width: 0;
  overflow-wrap: anywhere;
}

.item span,
.item small {
  color: var(--muted);
  font-size: 13px;
  text-align: right;
}

.empty {
  padding: 18px 0;
  color: var(--muted);
}

.project-strip,
.project-grid {
  display: grid;
  gap: 10px;
}

.project-strip {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

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

.project-card {
  display: grid;
  gap: 6px;
  min-height: 96px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.project-card:hover {
  border-color: var(--blue);
}

.project-card.tall {
  min-height: 170px;
}

.project-card p {
  margin-bottom: 0;
  overflow-wrap: anywhere;
}

.project-card em,
.project-card small {
  color: var(--muted);
  font-style: normal;
}

.area-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 6px;
  border-radius: 999px;
}

.item-panel p {
  margin: 6px 0 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.item-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
}

.badges {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.badges span,
code {
  display: inline-flex;
  min-height: 22px;
  align-items: center;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.inline-form {
  display: grid;
  grid-template-columns: 130px minmax(0, 1fr) 150px 180px auto;
  gap: 8px;
  margin-top: 12px;
  align-items: center;
}

.kanban {
  display: grid;
  grid-template-columns: repeat(6, minmax(230px, 1fr));
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 8px;
}

.column {
  min-width: 230px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fdfefe;
}

.column h2 {
  display: flex;
  justify-content: space-between;
}

.column h2 span {
  color: var(--muted);
}

.task-card {
  padding: 10px;
  margin-bottom: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.filters {
  display: flex;
  gap: 8px;
  align-items: center;
}

.filters input,
.filters select {
  min-width: 180px;
}

.calendar-item {
  grid-template-columns: minmax(0, 1fr) minmax(220px, auto);
}

.proposal {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}

.proposal:first-child {
  border-top: 0;
}

.run {
  border-top: 1px solid var(--line);
  padding: 10px 0;
}

.run pre {
  max-height: 360px;
  overflow: auto;
  padding: 12px;
  background: #101828;
  color: #f2f4f7;
  border-radius: 6px;
  white-space: pre-wrap;
}

.secret-box {
  display: grid;
  gap: 5px;
  margin: 12px 0;
}

.secret-box code {
  display: block;
  padding: 10px;
  border-radius: 6px;
  overflow-wrap: anywhere;
}

@media (max-width: 1100px) {
  .dashboard-grid,
  .project-grid,
  .two-col {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

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

@media (max-width: 720px) {
  .topbar {
    grid-template-columns: 1fr auto;
  }

  .nav {
    grid-column: 1 / -1;
    order: 3;
  }

  .page {
    padding: 16px;
  }

  .page-head {
    align-items: stretch;
    flex-direction: column;
  }

  .dashboard-grid,
  .project-grid,
  .project-strip,
  .two-col,
  .form-grid,
  .form-grid.compact {
    grid-template-columns: 1fr;
  }

  .wide,
  .span-2 {
    grid-column: auto;
  }

  .row,
  .inline-form {
    display: grid;
    grid-template-columns: 1fr;
  }

  .item,
  .item-head,
  .proposal,
  .calendar-item {
    grid-template-columns: 1fr;
  }

  .item span,
  .item small {
    text-align: left;
  }

  h1 {
    font-size: 26px;
  }
}
