@import url('https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,400;0,14..32,500;0,14..32,600;0,14..32,700;0,14..32,800&display=swap');

:root {
  /* Page */
  --page-bg: oklch(0.78 0.03 192);

  /* Surfaces */
  --bg: oklch(0.975 0.005 255);
  --panel: oklch(1 0 0);

  /* Text */
  --text: oklch(0.15 0.016 255);
  --muted: oklch(0.5 0.018 255);

  /* Borders */
  --line: oklch(0.91 0.005 255);

  /* Accent — teal */
  --accent: oklch(0.56 0.14 190);
  --accent-hover: oklch(0.50 0.15 190);
  --accent-soft: oklch(0.965 0.03 190);

  /* Neutral */
  --soft: oklch(0.958 0.005 255);

  /* Semantic */
  --danger: oklch(0.49 0.19 27);
  --danger-soft: oklch(0.975 0.015 27);
  --warn: oklch(0.60 0.14 55);
  --warn-soft: oklch(0.98 0.015 55);
  --ok: oklch(0.52 0.15 148);
  --ok-soft: oklch(0.975 0.02 148);

  /* Sidebar — dark */
  --sidebar-bg: oklch(0.148 0.015 255);
  --sidebar-border: oklch(0.22 0.013 255);
  --sidebar-hover: oklch(0.21 0.014 255);
  --sidebar-active: oklch(0.28 0.03 192);
  --sidebar-text: oklch(0.92 0.006 255);
  --sidebar-muted: oklch(0.52 0.01 255);

  /* Shadows */
  --shadow-sm: 0 1px 3px oklch(0 0 0 / 0.07), 0 1px 2px oklch(0 0 0 / 0.04);
  --shadow-md: 0 4px 16px oklch(0 0 0 / 0.09), 0 2px 4px oklch(0 0 0 / 0.04);
  --shadow-lg: 0 20px 60px oklch(0 0 0 / 0.16), 0 8px 20px oklch(0 0 0 / 0.07);
  --shadow-shell: 0 32px 80px oklch(0 0 0 / 0.28), 0 8px 32px oklch(0 0 0 / 0.12);

  /* Radii */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;

  /* Motion */
  --transition: 150ms ease;
  --transition-spring: 200ms cubic-bezier(0.16, 1, 0.3, 1);

  /* Z-index */
  --z-dropdown: 10;
  --z-sticky: 20;
  --z-modal-backdrop: 40;
  --z-modal: 50;
  --z-toast: 60;
  --z-tooltip: 70;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 16px;
  min-height: 100vh;
  box-sizing: border-box;
  font-family: 'Inter', ui-sans-serif, system-ui, -apple-system, sans-serif;
  font-feature-settings: 'cv01', 'ss01';
  background: var(--page-bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  font-size: 14px;
  line-height: 1.5;
}

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

button {
  border: 0;
  background: var(--accent);
  color: white;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  letter-spacing: .01em;
  transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
  white-space: nowrap;
}
button:hover {
  background: var(--accent-hover);
  box-shadow: 0 2px 10px oklch(0.56 0.14 190 / 0.38);
}
button:active { transform: scale(.97); }
button.secondary {
  background: oklch(0.40 0.02 255);
  box-shadow: none;
}
button.secondary:hover {
  background: oklch(0.34 0.02 255);
  box-shadow: 0 2px 8px oklch(0 0 0 / 0.22);
}
button.ghost { background: var(--soft); color: var(--text); box-shadow: none; }
button.ghost:hover { background: var(--line); box-shadow: none; }
button.danger { background: var(--danger); }
button.danger:hover {
  background: oklch(0.44 0.2 27);
  box-shadow: 0 2px 8px oklch(0.49 0.19 27 / 0.35);
}
button:disabled { opacity: .45; cursor: not-allowed; transform: none !important; box-shadow: none !important; }

input, select, textarea {
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  background: white;
  color: var(--text);
  width: 100%;
  transition: border-color var(--transition), box-shadow var(--transition);
  font-size: 14px;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px oklch(0.56 0.14 190 / 0.14);
}
textarea { min-height: 96px; resize: vertical; }

label {
  display: grid;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: .01em;
}

code {
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 1px 5px;
  font-size: 12px;
  font-family: 'JetBrains Mono', 'Fira Code', ui-monospace, monospace;
}

pre {
  white-space: pre-wrap;
  line-height: 1.6;
  background: var(--text);
  color: var(--soft);
  padding: 18px 20px;
  border-radius: var(--radius-md);
  overflow: auto;
  font-family: 'JetBrains Mono', 'Fira Code', ui-monospace, monospace;
  font-size: 13px;
  border: 1px solid oklch(1 0 0 / 0.06);
}

/* ── App shell ── */
.app-shell {
  display: grid;
  grid-template-columns: 232px 1fr;
  min-height: calc(100vh - 32px);
  background: var(--panel);
  border-radius: var(--radius-xl);
  overflow: hidden;
  box-shadow: var(--shadow-shell);
}

.app-shell.has-detail {
  grid-template-columns: 232px 1fr 316px;
}

/* ── Sidebar ── */
.sidebar {
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  padding: 18px 10px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  height: calc(100vh - 32px);
  overflow-y: auto;
  border-right: 1px solid var(--sidebar-border);
  scrollbar-width: thin;
  scrollbar-color: oklch(0.28 0.01 255) transparent;
}

.brand {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 4px 8px 8px;
  border-bottom: 1px solid var(--sidebar-border);
  margin-bottom: 2px;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: var(--accent);
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 16px;
  color: white;
  flex-shrink: 0;
  letter-spacing: -.02em;
  box-shadow: 0 2px 8px oklch(0.56 0.14 190 / 0.4);
}

.brand h1 {
  font-size: 14px;
  font-weight: 700;
  margin: 0;
  letter-spacing: -.02em;
  color: var(--sidebar-text);
}

.brand p {
  margin: 2px 0 0;
  color: var(--sidebar-muted);
  font-size: 11px;
  letter-spacing: 0;
}

nav {
  display: grid;
  gap: 1px;
}

.nav-section-label {
  font-size: 10.5px;
  font-weight: 500;
  color: var(--sidebar-muted);
  padding: 10px 12px 3px;
  margin-top: 2px;
  letter-spacing: .01em;
  opacity: 0.7;
}

.nav-item {
  color: var(--sidebar-muted);
  text-decoration: none;
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 13px;
  font-weight: 500;
  transition: background var(--transition), color var(--transition);
}
.nav-item:hover {
  background: var(--sidebar-hover);
  color: var(--sidebar-text);
}
.nav-item.active {
  background: var(--sidebar-active);
  color: oklch(0.88 0.08 190);
  font-weight: 600;
}
.nav-item .nav-icon {
  font-size: 13px;
  flex-shrink: 0;
  width: 18px;
  text-align: center;
  opacity: 0.75;
}
.nav-item.active .nav-icon { opacity: 1; }
.nav-item .nav-arrow {
  margin-left: auto;
  color: oklch(0.35 0.01 255);
  font-size: 12px;
  transition: color var(--transition);
}
.nav-item:hover .nav-arrow { color: var(--sidebar-muted); }
.nav-item.active .nav-arrow { color: oklch(0.56 0.08 190); }

.sidebar-footer {
  margin-top: auto;
  display: grid;
  gap: 8px;
  padding: 8px 4px 0;
  border-top: 1px solid var(--sidebar-border);
}
.sidebar-footer button.ghost {
  background: oklch(0.21 0.013 255);
  color: var(--sidebar-muted);
  font-size: 12px;
  padding: 7px 12px;
}
.sidebar-footer button.ghost:hover {
  background: oklch(0.26 0.013 255);
  color: var(--sidebar-text);
}
.sidebar-footer small {
  font-size: 10.5px;
  line-height: 1.4;
  color: oklch(0.38 0.008 255);
  padding: 0 4px;
}
.sidebar-footer code {
  background: oklch(0.22 0.012 255);
  border-color: oklch(0.28 0.01 255);
  color: oklch(0.68 0.02 255);
}

/* ── Main ── */
.main {
  padding: 28px 32px;
  overflow-y: auto;
  height: calc(100vh - 32px);
  background: var(--panel);
  min-width: 0;
}

/* ── Topbar ── */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 16px;
  margin-bottom: 24px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.topbar h2 {
  margin: 0;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -.04em;
  color: var(--text);
  text-wrap: balance;
  line-height: 1.1;
}

.topbar p {
  color: var(--muted);
  margin: 5px 0 0;
  font-size: 13px;
}

.pill {
  background: var(--panel);
  border: 1.5px solid var(--line);
  border-radius: 999px;
  padding: 5px 13px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .01em;
  transition: all var(--transition);
  white-space: nowrap;
  flex-shrink: 0;
}
.pill[data-status='loading'] {
  border-color: oklch(0.82 0.12 55);
  color: oklch(0.38 0.1 55);
  background: oklch(0.98 0.012 55);
}
.pill[data-status='error'] {
  border-color: oklch(0.73 0.14 27);
  color: oklch(0.33 0.13 27);
  background: oklch(0.975 0.015 27);
}
.pill[data-status='ready'] {
  border-color: oklch(0.72 0.1 190);
  color: oklch(0.36 0.1 190);
  background: oklch(0.965 0.025 190);
}

/* ── Content ── */
.view { display: grid; gap: 20px; }
.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }

/* ── Cards ── */
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition), border-color var(--transition);
  min-width: 0;
}
.card:hover {
  box-shadow: var(--shadow-md);
  border-color: oklch(0.86 0.008 255);
}

.area-edit-btn {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
}
.area-card:hover .area-edit-btn {
  opacity: 1;
  pointer-events: auto;
}
.card h3 {
  margin: 0 0 16px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -.015em;
  text-wrap: balance;
  color: var(--text);
}

/* ── Row ── */
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row > * { flex: 1 1 0; }
.row .fit { flex: 0 0 auto; }

/* ── Lists & Items ── */
.list { display: grid; gap: 8px; }

.item {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  display: grid;
  gap: 8px;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.item:hover {
  border-color: oklch(0.75 0.07 190);
  box-shadow: 0 2px 10px oklch(0.56 0.14 190 / 0.08);
}

.item-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
}

.item-title {
  font-weight: 600;
  font-size: 14px;
  letter-spacing: -.01em;
  line-height: 1.4;
}

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

/* ── Badges ── */
.badge {
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 2px 7px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .01em;
  white-space: nowrap;
}
.badge.high { background: var(--danger-soft); color: var(--danger); border-color: oklch(0.85 0.1 27); }
.badge.medium { background: var(--warn-soft); color: var(--warn); border-color: oklch(0.87 0.09 55); }
.badge.low { background: var(--ok-soft); color: var(--ok); border-color: oklch(0.82 0.1 148); }

/* ── Actions ── */
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.actions button { padding: 7px 12px; font-size: 12px; }

/* ── KPIs ── */
.kpi { display: grid; gap: 3px; }
.kpi .value {
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -.05em;
  line-height: 1;
  color: var(--text);
}
.kpi .label {
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: .01em;
}

/* ── Form grid ── */
.form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}
.form-grid .wide { grid-column: span 2; }
.form-grid .full { grid-column: 1 / -1; }

/* ── Toast ── */
.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  background: var(--text);
  color: oklch(0.955 0.006 255);
  padding: 11px 18px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  max-width: 420px;
  font-size: 13.5px;
  font-weight: 500;
  border: 1px solid oklch(1 0 0 / 0.08);
  animation: toast-in .22s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: var(--z-toast);
}
@keyframes toast-in {
  from { opacity: 0; transform: translateY(10px) scale(.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.hidden { display: none; }

/* ── Login ── */
.login-mode {
  display: grid;
  place-items: center;
}

.login-mode .app-shell {
  grid-template-columns: 1fr;
  width: min(100%, 460px);
  min-height: auto;
}

.login-mode .sidebar,
.login-mode .topbar,
.login-mode .detail-panel {
  display: none;
}

.login-mode .main {
  height: auto;
  padding: 32px;
}

.login-card {
  display: grid;
  gap: 16px;
}

.login-card h2 {
  margin: 0;
  font-size: 26px;
  line-height: 1.1;
}

.login-card p {
  margin: -8px 0 4px;
  color: var(--muted);
}

.login-mark {
  width: 42px;
  height: 42px;
}

.login-form {
  display: grid;
  gap: 12px;
}

.login-error {
  border: 1px solid oklch(0.85 0.1 27);
  border-radius: var(--radius-sm);
  background: var(--danger-soft);
  color: var(--danger);
  padding: 9px 12px;
  font-size: 13px;
  font-weight: 600;
}

/* ── Modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: oklch(0.12 0.014 255 / 0.6);
  display: grid;
  place-items: center;
  padding: 24px;
  z-index: var(--z-modal-backdrop);
  animation: modal-fade .15s ease-out;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.modal {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  width: min(580px, 100%);
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: modal-up .22s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modal-up {
  from { opacity: 0; transform: translateY(14px) scale(.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 18px 20px 16px;
  border-bottom: 1px solid var(--line);
}
.modal-header h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -.025em;
  text-wrap: balance;
}
.modal-close {
  padding: 5px 9px;
  border-radius: var(--radius-sm);
  line-height: 1;
  color: var(--muted);
  font-size: 15px;
  background: transparent;
}
.modal-close:hover { background: var(--soft); color: var(--text); box-shadow: none; }
.modal-body { padding: 20px; }
@keyframes modal-fade { from { opacity: 0; } to { opacity: 1; } }

/* ── Empty state ── */
.empty {
  color: var(--muted);
  padding: 24px 20px;
  border: 1.5px dashed var(--line);
  border-radius: var(--radius-md);
  text-align: center;
  font-size: 13px;
  background: var(--soft);
  line-height: 1.6;
}

/* ── Task rows ── */
.task-list { display: grid; gap: 0; }

.task-row {
  display: flex;
  align-items: start;
  gap: 12px;
  padding: 11px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition);
  position: relative;
}
.task-row + .task-row::before {
  content: '';
  position: absolute;
  top: 0;
  left: 8px;
  right: 8px;
  height: 1px;
  background: var(--line);
}
.task-row:hover { background: var(--soft); }
.task-row.selected {
  background: var(--soft);
  box-shadow: inset 0 0 0 1.5px var(--accent);
}

.task-row-check {
  width: 17px;
  height: 17px;
  border: 1.5px solid var(--line);
  border-radius: 5px;
  flex-shrink: 0;
  margin-top: 1px;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background: white;
  transition: background var(--transition), border-color var(--transition), box-shadow var(--transition);
}
.task-row-check:hover { border-color: var(--accent); }
.task-row-check:checked {
  background: var(--accent);
  border-color: var(--accent);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 10'%3E%3Cpath d='M1.5 5.5l2.5 2.5 5-5' stroke='white' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-size: 80%;
  background-position: center;
  background-repeat: no-repeat;
}

.task-row-body {
  flex: 1;
  min-width: 0;
}

.task-row-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  line-height: 1.4;
}

.task-row-meta {
  display: flex;
  gap: 5px;
  margin-top: 4px;
  align-items: center;
  flex-wrap: wrap;
}

.task-row-chevron {
  color: var(--muted);
  font-size: 16px;
  flex-shrink: 0;
  opacity: 0.3;
  transition: opacity var(--transition), color var(--transition);
  line-height: 1.5;
}
.task-row:hover .task-row-chevron { opacity: 0.6; }
.task-row.selected .task-row-chevron { opacity: 1; color: var(--accent); }

.quick-task-input-row {
  padding: 6px 8px;
  margin-bottom: 4px;
}
.quick-task-input-wrapper {
  position: relative;
}
.area-suggest {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 2px);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  z-index: var(--z-dropdown);
  overflow: hidden;
}
.area-suggest.hidden { display: none; }
.area-suggest-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 12px;
  font-size: 13px;
  cursor: pointer;
  color: var(--text);
  gap: 16px;
}
.area-suggest-item:hover,
.area-suggest-item.active {
  background: var(--accent-soft);
  color: var(--accent);
}
.area-suggest-item:first-child { border-radius: var(--radius-sm) var(--radius-sm) 0 0; }
.quick-task-field {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px;
  width: 100%;
  box-sizing: border-box;
  padding: 5px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg);
  transition: border-color var(--transition);
  cursor: text;
}
.quick-task-field:focus-within { border-color: var(--accent); }
.quick-task-field input {
  flex: 0 1 auto;
  width: auto;
  min-width: 30px;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 13px;
  outline: none;
  padding: 3px 0;
  box-shadow: none;
}
.quick-task-field input:focus { border: none; box-shadow: none; }
.quick-task-field input::placeholder { color: var(--muted); }
.quick-task-text {
  color: var(--text);
  font-size: 13px;
  white-space: pre;
  flex-shrink: 0;
}
.area-chip,
.date-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 6px 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  line-height: 1.4;
}
.area-chip {
  background: var(--accent-soft);
  color: var(--accent);
}
.date-chip {
  background: oklch(0.96 0.04 60);
  color: oklch(0.50 0.12 60);
}
.chip-remove {
  display: inline-flex;
  align-items: center;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0 1px;
  font-size: 15px;
  line-height: 1;
  opacity: 0.6;
  box-shadow: none;
  color: inherit;
}
.chip-remove:hover { opacity: 1; background: none; box-shadow: none; }
.suggest-hint {
  font-size: 12px;
  opacity: 0.45;
  white-space: nowrap;
  flex-shrink: 0;
}
.quick-date-picker {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 0;
  height: 0;
  border: none;
  padding: 0;
}

.add-task-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 8px;
  color: var(--muted);
  cursor: pointer;
  border-radius: var(--radius-sm);
  font-size: 13px;
  transition: background var(--transition), color var(--transition);
  border-bottom: 1px solid var(--line);
  margin-bottom: 4px;
}
.add-task-row:hover { background: var(--soft); color: var(--accent); }
.add-task-row .add-icon { font-size: 14px; width: 18px; text-align: center; }

/* ── Detail panel ── */
.detail-panel {
  display: none;
}

.app-shell.has-detail .detail-panel {
  border-left: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  background: var(--bg);
  height: calc(100vh - 32px);
  overflow-y: auto;
  padding: 24px 20px;
  gap: 0;
}

.detail-placeholder {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  opacity: 0.45;
  padding: 40px 16px;
  line-height: 1.6;
}

.detail-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.detail-header-row .detail-section-label { margin-bottom: 0; }
.detail-delete-btn { width: 26px; height: 26px; }


.detail-section-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .01em;
  color: var(--muted);
  margin: 0 0 8px;
}

.detail-title-input {
  width: 100%;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  border: none;
  border-bottom: 1.5px solid var(--line);
  border-radius: 0;
  padding: 4px 0 10px;
  background: transparent;
  box-sizing: border-box;
  transition: border-color var(--transition);
  margin-bottom: 8px;
  letter-spacing: -.01em;
}
.detail-title-input:focus {
  outline: none;
  border-bottom-color: var(--accent);
  box-shadow: none;
}

.detail-fields {
  border-top: 1px solid var(--line);
  margin-top: 8px;
  flex: 1;
}

.detail-field {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
}

.detail-field-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  min-width: 80px;
  flex-shrink: 0;
}

.detail-field select,
.detail-field input[type="text"],
.detail-field input[type="date"],
.detail-field input[type="number"] {
  flex: 1;
  border: none;
  padding: 3px 8px;
  font-size: 13px;
  font-family: inherit;
  background: transparent;
  color: var(--text);
  border-radius: var(--radius-sm);
  transition: background var(--transition);
  width: auto;
  min-width: 0;
}
.detail-field select:hover,
.detail-field input:hover { background: oklch(0.955 0.005 255); }
.detail-field select:focus,
.detail-field input:focus { outline: none; background: var(--accent-soft); }

.detail-footer {
  margin-top: auto;
  padding-top: 20px;
  display: flex;
  gap: 8px;
}
.detail-footer button { flex: 1; }

/* ── Habits table ── */
.habits-scroll-wrapper {
  overflow-x: auto;
  scrollbar-width: thin;
}

.habits-table {
  border-collapse: collapse;
  width: max-content;
  min-width: 100%;
}

.habits-table th,
.habits-table td {
  text-align: center;
  padding: 5px 3px;
  border-bottom: 1px solid var(--line);
}

.habits-table thead th {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: .01em;
  padding-bottom: 8px;
  white-space: nowrap;
}

.habits-table thead th.today {
  color: var(--accent);
  background: rgba(74, 222, 128, 0.12);
}

.habits-table tbody td.today {
  background: rgba(74, 222, 128, 0.12);
}

.habits-table .habit-name-col {
  position: sticky;
  left: 0;
  background: var(--panel);
  z-index: var(--z-sticky);
  text-align: left;
  min-width: 160px;
  max-width: 220px;
  padding: 8px 12px 8px 20px;
}

.habits-table tbody .habit-name-col {
  padding-top: 6px;
  padding-bottom: 6px;
}

.habits-table .habit-date-col {
  min-width: 44px;
}

.habit-name-wrap {
  display: flex;
  align-items: center;
  gap: 0;
}

.habit-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
}

.habit-row-actions {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  margin-left: 6px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
}

.habit-row:hover .habit-row-actions {
  opacity: 1;
  pointer-events: auto;
}

.habit-action-btn {
  width: 22px;
  height: 22px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 5px;
  font-size: 13px;
  line-height: 1;
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  box-shadow: none;
  transition: background 0.12s, color 0.12s;
}

.habit-edit-btn:hover {
  background: var(--soft);
  color: var(--accent);
  box-shadow: none;
}

.habit-delete-btn:hover {
  background: var(--danger-soft);
  color: var(--danger);
  box-shadow: none;
}

.habit-cell {
  padding: 4px 3px;
}

.habit-btn {
  width: 30px;
  height: 30px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 7px;
  font-size: 14px;
  font-weight: 700;
  box-shadow: none;
  line-height: 1;
  -webkit-touch-callout: none;
  user-select: none;
}
.habit-btn:hover { box-shadow: none; }
.habit-btn:active { transform: scale(.93); }

.habit-btn-empty {
  background: transparent;
  border: 1.5px dashed var(--line);
  color: transparent;
  box-shadow: none;
}
.habit-btn-empty:hover {
  background: var(--soft);
  border-color: var(--accent);
  border-style: solid;
  box-shadow: none;
}

.habit-btn-done {
  background: var(--ok-soft);
  color: var(--ok);
}
.habit-btn-done:hover { background: oklch(0.93 0.07 148); }

.habit-btn-missed {
  background: var(--danger-soft);
  color: var(--danger);
}
.habit-btn-missed:hover { background: oklch(0.95 0.06 27); }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: oklch(0.85 0.005 255); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: oklch(0.76 0.008 255); }

/* ── Reduced motion ── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  button:active { transform: none; }
}

/* ── Responsive ── */
@media (max-width: 900px) {
  body { padding: 0; }
  .app-shell {
    grid-template-columns: 1fr;
    min-height: 100vh;
    border-radius: 0;
    box-shadow: none;
  }
  .app-shell.has-detail { grid-template-columns: 1fr; }
  .sidebar {
    height: auto;
    overflow-y: visible;
    border-right: none;
    border-bottom: 1px solid var(--sidebar-border);
  }
  .main { height: auto; overflow-y: visible; padding: 20px 16px; }
  .login-mode .main { padding: 28px 20px; }
  .detail-panel {
    height: auto;
    border-left: none;
    border-top: 1px solid var(--line);
    padding: 20px 16px;
  }
  .grid.two, .grid.three, .form-grid { grid-template-columns: 1fr; }
  .form-grid .wide { grid-column: span 1; }
}
