:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-alt: #eceef2;
  --text: #181b20;
  --muted: #6b7280;
  --line: #dfe3e9;
  --accent: #4f7cff;
  --danger: #c0392b;
  --warn: #d98324;
  --radius: 10px;
  --column-width: 85%;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101318;
    --surface: #191d24;
    --surface-alt: #21262e;
    --text: #e8eaed;
    --muted: #9aa1ac;
    --line: #2a2f38;
  }
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 15px;
  color: var(--text);
  background: var(--bg);
  overflow: hidden;
}

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

button {
  cursor: pointer;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  padding-top: env(safe-area-inset-top);
}

.topbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.filters {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  flex: 1;
  scrollbar-width: none;
}

.filters::-webkit-scrollbar {
  display: none;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
  padding: 5px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  white-space: nowrap;
}

.chip::before {
  content: '';
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--chip-color);
}

.chip.is-active {
  border-color: var(--chip-color);
  background: color-mix(in srgb, var(--chip-color) 16%, transparent);
  font-weight: 600;
}

.icon-button {
  border: none;
  background: transparent;
  padding: 6px 8px;
  border-radius: 8px;
  font-size: 16px;
  line-height: 1;
}

.icon-button:hover {
  background: var(--surface-alt);
}

.board {
  flex: 1;
  display: flex;
  gap: 10px;
  padding: 10px;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  overscroll-behavior-x: contain;
}

.column {
  flex: 0 0 var(--column-width);
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--surface-alt);
  border-radius: var(--radius);
  scroll-snap-align: start;
}

.column-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px 6px;
  font-weight: 600;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.count {
  font-weight: 500;
}

.column-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 0 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.intake {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.intake-input {
  width: 100%;
  padding: 9px 10px 9px 12px;
  border: 1px dashed var(--line);
  border-left: 3px solid var(--project-color);
  border-radius: var(--radius);
  background: var(--surface);
}

.intake-input::placeholder {
  color: var(--muted);
}

.cards {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 60px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 3px solid var(--project-color);
  border-radius: var(--radius);
  padding: 10px 12px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  user-select: none;
  -webkit-touch-callout: none;
}

.card-title {
  margin: 0;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.card-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 8px;
  margin-top: 8px;
  font-size: 12px;
  color: var(--muted);
}

.card-meta .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--project-color);
}

.person {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 9px;
  border-radius: 999px;
  background: var(--surface-alt);
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.due.is-overdue {
  color: var(--danger);
  font-weight: 600;
}

.due.is-today {
  color: var(--warn);
  font-weight: 600;
}

.note-mark {
  font-size: 16px;
  line-height: 1;
}

.is-placeholder {
  opacity: 0.3;
  border-style: dashed;
  box-shadow: none;
}

.drag-ghost {
  position: fixed;
  z-index: 100;
  pointer-events: none;
  transform: rotate(1.5deg);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.25);
  opacity: 0.97;
}

body.is-dragging {
  user-select: none;
}

body.is-dragging .board {
  scroll-snap-type: none;
}

.empty-state {
  margin: auto;
  text-align: center;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.empty-state button {
  padding: 10px 16px;
  border: none;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
}

.login {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100dvh;
  padding: 20px;
}

.login-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: min(320px, 100%);
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
}

.login-card h1 {
  margin: 0 0 4px;
  font-size: 20px;
}

.login-card input,
.sheet-panel input,
.sheet-panel select,
.sheet-panel textarea {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
}

.login-card button {
  padding: 10px 12px;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}

.error {
  margin: 0;
  color: var(--danger);
  font-size: 13px;
}

.sheet {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
}

.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
}

.sheet-panel {
  position: relative;
  margin-top: auto;
  width: 100%;
  max-height: 88dvh;
  overflow-y: auto;
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
  background: var(--surface);
  border-radius: 16px 16px 0 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.sheet-header h2 {
  margin: 0;
  font-size: 17px;
}

.sheet-project {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}

.sheet-project::before {
  content: '';
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--project-color);
}

.sheet-panel label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 13px;
  color: var(--muted);
}

.sheet-panel h3 {
  margin: 12px 0 0;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.settings-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

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

.settings-row input[type='text'] {
  flex: 1;
  min-width: 0;
}

.settings-row input[type='color'] {
  width: 34px;
  height: 34px;
  padding: 2px;
}

.settings-row.is-archived input[type='text'] {
  opacity: 0.5;
  text-decoration: line-through;
}

.hint {
  font-size: 12px;
  color: var(--muted);
}

.settings-add {
  display: flex;
  gap: 6px;
}

.settings-add input[type='text'] {
  flex: 1;
  min-width: 0;
}

.settings-add button {
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-alt);
}

.danger {
  align-self: flex-start;
  margin-top: 8px;
  padding: 9px 14px;
  border: 1px solid var(--danger);
  border-radius: 8px;
  background: transparent;
  color: var(--danger);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(20px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 200;
  max-width: 90vw;
  padding: 10px 16px;
  border-radius: 999px;
  background: #23272f;
  color: #fff;
  font-size: 14px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}

@media (orientation: landscape) {
  :root {
    --column-width: 45%;
  }
}

@media (min-width: 900px) {
  :root {
    --column-width: 300px;
  }

  .board {
    scroll-snap-type: none;
  }

  .column {
    flex: 1 1 0;
    min-width: 260px;
  }

  .sheet-panel {
    margin: 0 0 0 auto;
    width: min(400px, 100%);
    max-height: 100dvh;
    height: 100dvh;
    border-radius: 0;
  }
}
