:root {
  --bg: #f5f0e8;
  --ink: #0a0a0a;
  --paper: #ffffff;
  --magenta: #ff0080;
  --cyan: #00d9ff;
  --lemon: #fff200;
  --mint: #00ff9d;
  --grey: #e8e4dc;
  --b: 3px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

html, body {
  background: var(--bg);
  color: var(--ink);
  font-family: 'Unbounded', system-ui, -apple-system, sans-serif;
  font-weight: 500;
  font-size: 14px;
  overscroll-behavior-y: contain;
}

body {
  padding: env(safe-area-inset-top) 0 calc(120px + env(safe-area-inset-bottom));
  background-image:
    radial-gradient(circle at 1px 1px, rgba(10,10,10,0.06) 1px, transparent 0);
  background-size: 22px 22px;
}

button, input, textarea, select {
  font-family: inherit;
  color: inherit;
  background: none;
  border: none;
  padding: 0;
  border-radius: 0;
  outline: none;
}
button { cursor: pointer; }

/* ============ HEADER ============ */
.app-header {
  padding: 28px 18px 16px;
  border-bottom: var(--b) solid var(--ink);
  background: var(--paper);
  position: relative;
}
.app-header::after {
  content: '';
  position: absolute;
  left: 0; right: 0; bottom: -9px;
  height: 6px;
  background: var(--ink);
  opacity: 0.15;
}
.app-header h1 {
  font-size: clamp(46px, 14vw, 72px);
  font-weight: 900;
  letter-spacing: -0.05em;
  line-height: 0.82;
  text-transform: uppercase;
}
.app-header h1 .accent { color: var(--magenta); }
.app-header .meta-row {
  margin-top: 14px;
  display: flex; justify-content: space-between; align-items: baseline;
  font-family: 'Space Mono', monospace;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

/* ============ TABS ============ */
.tabs {
  display: flex;
  border-bottom: var(--b) solid var(--ink);
  background: var(--paper);
}
.tab {
  flex: 1;
  padding: 16px 12px;
  font-family: 'Unbounded', sans-serif;
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  background: var(--paper);
  border-right: var(--b) solid var(--ink);
  transition: background .12s;
}
.tab:last-child { border-right: none; }
.tab.active {
  background: var(--ink);
  color: var(--paper);
}

/* ============ BUCKET ============ */
.bucket { background: var(--paper); }

.bucket-header {
  padding: 18px;
  border-bottom: var(--b) solid var(--ink);
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.bucket-header h2 {
  font-size: clamp(24px, 7vw, 32px);
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: -0.025em;
  line-height: 0.9;
}
.bucket-header .count {
  font-family: 'Space Mono', monospace;
  font-size: 13px;
  font-weight: 700;
  padding: 4px 10px;
  border: var(--b) solid currentColor;
  white-space: nowrap;
}

.bucket.overdue .bucket-header  { background: var(--magenta); color: var(--paper); }
.bucket.today .bucket-header    { background: var(--lemon); }
.bucket.tomorrow .bucket-header { background: var(--cyan); }
.bucket.week .bucket-header     { background: var(--ink); color: var(--paper); }
.bucket.later .bucket-header    { background: var(--paper); }
.bucket.none .bucket-header     {
  background: var(--paper);
  border-bottom-style: dashed;
}
.bucket.done .bucket-header     { background: var(--grey); }

/* ============ TASK GRID ============ */
.task-grid {
  display: grid;
  border-bottom: var(--b) solid var(--ink);
}
/* срочные — 1 колонка, гигантские карточки */
.bucket.overdue .task-grid,
.bucket.today .task-grid {
  grid-template-columns: 1fr;
}
/* tomorrow / week — 2 колонки */
.bucket.tomorrow .task-grid,
.bucket.week .task-grid {
  grid-template-columns: repeat(2, 1fr);
}
/* later / none / done — 2 колонки тоже, но компактные */
.bucket.later .task-grid,
.bucket.none .task-grid,
.bucket.done .task-grid {
  grid-template-columns: repeat(2, 1fr);
}

/* ============ TASK ============ */
.task {
  background: var(--paper);
  border-right: var(--b) solid var(--ink);
  border-bottom: var(--b) solid var(--ink);
  padding: 18px 16px 60px;
  position: relative;
  min-height: 130px;
  display: flex;
  flex-direction: column;
  transition: transform .08s ease, background .12s;
  cursor: pointer;
}
.task:nth-child(2n) { border-right: none; }
.bucket.overdue .task,
.bucket.today .task {
  border-right: none;
  min-height: 150px;
  padding: 22px 20px 70px;
}
.task:active { transform: translate(2px, 2px); }
.task:last-child { border-bottom: none; }

.task .num {
  position: absolute;
  top: 14px;
  right: 16px;
  font-family: 'Space Mono', monospace;
  font-size: 12px;
  font-weight: 700;
  opacity: 0.45;
  letter-spacing: 0.05em;
}
.bucket.overdue .task .num,
.bucket.today .task .num { font-size: 14px; opacity: 0.6; }

.task .title {
  font-family: 'Unbounded', sans-serif;
  font-weight: 700;
  font-size: 15px;
  line-height: 1.2;
  letter-spacing: -0.015em;
  margin-top: 6px;
  word-break: break-word;
  flex: 1;
}
.bucket.overdue .task .title,
.bucket.today .task .title {
  font-size: 22px;
  line-height: 1.05;
  font-weight: 900;
  letter-spacing: -0.025em;
}
.bucket.later .task .title,
.bucket.none .task .title { font-size: 13px; }

.task .meta {
  position: absolute;
  bottom: 18px;
  left: 16px;
  right: 56px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font-family: 'Space Mono', monospace;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.bucket.overdue .task .meta,
.bucket.today .task .meta {
  left: 20px;
  bottom: 22px;
  font-size: 13px;
}
.task .meta .time {
  padding: 3px 8px;
  background: var(--ink);
  color: var(--paper);
}
.bucket.overdue .task .meta .time { background: var(--paper); color: var(--ink); }
.bucket.today .task .meta .time { background: var(--ink); color: var(--lemon); }
.task .meta .repeat {
  padding: 3px 8px;
  border: 2px solid var(--ink);
}

/* колоризация фоном */
.bucket.overdue .task { background: var(--magenta); color: var(--paper); }
.bucket.today .task { background: var(--lemon); }
.bucket.tomorrow .task { background: var(--cyan); }
.bucket.week .task { background: var(--paper); }
.bucket.week .task:nth-child(2n+1) { background: var(--mint); }
.bucket.later .task,
.bucket.none .task { background: var(--paper); }
.bucket.done .task {
  background: var(--grey);
  opacity: 0.7;
}
.bucket.done .task .title { text-decoration: line-through; }

/* checkbox */
.check {
  position: absolute;
  bottom: 14px;
  right: 14px;
  width: 30px;
  height: 30px;
  border: var(--b) solid var(--ink);
  background: var(--paper);
  display: flex; align-items: center; justify-content: center;
  z-index: 2;
}
.bucket.overdue .check { background: var(--paper); }
.check.checked {
  background: var(--ink);
}
.check.checked::after {
  content: '✕';
  color: var(--paper);
  font-family: 'Unbounded', sans-serif;
  font-weight: 900;
  font-size: 14px;
  line-height: 1;
}

/* ============ EMPTY ============ */
.empty {
  padding: 80px 24px;
  text-align: center;
}
.empty .emoji {
  font-size: 72px;
  filter: grayscale(0.3);
}
.empty .text {
  font-family: 'Unbounded', sans-serif;
  font-weight: 700;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-top: 18px;
}

/* ============ FAB ============ */
.fab {
  position: fixed;
  right: 18px;
  bottom: calc(22px + env(safe-area-inset-bottom));
  width: 76px;
  height: 76px;
  background: var(--ink);
  color: var(--paper);
  border: var(--b) solid var(--ink);
  font-family: 'Unbounded', sans-serif;
  font-weight: 900;
  font-size: 40px;
  line-height: 1;
  box-shadow: 6px 6px 0 0 var(--magenta);
  transition: transform .1s, box-shadow .1s;
  z-index: 50;
  display: flex; align-items: center; justify-content: center;
  padding-bottom: 6px;
}
.fab:active {
  transform: translate(6px, 6px);
  box-shadow: 0 0 0 0 var(--magenta);
}

/* ============ SHEET ============ */
.scrim {
  position: fixed; inset: 0;
  background: rgba(10,10,10,0.55);
  z-index: 100;
  opacity: 0; pointer-events: none;
  transition: opacity .18s;
}
.scrim.open { opacity: 1; pointer-events: auto; }

.sheet {
  position: fixed;
  left: 8px; right: 8px;
  bottom: 8px;
  background: var(--paper);
  border: var(--b) solid var(--ink);
  box-shadow: 7px 7px 0 0 var(--ink);
  z-index: 101;
  transform: translateY(115%);
  transition: transform .28s cubic-bezier(.2,.9,.3,1);
  max-height: 88vh;
  overflow-y: auto;
  padding: 22px 20px calc(22px + env(safe-area-inset-bottom));
}
.sheet.open { transform: translateY(0); }

.sheet h2 {
  font-family: 'Unbounded', sans-serif;
  font-size: clamp(28px, 9vw, 38px);
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: -0.03em;
  line-height: 0.9;
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: var(--b) solid var(--ink);
}

.sheet input,
.sheet textarea,
.sheet select {
  font-family: 'Space Mono', monospace;
  font-size: 14px;
  background: var(--paper);
  color: var(--ink);
  border: var(--b) solid var(--ink);
  padding: 14px;
  width: 100%;
  resize: none;
}
.sheet input:focus,
.sheet textarea:focus { background: var(--lemon); }

.field { margin-bottom: 16px; }
.field label {
  display: block;
  font-family: 'Unbounded', sans-serif;
  font-weight: 900;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin-bottom: 6px;
}

.btn {
  display: block;
  width: 100%;
  padding: 18px;
  background: var(--ink);
  color: var(--paper);
  border: var(--b) solid var(--ink);
  font-family: 'Unbounded', sans-serif;
  font-weight: 900;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  box-shadow: 5px 5px 0 0 var(--magenta);
  transition: transform .1s, box-shadow .1s;
}
.btn:active {
  transform: translate(5px, 5px);
  box-shadow: 0 0 0 0 var(--magenta);
}
.btn:disabled {
  opacity: 0.45;
}
.btn.danger {
  background: var(--magenta);
  box-shadow: 5px 5px 0 0 var(--cyan);
}
.btn.danger:active { box-shadow: 0 0 0 0 var(--cyan); }
.btn.secondary {
  background: var(--paper);
  color: var(--ink);
  box-shadow: 5px 5px 0 0 var(--ink);
}
.btn.secondary:active { box-shadow: 0 0 0 0 var(--ink); }

.btn-row { display: flex; gap: 10px; margin-top: 14px; }
.btn-row .btn { flex: 1; }

.chips { display: flex; flex-wrap: wrap; }
.chip {
  padding: 11px 14px;
  background: var(--paper);
  border: var(--b) solid var(--ink);
  margin: -3px 0 0 -3px;
  font-family: 'Space Mono', monospace;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.chip.active {
  background: var(--ink);
  color: var(--paper);
}

.detail-meta {
  background: var(--lemon);
  padding: 16px;
  border: var(--b) solid var(--ink);
  margin-bottom: 18px;
  font-family: 'Space Mono', monospace;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 700;
}
.detail-meta .row {
  display: flex; justify-content: space-between; gap: 12px;
}
.detail-meta .row + .row { margin-top: 8px; padding-top: 8px; border-top: 2px solid var(--ink); }

.hint {
  font-family: 'Space Mono', monospace;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--cyan);
  border: var(--b) solid var(--ink);
  padding: 10px 12px;
  margin-bottom: 14px;
}

/* ============ TOAST ============ */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(115px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--lemon);
  padding: 12px 22px;
  border: var(--b) solid var(--ink);
  font-family: 'Space Mono', monospace;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  z-index: 200;
  opacity: 0;
  transition: opacity .2s, transform .2s;
  white-space: nowrap;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
