:root {
  color-scheme: dark;
  --bg: #101316;
  --panel: #171b20;
  --panel-strong: #1f252b;
  --line: #2b333b;
  --line-strong: #3a4650;
  --text: #f3f0e8;
  --muted: #a8b0b7;
  --soft: #d8d0bf;
  --green: #2eb67d;
  --green-deep: #184b39;
  --amber: #d89b33;
  --amber-deep: #4b3516;
  --blue: #5897d6;
  --blue-deep: #193c5a;
  --rose: #df6b73;
  --rose-deep: #58242a;
  --violet: #8d7ad9;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.28);
  --radius: 8px;
  --font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    linear-gradient(0deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    var(--bg);
  background-size: 56px 56px;
  font-family: var(--font);
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1480px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 34px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

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

.matrix-mark {
  display: grid;
  grid-template-columns: repeat(2, 18px);
  grid-template-rows: repeat(2, 18px);
  gap: 4px;
  width: 44px;
  height: 44px;
  padding: 3px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #0f1215;
  box-shadow: var(--shadow);
}

.matrix-mark span {
  border-radius: 4px;
}

.matrix-mark span:nth-child(1) {
  background: var(--rose);
}

.matrix-mark span:nth-child(2) {
  background: var(--amber);
}

.matrix-mark span:nth-child(3) {
  background: var(--blue);
}

.matrix-mark span:nth-child(4) {
  background: var(--green);
}

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

h1 {
  font-size: clamp(1.7rem, 2.5vw, 2.4rem);
  line-height: 1;
  font-weight: 760;
}

.brand-block p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.92rem;
}

.topbar-actions,
.modal-actions,
.system-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.command-strip {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 390px);
  gap: 14px;
  align-items: stretch;
  margin-bottom: 14px;
}

.task-entry,
.control-cluster,
.system-row {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(23, 27, 32, 0.92);
  box-shadow: var(--shadow);
}

.task-entry {
  padding: 16px;
}

.task-entry label,
.control-cluster label,
.modal-panel label {
  display: block;
  margin-bottom: 8px;
  color: var(--soft);
  font-size: 0.78rem;
  font-weight: 720;
  text-transform: uppercase;
}

.input-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 96px;
  gap: 10px;
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  padding: 0 12px;
  color: var(--text);
  background: #0d1013;
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(88, 151, 214, 0.18);
}

.primary-button,
.ghost-button,
.icon-button {
  min-height: 42px;
  border-radius: 7px;
  border: 1px solid transparent;
  color: var(--text);
  font-weight: 740;
}

.primary-button {
  background: #f3f0e8;
  color: #111416;
}

.primary-button:hover {
  background: #ffffff;
}

.ghost-button,
.icon-button {
  background: #14181d;
  border-color: var(--line-strong);
}

.ghost-button {
  padding: 0 13px;
}

.ghost-button:hover,
.icon-button:hover {
  border-color: var(--soft);
}

.icon-button {
  width: 42px;
  padding: 0;
  font-family: var(--mono);
}

.parse-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 31px;
  margin-top: 12px;
  color: var(--muted);
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 10px;
  color: var(--soft);
  background: #12161a;
  font-size: 0.78rem;
  white-space: nowrap;
}

.pill.good {
  border-color: rgba(46, 182, 125, 0.42);
  background: var(--green-deep);
}

.pill.warn {
  border-color: rgba(216, 155, 51, 0.46);
  background: var(--amber-deep);
}

.pill.bad {
  border-color: rgba(223, 107, 115, 0.48);
  background: var(--rose-deep);
}

.control-cluster {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 10px;
  padding: 16px;
}

.control-cluster label:first-child,
.control-cluster input {
  grid-column: 1 / -1;
}

.system-row {
  justify-content: space-between;
  min-height: 54px;
  padding: 8px 10px;
  margin-bottom: 14px;
}

.status-pills {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.quadrant-board {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.quadrant {
  min-height: 360px;
  border: 1px solid var(--line);
  border-top-width: 4px;
  border-radius: var(--radius);
  background: rgba(17, 20, 24, 0.94);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.quadrant[data-quadrant="do"] {
  border-top-color: var(--rose);
}

.quadrant[data-quadrant="plan"] {
  border-top-color: var(--amber);
}

.quadrant[data-quadrant="delegate"] {
  border-top-color: var(--blue);
}

.quadrant[data-quadrant="later"] {
  border-top-color: var(--green);
}

.quadrant-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  min-height: 82px;
  padding: 15px;
  border-bottom: 1px solid var(--line);
  background: rgba(31, 37, 43, 0.68);
}

.quadrant-title h2 {
  font-size: 1.02rem;
  line-height: 1.15;
}

.quadrant-title p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.84rem;
}

.count-chip {
  min-width: 38px;
  height: 30px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  display: grid;
  place-items: center;
  font-family: var(--mono);
  color: var(--soft);
  background: #0f1317;
}

.task-list {
  display: grid;
  gap: 10px;
  padding: 12px;
}

.task-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  padding: 11px;
}

.task-card.done {
  opacity: 0.62;
}

.task-main {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  gap: 9px;
}

.task-check {
  width: 22px;
  height: 22px;
  margin-top: 1px;
  accent-color: var(--green);
}

.task-title {
  overflow-wrap: anywhere;
  line-height: 1.35;
  font-weight: 720;
}

.task-card.done .task-title {
  text-decoration: line-through;
}

.task-meta,
.task-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 10px;
}

.task-meta {
  color: var(--muted);
  font-size: 0.78rem;
}

.task-meta span {
  min-height: 24px;
  border-radius: 999px;
  border: 1px solid var(--line);
  padding: 3px 8px;
  background: #111519;
}

.task-actions {
  justify-content: flex-end;
}

.task-actions button {
  min-height: 34px;
  border-radius: 7px;
  border: 1px solid var(--line-strong);
  color: var(--text);
  background: #101419;
  padding: 0 10px;
  font-size: 0.82rem;
  font-weight: 700;
}

.task-actions button:hover {
  border-color: var(--soft);
}

.empty-state {
  min-height: 170px;
  display: grid;
  place-items: center;
  color: var(--muted);
  text-align: center;
  padding: 22px;
}

.modal {
  border: none;
  padding: 0;
  background: transparent;
}

.modal::backdrop {
  background: rgba(0, 0, 0, 0.62);
}

.modal-panel {
  width: min(500px, calc(100vw - 28px));
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 16px;
  color: var(--text);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.modal-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.modal-heading h2 {
  font-size: 1.1rem;
}

.modal-panel input,
.modal-panel select {
  margin-bottom: 14px;
}

.two-up {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.switch-row {
  display: flex;
  gap: 12px;
  margin: 2px 0 16px;
  flex-wrap: wrap;
}

.switch-label {
  display: inline-flex !important;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  margin: 0 !important;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #111519;
  text-transform: none !important;
  font-size: 0.86rem !important;
}

.switch-label input {
  width: 16px;
  min-height: 16px;
  margin: 0;
}

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

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(420px, calc(100vw - 36px));
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 12px 14px;
  color: var(--text);
  background: #14181d;
  box-shadow: var(--shadow);
  transform: translateY(24px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.visible {
  transform: translateY(0);
  opacity: 1;
}

@media (max-width: 980px) {
  .command-strip,
  .quadrant-board {
    grid-template-columns: 1fr;
  }

  .quadrant {
    min-height: 260px;
  }
}

@media (max-width: 650px) {
  .app-shell {
    width: min(100% - 20px, 1480px);
    padding-top: 14px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-actions,
  .topbar-actions button,
  .system-row,
  .input-row,
  .control-cluster,
  .two-up {
    width: 100%;
  }

  .input-row,
  .control-cluster,
  .two-up {
    grid-template-columns: 1fr;
  }

  .topbar-actions button {
    flex: 1;
  }

  .system-row {
    align-items: stretch;
  }

  .system-row > button {
    width: 100%;
  }
}
