:root {
  --ink: #161a1d;
  --ink-2: #28313a;
  --paper: #f6f3ea;
  --surface: #fffdfa;
  --surface-2: #ece8dc;
  --line: rgba(22, 26, 29, .14);
  --muted: #68717a;
  --green: #2f7d6e;
  --blue: #345a8a;
  --amber: #d8a83d;
  --red: #b54147;
  --focus: #f0c75e;
  --shadow: 0 18px 48px rgba(22, 26, 29, .12);
}

* {
  box-sizing: border-box;
}

html {
  background: var(--ink);
  text-size-adjust: 100%;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(52, 90, 138, .16), transparent 36%),
    linear-gradient(315deg, rgba(47, 125, 110, .18), transparent 42%),
  var(--ink);
  font-family: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
  -webkit-tap-highlight-color: rgba(47, 125, 110, .18);
}

button,
input,
select {
  font: inherit;
  font-size: 16px;
}

button {
  cursor: pointer;
  touch-action: manipulation;
}

button:disabled {
  cursor: not-allowed;
  opacity: .52;
}

button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid rgba(240, 199, 94, .7);
  outline-offset: 2px;
}

.app-shell {
  width: min(1440px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 390px 1fr;
  background: var(--paper);
}

.side-panel {
  min-height: 100vh;
  padding: 22px;
  border-right: 1px solid var(--line);
  background: var(--surface);
  display: grid;
  align-content: start;
  gap: 16px;
}

.brand-row,
.workspace-header,
.section-heading.inline,
.profile-card,
.countdown-panel,
.action-strip,
.result-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  color: inherit;
  text-decoration: none;
  font-weight: 900;
  letter-spacing: 0;
}

.brand > span:last-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand-mark {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--ink);
  color: var(--focus);
  font: 900 18px/1 ui-monospace, "SFMono-Regular", Consolas, monospace;
}

.mode-pill,
.status-cluster span,
.timer-board span {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 10px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.panel,
.countdown-panel,
.activity-panel,
.result-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.panel {
  padding: 18px;
}

.section-heading {
  margin-bottom: 16px;
}

.section-heading.inline {
  margin-bottom: 14px;
  align-items: flex-end;
}

.section-heading p,
.eyebrow {
  margin: 0 0 7px;
  color: var(--muted);
  font: 800 10px/1.2 ui-monospace, "SFMono-Regular", Consolas, monospace;
  letter-spacing: .13em;
}

.section-heading h1,
.section-heading h2,
.workspace-header h2,
.countdown-copy h2,
.result-panel h2 {
  margin: 0;
  letter-spacing: 0;
  line-height: 1.12;
}

.section-heading h1 {
  font-size: 24px;
}

.section-heading h2,
.countdown-copy h2,
.result-panel h2 {
  font-size: 20px;
}

.stack-form {
  display: grid;
  gap: 10px;
}

.stack-form label {
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 850;
}

.stack-form input,
.stack-form select {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 0 12px;
}

.stack-form input::placeholder {
  color: #9aa0a6;
}

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

.primary-action,
.tool-button,
.profile-card button {
  border: 0;
  border-radius: 8px;
  min-height: 48px;
  font-weight: 900;
}

.primary-action {
  margin-top: 4px;
  background: var(--ink);
  color: #fff;
}

.field-note {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.55;
}

.profile-card {
  min-height: 96px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--surface-2);
}

.profile-card span,
.profile-card small {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
}

.profile-card strong {
  display: block;
  margin: 5px 0;
  font-size: 18px;
}

.profile-card button {
  padding: 0 14px;
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
}

.switch-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.switch {
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  background: #fff;
}

.switch input {
  width: 18px;
  height: 18px;
  accent-color: var(--green);
}

.switch span {
  color: var(--ink);
  font-size: 12px;
  font-weight: 850;
}

.workspace {
  padding: 28px;
  display: grid;
  align-content: start;
  gap: 18px;
}

.workspace-header {
  align-items: flex-start;
}

.workspace-header h2 {
  font-size: clamp(28px, 4vw, 46px);
  max-width: 780px;
  overflow-wrap: anywhere;
}

.status-cluster {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.status-cluster span:nth-child(1) {
  background: rgba(47, 125, 110, .11);
  color: var(--green);
}

.status-cluster span:nth-child(2) {
  background: rgba(52, 90, 138, .11);
  color: var(--blue);
}

.status-cluster span:nth-child(3) {
  background: rgba(181, 65, 71, .09);
  color: var(--red);
}

.countdown-panel {
  min-height: 176px;
  padding: 22px;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, .9), rgba(255, 255, 255, .62)),
    repeating-linear-gradient(90deg, transparent 0 18px, rgba(22, 26, 29, .035) 18px 19px);
}

.countdown-copy {
  max-width: 560px;
}

.countdown-copy p:last-child,
.result-panel p {
  margin: 12px 0 0;
  color: var(--muted);
  line-height: 1.7;
  font-size: 14px;
}

.timer-board {
  width: min(380px, 100%);
  min-height: 132px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 10px;
  border: 1px solid rgba(22, 26, 29, .18);
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
}

.timer-board span {
  border-color: rgba(255, 255, 255, .18);
  color: #d8dde2;
  padding: 6px 10px;
}

.timer-board strong {
  min-width: 312px;
  text-align: center;
  font: 900 clamp(36px, 6vw, 60px)/1 ui-monospace, "SFMono-Regular", Consolas, monospace;
  letter-spacing: 0;
}

.timer-board small {
  color: #b9c0c7;
  font-size: 12px;
  text-align: center;
  padding: 0 12px;
}

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

.tool-button {
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  line-height: 1.25;
  text-align: left;
}

.tool-button.accent {
  background: var(--green);
  color: #fff;
  border-color: transparent;
}

.button-icon {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: rgba(22, 26, 29, .08);
  font: 900 11px/1 ui-monospace, "SFMono-Regular", Consolas, monospace;
}

.tool-button.accent .button-icon {
  background: rgba(255, 255, 255, .2);
}

.board-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(320px, .75fr);
  gap: 18px;
}

.board-panel {
  min-height: 320px;
}

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

.seat-option {
  min-height: 112px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 14px;
  display: grid;
  align-content: space-between;
  gap: 10px;
  text-align: left;
  touch-action: manipulation;
}

.seat-option.is-selected {
  border-color: var(--green);
  box-shadow: inset 0 0 0 2px rgba(47, 125, 110, .16);
}

.seat-option strong,
.seat-option span {
  display: block;
}

.seat-option strong {
  font-size: 16px;
  overflow-wrap: anywhere;
}

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

.seat-option b {
  font: 900 24px/1 ui-monospace, "SFMono-Regular", Consolas, monospace;
  color: var(--ink);
}

.runbook-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 10px;
}

.runbook-list li {
  min-height: 48px;
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 10px 12px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.runbook-list li::before {
  content: "";
  width: 12px;
  height: 12px;
  flex: 0 0 12px;
  border-radius: 50%;
  border: 2px solid #a7aeb5;
}

.runbook-list li.is-done {
  color: var(--ink);
  background: rgba(47, 125, 110, .08);
}

.runbook-list li.is-done::before {
  background: var(--green);
  border-color: var(--green);
}

.result-panel {
  min-height: 142px;
  padding: 20px;
  border-color: rgba(47, 125, 110, .3);
  background: #f7fff9;
}

.result-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(110px, 1fr));
  gap: 10px;
}

.result-metrics span {
  min-height: 82px;
  display: grid;
  align-content: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
}

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

.result-metrics strong {
  font-size: 20px;
}

.activity-panel {
  padding: 18px;
  background: var(--surface);
}

.activity-log {
  min-height: 120px;
  max-height: 230px;
  margin: 0;
  padding: 0;
  list-style: none;
  overflow: auto;
  display: grid;
  align-content: start;
  gap: 8px;
}

.activity-log li {
  display: grid;
  grid-template-columns: 82px 1fr;
  gap: 10px;
  border-top: 1px solid var(--line);
  padding-top: 8px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.activity-log time {
  color: var(--ink);
  font: 800 11px/1.5 ui-monospace, "SFMono-Regular", Consolas, monospace;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: max(18px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: min(520px, calc(100% - 32px));
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  padding: 14px 16px;
  box-shadow: 0 22px 60px rgba(0, 0, 0, .3);
  font-size: 14px;
  text-align: center;
  z-index: 10;
  padding-bottom: calc(14px + env(safe-area-inset-bottom));
}

[hidden] {
  display: none !important;
}

@media (max-width: 1120px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .side-panel {
    min-height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    grid-template-columns: 1fr 1fr;
    align-items: start;
  }

  .brand-row {
    grid-column: 1 / -1;
  }

  .board-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .side-panel,
  .workspace {
    padding: 14px;
  }

  .side-panel {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .workspace-header,
  .countdown-panel,
  .result-panel {
    align-items: stretch;
    flex-direction: column;
  }

  .status-cluster {
    justify-content: flex-start;
    gap: 6px;
  }

  .status-cluster span,
  .mode-pill {
    padding: 6px 8px;
    font-size: 10px;
  }

  .timer-board {
    width: 100%;
    min-height: 120px;
  }

  .timer-board strong {
    min-width: 0;
    width: 100%;
    font-size: clamp(32px, 11vw, 42px);
  }

  .action-strip,
  .seat-board,
  .result-metrics {
    grid-template-columns: 1fr;
  }

  .tool-button {
    justify-content: flex-start;
    padding: 0 14px;
    min-height: 58px;
  }

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

  .panel,
  .countdown-panel,
  .activity-panel,
  .result-panel {
    box-shadow: none;
  }

  .board-panel {
    min-height: auto;
  }

  .activity-log {
    max-height: none;
  }
}

@media (max-width: 430px) {
  .brand-row {
    align-items: flex-start;
  }

  .brand {
    max-width: calc(100% - 82px);
  }

  .section-heading h1 {
    font-size: 21px;
  }

  .workspace-header h2 {
    font-size: 26px;
  }

  .countdown-panel,
  .result-panel,
  .profile-card {
    gap: 12px;
  }

  .activity-log li {
    grid-template-columns: 68px 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    scroll-behavior: auto !important;
  }
}
