:root {
  --bg: #f7f7f8;
  --surface: #ffffff;
  --surface-subtle: #fafafa;
  --surface-muted: #f2f3f5;
  --text: #171719;
  --text-secondary: #62646a;
  --text-tertiary: #92949a;
  --border: #e1e2e5;
  --border-strong: #cfd1d5;
  --accent: #3157d5;
  --accent-hover: #2748b8;
  --accent-soft: #eef2ff;
  --danger: #c83d3d;
  --danger-soft: #fff1f1;
  --focus: 0 0 0 3px rgba(49, 87, 213, 0.16);
  --radius-sm: 5px;
  --radius-md: 8px;
  --radius-lg: 10px;
}

* { box-sizing: border-box; }
html { background: var(--bg); }

body {
  margin: 0;
  min-width: 320px;
  color: var(--text);
  background: var(--bg);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

button, input, textarea, select { font: inherit; }
button, select { cursor: pointer; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, a:focus-visible { outline: none; box-shadow: var(--focus); }
.app-shell { min-height: 100vh; }

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  height: 56px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 0 24px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(8px);
}

.brand { width: fit-content; display: inline-flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-size: 14px; font-weight: 650; letter-spacing: -0.01em; }
.brand-mark { width: 26px; height: 26px; display: grid; place-items: center; border-radius: var(--radius-sm); background: var(--accent); color: #fff; font-size: 12px; font-weight: 700; }
.storage-status { display: inline-flex; align-items: center; gap: 7px; color: var(--text-secondary); font-size: 12px; }
.storage-dot { width: 6px; height: 6px; border-radius: 50%; background: #2f8f5b; }
.header-actions { justify-self: end; }

.button { min-height: 34px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 7px 12px; border: 1px solid transparent; border-radius: var(--radius-sm); font-size: 13px; font-weight: 550; transition: background-color 120ms, border-color 120ms, color 120ms; }
.button svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.button-primary { border-color: var(--accent); background: var(--accent); color: #fff; }
.button-primary:hover { border-color: var(--accent-hover); background: var(--accent-hover); }
.button-secondary { border-color: var(--border); background: var(--surface); color: var(--text); }
.button-secondary:hover { border-color: var(--border-strong); background: var(--surface-subtle); }
.button:disabled { opacity: 0.5; cursor: not-allowed; }

.workspace { width: min(1600px, calc(100% - 48px)); margin: 0 auto; padding: 32px 0 40px; }
.workspace-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 32px; margin-bottom: 24px; }
.section-label { margin: 0 0 4px; color: var(--text-tertiary); font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; }
h1, h2, h3, h4, p { margin-top: 0; }
h1 { margin-bottom: 4px; font-size: 26px; line-height: 1.2; letter-spacing: -0.03em; }
.page-description { margin-bottom: 0; color: var(--text-secondary); font-size: 13px; }

.summary { display: flex; align-items: stretch; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface); }
.summary-item { min-width: 116px; padding: 10px 14px; }
.summary-item + .summary-item { border-left: 1px solid var(--border); }
.summary-value { display: block; margin-bottom: 1px; font-size: 17px; font-weight: 650; font-variant-numeric: tabular-nums; }
.summary-label { display: block; color: var(--text-secondary); font-size: 11px; white-space: nowrap; }

.capture-panel { margin-bottom: 28px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); }
.capture-heading { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.capture-heading h2, .board-toolbar h2 { margin-bottom: 2px; font-size: 14px; line-height: 1.4; letter-spacing: -0.01em; }
.capture-heading p, .board-toolbar p { margin-bottom: 0; color: var(--text-secondary); font-size: 12px; }
.keyboard-help { color: var(--text-tertiary); font-size: 11px; white-space: nowrap; }
kbd { min-width: 20px; height: 19px; display: inline-grid; place-items: center; margin-right: 3px; padding: 0 4px; border: 1px solid var(--border-strong); border-radius: 4px; background: var(--surface-subtle); color: var(--text-secondary); font-family: inherit; font-size: 10px; box-shadow: 0 1px 0 var(--border-strong); }
.capture-form { padding: 12px; }
.capture-form textarea { width: 100%; min-height: 76px; resize: vertical; padding: 10px 11px; border: 1px solid var(--border); border-radius: var(--radius-sm); outline: none; background: var(--surface); color: var(--text); font-size: 13px; line-height: 1.5; }
.capture-form textarea:hover { border-color: var(--border-strong); }
.capture-form textarea:focus { border-color: var(--accent); box-shadow: var(--focus); }
.capture-form textarea::placeholder { color: var(--text-tertiary); }
.capture-actions { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 10px; }
.input-hint { color: var(--text-tertiary); font-size: 11px; }

.board-section { min-width: 0; }
.board-toolbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 12px; }
.search-field { width: 240px; height: 34px; display: flex; align-items: center; gap: 8px; padding: 0 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--text-tertiary); }
.search-field:focus-within { border-color: var(--accent); box-shadow: var(--focus); }
.search-field svg { width: 16px; height: 16px; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; }
.search-field input { width: 100%; min-width: 0; padding: 0; border: 0; outline: none; background: transparent; color: var(--text); font-size: 12px; }
.search-field input::placeholder { color: var(--text-tertiary); }

.board { display: grid; grid-template-columns: repeat(4, minmax(250px, 1fr)); gap: 10px; overflow-x: auto; padding-bottom: 4px; }
.column { min-height: 460px; padding: 0 8px 8px; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface-muted); transition: border-color 120ms, background-color 120ms; }
.column.drag-over { border-color: var(--accent); background: var(--accent-soft); }
.column-header { min-height: 55px; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 4px; border-bottom: 1px solid var(--border); }
.column-title { min-width: 0; display: flex; align-items: center; gap: 7px; }
.column-header h3 { margin: 0; font-size: 12px; font-weight: 650; }
.status-dot { width: 7px; height: 7px; flex: 0 0 auto; border-radius: 50%; background: #8b8e95; }
.column-high .status-dot { background: #c44949; }
.column-medium .status-dot { background: #b28023; }
.column-low .status-dot { background: #4d7d65; }
.column-count { min-width: 19px; height: 19px; display: grid; place-items: center; padding: 0 5px; border-radius: 10px; background: #e5e6e9; color: var(--text-secondary); font-size: 10px; font-weight: 600; font-variant-numeric: tabular-nums; }
.column-hint { margin: 0; color: var(--text-tertiary); font-size: 10px; white-space: nowrap; }
.card-list { min-height: 395px; display: flex; flex-direction: column; gap: 7px; padding-top: 8px; }

.demand-card { position: relative; padding: 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); transition: border-color 120ms, opacity 120ms; }
.demand-card:hover { border-color: var(--border-strong); }
.demand-card.dragging { opacity: 0.5; }
.card-topline { height: 18px; display: flex; align-items: center; justify-content: space-between; }
.drag-handle { width: 18px; height: 18px; display: grid; place-items: center; color: var(--text-tertiary); cursor: grab; }
.drag-handle:active { cursor: grabbing; }
.drag-handle svg { width: 14px; height: 14px; fill: currentColor; }
.card-actions { display: flex; align-items: center; gap: 2px; }
.complete-button, .delete-button { width: 24px; height: 24px; display: grid; place-items: center; padding: 0; border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--text-tertiary); opacity: 0; }
.demand-card:hover .complete-button, .demand-card:hover .delete-button, .complete-button:focus-visible, .delete-button:focus-visible { opacity: 1; }
.complete-button:hover { background: #edf7f1; color: #28734a; }
.delete-button:hover { background: var(--danger-soft); color: var(--danger); }
.complete-button svg, .delete-button svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }
.card-title { margin: 6px 0 12px; color: var(--text); font-size: 13px; font-weight: 600; line-height: 1.4; overflow-wrap: anywhere; }
.next-action-wrap { padding-top: 9px; border-top: 1px solid var(--border); }
.next-action-label { display: block; margin-bottom: 4px; color: var(--text-tertiary); font-size: 9px; font-weight: 650; letter-spacing: 0.06em; text-transform: uppercase; }
.next-action-input { width: 100%; padding: 5px 0; border: 0; border-bottom: 1px solid transparent; outline: none; background: transparent; color: var(--text); font-size: 11px; }
.next-action-input:hover { border-bottom-color: var(--border); }
.next-action-input:focus { border-bottom-color: var(--accent); }
.next-action-input::placeholder { color: var(--text-tertiary); }
.card-footer { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 10px; }
.card-date { color: var(--text-tertiary); font-size: 9px; letter-spacing: 0.02em; text-transform: uppercase; }
.status-select { max-width: 92px; height: 27px; padding: 0 24px 0 8px; border: 1px solid var(--border); border-radius: var(--radius-sm); outline: none; background-color: var(--surface); color: var(--text-secondary); font-size: 10px; }
.status-select:hover { border-color: var(--border-strong); }
.status-select:focus { border-color: var(--accent); }
.empty-state { padding: 18px 10px; border: 1px dashed var(--border-strong); border-radius: var(--radius-sm); color: var(--text-tertiary); text-align: center; font-size: 11px; }
.no-results { padding: 28px; color: var(--text-secondary); text-align: center; font-size: 12px; }

.completed-section { margin-top: 28px; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface); }
.completed-header { display: flex; align-items: center; justify-content: space-between; padding: 13px 16px; border-bottom: 1px solid var(--border); }
.completed-title-row { display: flex; align-items: center; gap: 8px; }
.completed-header h2 { margin: 0; font-size: 14px; letter-spacing: -0.01em; }
.completed-header p { margin: 2px 0 0; color: var(--text-secondary); font-size: 11px; }
.completed-badge { min-width: 19px; height: 19px; display: grid; place-items: center; padding: 0 5px; border-radius: 10px; background: var(--surface-muted); color: var(--text-secondary); font-size: 10px; font-weight: 600; font-variant-numeric: tabular-nums; }
.completed-list { display: grid; }
.completed-row { min-height: 58px; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 10px 14px; }
.completed-row + .completed-row { border-top: 1px solid var(--border); }
.completed-check { width: 22px; height: 22px; display: grid; place-items: center; border: 1px solid #b8d9c5; border-radius: 50%; background: #edf7f1; color: #28734a; }
.completed-check svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.completed-content { min-width: 0; }
.completed-item-title { margin: 0; overflow: hidden; color: var(--text-secondary); font-size: 12px; font-weight: 550; text-decoration: line-through; text-overflow: ellipsis; white-space: nowrap; }
.completed-meta { margin: 2px 0 0; overflow: hidden; color: var(--text-tertiary); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.completed-actions { display: flex; align-items: center; gap: 4px; }
.reopen-button { min-height: 28px; padding: 4px 8px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--text-secondary); font-size: 10px; }
.reopen-button:hover { border-color: var(--border-strong); color: var(--text); }
.completed-delete-button { width: 28px; height: 28px; display: grid; place-items: center; padding: 0; border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--text-tertiary); }
.completed-delete-button:hover { background: var(--danger-soft); color: var(--danger); }
.completed-delete-button svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }
.completed-empty { padding: 20px 16px; color: var(--text-tertiary); font-size: 11px; text-align: center; }

.toast { position: fixed; left: 50%; bottom: 24px; z-index: 30; transform: translate(-50%, 8px); padding: 9px 12px; border: 1px solid #2d2d30; border-radius: var(--radius-sm); background: #202023; color: #fff; font-size: 12px; opacity: 0; pointer-events: none; transition: opacity 120ms, transform 120ms; }
.toast.visible { opacity: 1; transform: translate(-50%, 0); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

@media (max-width: 900px) {
  .workspace { width: min(100% - 32px, 1600px); padding-top: 24px; }
  .board { grid-template-columns: repeat(4, minmax(280px, 1fr)); }
  .storage-status { display: none; }
  .app-header { grid-template-columns: 1fr auto; }
}

@media (max-width: 640px) {
  .app-header { height: 52px; padding: 0 16px; }
  .workspace { width: min(100% - 24px, 1600px); padding: 20px 0 28px; }
  .workspace-header { align-items: stretch; flex-direction: column; gap: 16px; }
  .summary { width: 100%; }
  .summary-item { flex: 1; min-width: 0; }
  .capture-heading { align-items: flex-start; }
  .keyboard-help { display: none; }
  .capture-actions { align-items: stretch; flex-direction: column; }
  .input-hint { order: 2; }
  .button-primary { width: 100%; }
  .board-toolbar { align-items: stretch; flex-direction: column; gap: 12px; }
  .search-field { width: 100%; }
  .board { grid-template-columns: repeat(4, minmax(86vw, 1fr)); scroll-snap-type: x mandatory; }
  .column { min-height: 420px; scroll-snap-align: start; }
  .column-hint { display: none; }
  .completed-header p { display: none; }
  .completed-row { grid-template-columns: auto minmax(0, 1fr); }
  .completed-actions { grid-column: 2; justify-content: flex-start; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0.01ms !important; }
}
