:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-soft: #f9fafb;
  --border: #d8dde5;
  --border-strong: #b8c1cf;
  --text: #111827;
  --subtle: #4b5563;
  --faint: #6b7280;
  --blue: #2563eb;
  --blue-soft: #e8f0ff;
  --green: #16a34a;
  --amber: #b45309;
  --red: #dc2626;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); }
button, input, textarea, select { font: inherit; }
button {
  min-height: 40px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}
button:hover { border-color: var(--border-strong); }
button:disabled { cursor: wait; opacity: .72; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: 2px solid rgba(37, 99, 235, .35);
  outline-offset: 2px;
}
input, textarea, select {
  width: 100%;
  min-width: 0;
  min-height: 40px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  padding: 9px 11px;
  color: var(--text);
}
textarea { min-height: 112px; resize: vertical; line-height: 1.45; }
.hidden { display: none !important; }
.primary { background: var(--blue); color: #fff; border-color: var(--blue); font-weight: 800; }
.danger { background: #fff; color: var(--red); border-color: #fecaca; font-weight: 800; }
.danger:hover { border-color: #f87171; background: #fff7f7; }
.text-button { border: 0; min-height: 0; padding: 0; color: var(--blue); background: transparent; text-align: left; }
.label, .eyebrow { color: var(--faint); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.form-message { min-height: 20px; color: var(--subtle); margin: 4px 0 0; }

.login-screen { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-panel { width: min(420px, 100%); border: 1px solid var(--border); border-radius: 8px; background: var(--surface); padding: 24px; }
.brand-row { display: flex; gap: 12px; align-items: center; margin-bottom: 20px; }
.brand-row h1 { margin: 0; font-size: 25px; }
.brand-row p { margin: 3px 0 0; color: var(--subtle); }
.brand-mark { display: inline-grid; place-items: center; flex: 0 0 auto; width: 38px; height: 38px; border-radius: 8px; background: var(--blue); color: #fff; font-weight: 900; }
.brand-mark.small { width: 28px; height: 28px; border-radius: 7px; }
.login-form { display: grid; gap: 14px; }
.login-form label, .settings-panel label { display: grid; gap: 6px; color: var(--subtle); font-size: 13px; }
.verification-panel {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
  display: grid;
  gap: 12px;
}
.verification-panel h2 { margin: 0; font-size: 18px; }
.verification-panel p { margin: 0; color: var(--subtle); }
.form-message a { color: var(--blue); font-weight: 800; }

.app-shell {
  height: 100vh;
  display: grid;
  grid-template-columns: 220px minmax(420px, 1fr) minmax(360px, 30vw);
  overflow: hidden;
}
.sidebar {
  min-height: 0;
  overflow: auto;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.app-title { display: flex; align-items: center; gap: 10px; font-size: 18px; padding: 2px; }
.server-box, .storage-box {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-soft);
  padding: 12px;
  display: grid;
  gap: 8px;
  font-size: 13px;
}
.server-box strong, .storage-box span { overflow-wrap: anywhere; }
.state { display: inline-flex; align-items: center; gap: 7px; color: var(--subtle); }
.state::before { content: ""; width: 9px; height: 9px; border-radius: 999px; background: currentColor; }
.state.good { color: var(--green); }
.state.bad { color: var(--red); }
.nav-list { display: grid; gap: 5px; }
.nav-item { border: 0; background: transparent; text-align: left; padding: 10px 12px; }
.nav-item.active { background: var(--blue-soft); color: var(--blue); font-weight: 800; }

.workspace {
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  padding: 18px;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 14px;
}
.topbar { display: grid; grid-template-columns: minmax(180px, 1fr) minmax(320px, 680px); gap: 16px; align-items: end; }
.topbar h2 { margin: 2px 0 0; font-size: 28px; line-height: 1.1; }
.toolbar { display: grid; grid-template-columns: minmax(160px, 1fr) auto auto auto; gap: 10px; align-items: center; }
.toolbar .primary { white-space: nowrap; }
.sync-pill {
  min-height: 40px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--subtle);
  padding: 0 11px;
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 750;
  cursor: pointer;
}
.sync-pill:disabled { cursor: wait; }
.sync-pill.good { color: var(--green); border-color: #bbf7d0; background: #f0fdf4; }
.sync-pill.bad { color: var(--red); border-color: #fecaca; background: #fff7f7; }
.sync-pill.syncing { color: var(--blue); border-color: #bfdbfe; background: var(--blue-soft); }

.quick-add {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(130px, 170px) minmax(110px, 140px) auto;
  gap: 10px;
  align-items: end;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  padding: 12px;
}
.quick-add label { display: grid; gap: 6px; min-width: 0; }
.quick-add button { align-self: end; padding-inline: 16px; }
.date-shortcuts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.quick-shortcuts { grid-column: 1 / -1; }
.date-shortcuts button {
  min-height: 34px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--subtle);
  font-size: 13px;
  font-weight: 800;
}

.board-view { min-height: 0; overflow: auto; display: block; }
.reminder-list-panel { display: grid; gap: 10px; }
.list-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.list-head h3 { margin: 0; font-size: 18px; }
.count { color: var(--faint); background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 3px 9px; font-size: 12px; white-space: nowrap; }
.reminder-list { display: grid; gap: 8px; }
.empty-state {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  padding: 22px;
  display: grid;
  gap: 8px;
  align-content: start;
}
.empty-state strong { font-size: 18px; }
.empty-state p { margin: 0; color: var(--subtle); line-height: 1.45; }
.empty-state button { justify-self: start; margin-top: 4px; }
.loading-state { border-style: dashed; }
.error-state { border-color: #fecaca; background: #fffafa; }
.task-card {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  padding: 12px;
  display: grid;
  gap: 10px;
}
.task-card.selected { border-color: var(--blue); box-shadow: 0 0 0 2px rgba(37, 99, 235, .12); }
.task-card.overdue { border-color: #fecaca; background: #fffafa; }
.task-card.completed .task-name { color: var(--subtle); text-decoration: line-through; }
.task-title-row { display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; gap: 10px; align-items: start; }
.check {
  width: 34px;
  height: 34px;
  min-width: 34px;
  min-height: 34px;
  aspect-ratio: 1 / 1;
  padding: 0;
  border-radius: 999px;
  display: grid;
  place-items: center;
  align-self: start;
  color: var(--green);
  background: #fff;
  font-weight: 900;
  line-height: 1;
}
.check.checked { background: #ecfdf5; border-color: #86efac; }
.task-card-main { min-width: 0; display: grid; gap: 6px; }
.task-name {
  min-width: 0;
  min-height: 28px;
  border: 0;
  background: transparent;
  padding: 0;
  text-align: left;
  font-weight: 850;
  line-height: 1.3;
  overflow-wrap: anywhere;
}
.task-meta-line { display: flex; flex-wrap: wrap; gap: 7px; align-items: center; }
.status-chip {
  min-height: 26px;
  border-radius: 999px;
  padding: 0 9px;
  font-size: 12px;
  font-weight: 850;
  border: 1px solid var(--border);
  background: var(--surface-soft);
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
}
.status-todo { color: var(--subtle); }
.status-inProgress { color: var(--blue); border-color: #bfdbfe; background: var(--blue-soft); }
.status-waiting { color: var(--amber); border-color: #fed7aa; background: #fff7ed; }
.status-completed { color: var(--green); border-color: #bbf7d0; background: #f0fdf4; }
.priority-text { font-size: 12px; font-weight: 850; }
.task-edit { min-height: 32px; padding: 0 10px; border-radius: 8px; background: var(--surface-soft); font-weight: 800; color: var(--subtle); white-space: nowrap; }
.card-facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.card-facts span { min-width: 0; display: grid; gap: 3px; border-left: 2px solid #e5e7eb; padding-left: 8px; }
.card-facts small { color: var(--faint); font-size: 11px; line-height: 1; text-transform: uppercase; letter-spacing: .04em; }
.card-facts strong { min-width: 0; color: var(--text); font-size: 13px; line-height: 1.25; overflow-wrap: anywhere; }
.task-summary { display: flex; flex-wrap: wrap; gap: 8px; }
.summary-item {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface-soft);
  padding: 7px 9px;
  display: grid;
  gap: 2px;
}
.summary-item small { color: var(--faint); font-size: 11px; line-height: 1; text-transform: uppercase; letter-spacing: .04em; }
.summary-item strong { font-size: 13px; line-height: 1.2; overflow-wrap: anywhere; }
.danger-text strong { color: var(--red); }
.notes-flag strong { color: var(--blue); }
.tag-row { display: flex; flex-wrap: wrap; gap: 6px; color: var(--subtle); font-size: 12px; }
.tag { border: 1px solid var(--border); border-radius: 6px; padding: 3px 7px; background: var(--surface-soft); }
.priority-high, .priority-urgent { color: var(--red); font-weight: 800; }
.priority-medium { color: var(--amber); font-weight: 800; }
.progress { height: 4px; border-radius: 999px; background: #e5e7eb; overflow: hidden; }
.progress span { display: block; height: 100%; background: var(--blue); }

.calendar-view { min-height: 0; overflow: auto; }
.calendar-shell { min-height: 0; display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(280px, .75fr); gap: 14px; }
.calendar-panel, .calendar-agenda {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  padding: 14px;
}
.calendar-header { display: flex; justify-content: space-between; gap: 12px; align-items: end; margin-bottom: 12px; }
.calendar-header h3, .calendar-agenda h3 { margin: 2px 0 0; font-size: 22px; line-height: 1.15; }
.calendar-header small, .calendar-agenda small { color: var(--subtle); }
.calendar-controls { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.calendar-controls button { min-height: 36px; padding: 0 10px; }
.calendar-weekdays { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; margin-bottom: 6px; }
.calendar-weekdays span { color: var(--faint); font-size: 11px; font-weight: 800; text-align: center; text-transform: uppercase; letter-spacing: .04em; }
.calendar-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.calendar-day {
  min-width: 0;
  min-height: 70px;
  border-radius: 8px;
  padding: 8px;
  background: var(--surface-soft);
  display: grid;
  align-content: space-between;
  text-align: left;
}
.calendar-day.outside { color: #9ca3af; background: #fcfcfd; }
.calendar-day.today { border-color: var(--blue); box-shadow: inset 0 0 0 1px rgba(37, 99, 235, .25); }
.calendar-day.selected { background: var(--blue-soft); border-color: #93c5fd; }
.calendar-day.has-items .day-number { font-weight: 900; }
.day-number { font-size: 16px; line-height: 1; }
.day-count {
  min-height: 20px;
  justify-self: start;
  border-radius: 999px;
  background: #eef2ff;
  color: var(--blue);
  font-size: 12px;
  font-weight: 900;
  line-height: 20px;
  padding: 0 7px;
}
.day-count:empty { display: none; }
.calendar-agenda { display: grid; gap: 10px; align-content: start; }
.current-time { display: inline-block; margin-bottom: 4px; }
.calendar-add-day { width: 100%; }
.agenda-list { display: grid; gap: 8px; }
.agenda-item {
  min-width: 0;
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  padding: 10px;
  text-align: left;
  background: var(--surface-soft);
}
.agenda-time { color: var(--blue); font-weight: 900; font-size: 13px; }
.agenda-main { min-width: 0; display: grid; gap: 3px; }
.agenda-main strong { overflow-wrap: anywhere; }
.agenda-main small { color: var(--subtle); line-height: 1.3; }

.settings-panel {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  padding: 14px;
}
.settings-view { display: grid; align-content: start; }
.settings-stack { max-width: 760px; display: grid; gap: 12px; }
.settings-panel { display: grid; gap: 12px; }
.settings-panel h3 { margin: 0; }
.settings-note { margin: 0; display: grid; gap: 4px; color: var(--subtle); }
.settings-note strong { color: var(--text); }

.detail-panel {
  min-width: 0;
  min-height: 0;
  overflow: auto;
  border-left: 1px solid var(--border);
  background: var(--surface);
  padding: 18px;
}
.detail-backdrop { display: none; }
.detail-empty { color: var(--subtle); margin-top: 30px; }
.detail-header { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; align-items: start; margin-bottom: 14px; }
.detail-panel h3 { margin: 0; font-size: 22px; line-height: 1.2; overflow-wrap: anywhere; }
.detail-close { display: none; min-height: 34px; padding: 0 10px; }
.detail-chips { display: flex; flex-wrap: wrap; gap: 7px; }
.detail-chips span { border: 1px solid var(--border); border-radius: 999px; padding: 4px 9px; background: var(--surface-soft); color: var(--subtle); font-size: 12px; font-weight: 800; }
.detail-block { border-top: 1px solid var(--border); padding-top: 14px; margin-top: 14px; display: grid; gap: 10px; }
.detail-block-title { display: grid; gap: 2px; }
.detail-block-title strong { font-size: 15px; }
.detail-block-title span { color: var(--faint); font-size: 12px; }
.detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.detail-grid.stacked { grid-template-columns: 1fr; }
.detail-field { min-width: 0; display: grid; gap: 6px; }
.detail-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.detail-section { border-top: 1px solid var(--border); padding-top: 14px; margin-top: 14px; display: grid; gap: 10px; }
.detail-section-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.subtask-row { min-width: 0; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 8px; align-items: center; font-size: 14px; }
.subtask-row button {
  width: 28px;
  height: 28px;
  min-width: 28px;
  min-height: 28px;
  padding: 0;
  border-radius: 6px;
}
.subtask-row span { min-width: 0; overflow-wrap: anywhere; }
.subtask-row small { color: var(--subtle); white-space: nowrap; }
.add-subtask { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
.bottom-nav { display: none; }

@media (max-width: 1200px) {
  .app-shell { grid-template-columns: 200px minmax(0, 1fr); overflow: auto; }
  .detail-panel { grid-column: 2; border-left: 0; border-top: 1px solid var(--border); }
}

@media (max-width: 760px) {
  body { background: var(--surface); }
  .app-shell { height: auto; min-height: 100vh; display: block; overflow: visible; padding-bottom: 76px; }
  button, input, textarea, select { min-height: 46px; }
  .topbar .eyebrow { display: none; }
  .topbar h2 { font-size: 24px; }
  .detail-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(17, 24, 39, .32);
    border: 0;
    border-radius: 0;
    padding: 0;
    z-index: 4;
  }
  .app-shell.detail-open .detail-backdrop { display: block; }
  .sidebar { display: none; }
  .workspace { overflow: visible; padding: 14px; gap: 12px; }
  .topbar { grid-template-columns: 1fr; gap: 12px; }
  .toolbar { grid-template-columns: 1fr auto; }
  .sync-pill {
    grid-column: 1 / -1;
    min-height: 30px;
    justify-self: start;
    padding: 0 9px;
  }
  .toolbar .primary {
    position: fixed;
    right: 18px;
    bottom: 86px;
    width: 58px;
    height: 58px;
    border-radius: 18px;
    font-size: 0;
    box-shadow: 0 12px 28px rgba(17, 24, 39, .2);
    z-index: 3;
  }
  .toolbar .primary::after { content: "+"; font-size: 32px; line-height: 1; }
  #sync-button { display: none; }
  .quick-add { grid-template-columns: 1fr 1fr; padding: 10px; gap: 9px; }
  .quick-add label:first-child { grid-column: 1 / -1; }
  .quick-add button { grid-column: 1 / -1; }
  .date-shortcuts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; }
  .date-shortcuts button { grid-column: auto; min-height: 40px; padding: 0 6px; }
  .card-facts { grid-template-columns: 1fr; }
  .task-card { padding: 12px; gap: 10px; }
  .task-title-row { grid-template-columns: 44px minmax(0, 1fr) auto; gap: 10px; }
  .check {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
  }
  .task-name { min-height: 34px; font-size: 16px; }
  .task-edit { min-width: 58px; min-height: 44px; }
  .status-chip { min-height: 30px; }
  .summary-item { flex: 1 1 122px; }
  .calendar-shell { grid-template-columns: 1fr; gap: 10px; }
  .calendar-panel, .calendar-agenda { padding: 12px; }
  .calendar-header { display: grid; align-items: start; }
  .calendar-controls { justify-content: stretch; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .calendar-controls button { padding: 0 6px; }
  .calendar-weekdays { gap: 3px; }
  .calendar-grid { gap: 3px; }
  .calendar-day { min-height: 58px; padding: 7px; border-radius: 7px; }
  .day-number { font-size: 14px; }
  .day-count { min-height: 18px; line-height: 18px; font-size: 11px; padding: 0 6px; }
  .agenda-item { grid-template-columns: 66px minmax(0, 1fr); padding: 9px; }
  .detail-panel {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    max-height: 88vh;
    transform: translateY(104%);
    transition: transform .18s ease;
    z-index: 5;
    border-left: 0;
    border-top: 1px solid var(--border);
    border-radius: 18px 18px 0 0;
    padding: 16px;
    box-shadow: 0 -18px 48px rgba(17, 24, 39, .22);
  }
  .app-shell.detail-open .detail-panel { transform: translateY(0); }
  .detail-empty { display: none; }
  .detail-close { display: inline-flex; align-items: center; }
  .detail-panel h3 { font-size: 19px; }
  .detail-grid { grid-template-columns: 1fr; }
  .detail-actions { display: grid; grid-template-columns: 1fr; }
  .detail-block { margin-top: 12px; padding-top: 12px; }
  .detail-panel textarea { min-height: 138px; }
  .subtask-row {
    grid-template-columns: 42px minmax(0, 1fr) auto;
    min-height: 44px;
  }
  .subtask-row button {
    width: 36px;
    height: 36px;
    min-width: 36px;
    min-height: 36px;
  }
  .add-subtask { grid-template-columns: minmax(0, 1fr); }
  .bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    height: 70px;
    background: var(--surface);
    border-top: 1px solid var(--border);
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    z-index: 3;
  }
  .bottom-item { border: 0; border-radius: 0; background: transparent; font-size: 12px; min-height: 70px; }
  .bottom-item.active { color: var(--blue); font-weight: 800; }
}
