:root {
  --bg0: #f6f7fb;
  --bg1: #eef2ff;
  --surface: #ffffff;
  --surface-2: rgba(255, 255, 255, 0.6);
  --text: #0f172a;
  --muted: #64748b;
  --border: rgba(15, 23, 42, 0.12);

  --primary: #2563eb;
  --primary-2: #1d4ed8;
  --warn: #f59e0b;
  --bad: #ef4444;

  --r1: 10px;
  --r2: 14px;
  --r3: 20px;
  --s1: 8px;
  --s2: 12px;
  --s3: 16px;
  --s4: 20px;
  --s5: 28px;
  --s6: 40px;

  --shadow-sm: 0 6px 20px rgba(15, 23, 42, 0.06);
  --shadow: 0 16px 40px rgba(15, 23, 42, 0.08);
  --ring: 0 0 0 4px rgba(37, 99, 235, 0.18);

  --font: "IBM Plex Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  color: var(--text);
  font-family: var(--font);
  line-height: 1.55;
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(37, 99, 235, 0.10), transparent 60%),
    radial-gradient(900px 500px at 110% 0%, rgba(245, 158, 11, 0.10), transparent 55%),
    linear-gradient(180deg, var(--bg1), var(--bg0));
}

h1,
h2,
h3 {
  line-height: 1.2;
}

p {
  margin: 0 0 12px 0;
}

a {
  color: var(--primary);
  text-decoration: none;
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}

a:hover {
  text-decoration: underline;
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 0.95em;
  background: rgba(15, 23, 42, 0.06);
  padding: 0 6px;
  border-radius: 8px;
}

:focus-visible {
  outline: none;
  box-shadow: var(--ring);
  border-radius: 10px;
}

@media (prefers-reduced-motion: reduce) {
  * {
    scroll-behavior: auto !important;
    transition: none !important;
    animation: none !important;
  }
}

.container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 20px;
}

.page-timeline main.container {
  max-width: none;
  padding: 0;
}

.page-timeline .timeline-shell {
  padding: 0;
}

.page-timeline .timeline-canvas {
  min-height: calc(100dvh - 120px);
}

.page-timeline .empty {
  padding: 48px 16px;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

.toolbar::-webkit-scrollbar {
  height: 8px;
}

.toolbar::-webkit-scrollbar-thumb {
  background: rgba(15, 23, 42, 0.15);
  border-radius: 999px;
}

.toolbar-spacer {
  flex: 1;
  min-width: 12px;
}

.seg {
  display: inline-flex;
  align-items: center;
  height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid rgba(15, 23, 42, 0.14);
  background: rgba(255, 255, 255, 0.75);
  color: rgba(15, 23, 42, 0.86);
  font-weight: 750;
  font-size: 13px;
  white-space: nowrap;
  transition: background 140ms ease, border-color 140ms ease, transform 140ms ease;
}

.seg:hover {
  text-decoration: none;
  background: rgba(15, 23, 42, 0.04);
}

.seg.is-on {
  background: rgba(37, 99, 235, 0.12);
  border-color: rgba(37, 99, 235, 0.28);
  color: var(--primary-2);
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(255, 255, 255, 0.75);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
}

.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s3);
  padding-top: 14px;
  padding-bottom: 14px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  justify-content: flex-end;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

.top-actions::-webkit-scrollbar {
  height: 8px;
}

.top-actions::-webkit-scrollbar-thumb {
  background: rgba(15, 23, 42, 0.15);
  border-radius: 999px;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-weight: 800;
  letter-spacing: -0.02em;
  font-size: 16px;
}

.nav {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.nav a {
  color: var(--text);
  font-weight: 650;
  font-size: 14px;
  padding: 8px 10px;
  border-radius: 999px;
  border: 1px solid transparent;
  transition: background 140ms ease, border-color 140ms ease;
}

.nav a:hover {
  text-decoration: none;
  background: rgba(15, 23, 42, 0.05);
}

.nav a.is-active,
.nav a[aria-current="page"] {
  background: rgba(37, 99, 235, 0.10);
  border-color: rgba(37, 99, 235, 0.25);
  color: var(--primary-2);
}

.card {
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid var(--border);
  border-radius: var(--r2);
  padding: var(--s4);
  margin-bottom: var(--s4);
  box-shadow: var(--shadow-sm);
}

.card h1,
.card h2 {
  margin: 0 0 10px 0;
  letter-spacing: -0.02em;
}

.card h1 {
  font-size: 22px;
}

.card h2 {
  font-size: 16px;
  color: rgba(15, 23, 42, 0.88);
}

.grid {
  display: grid;
  gap: var(--s4);
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

.actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 38px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: var(--primary);
  color: #ffffff;
  cursor: pointer;
  font-weight: 700;
  letter-spacing: -0.01em;
  transition: transform 120ms ease, filter 120ms ease, background 120ms ease;
}

.button:hover {
  text-decoration: none;
  filter: brightness(0.98);
}

.button:active {
  transform: translateY(1px);
}

.button.outline {
  background: transparent;
  color: var(--text);
  border-color: rgba(15, 23, 42, 0.18);
}

.button.outline:hover {
  background: rgba(15, 23, 42, 0.05);
}

.button.bad {
  background: var(--bad);
}

.notice {
  padding: 12px 14px;
  border-radius: var(--r1);
  margin-top: 12px;
  border: 1px solid rgba(15, 23, 42, 0.08);
}

.notice.bad {
  background: rgba(239, 68, 68, 0.10);
  color: #991b1b;
  border-color: rgba(239, 68, 68, 0.25);
}

.notice.warn {
  background: rgba(245, 158, 11, 0.12);
  color: #854d0e;
  border-color: rgba(245, 158, 11, 0.25);
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 750;
  border: 1px solid rgba(15, 23, 42, 0.12);
  background: rgba(255, 255, 255, 0.7);
}

.status-active {
  background: rgba(37, 99, 235, 0.10);
  border-color: rgba(37, 99, 235, 0.22);
  color: var(--primary-2);
}

.status-paused {
  background: rgba(245, 158, 11, 0.12);
  border-color: rgba(245, 158, 11, 0.22);
  color: #854d0e;
}

.status-archived {
  background: rgba(100, 116, 139, 0.12);
  border-color: rgba(100, 116, 139, 0.22);
  color: #334155;
}

.form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.field label {
  display: block;
  font-weight: 750;
  font-size: 13px;
  margin-bottom: 6px;
  color: rgba(15, 23, 42, 0.84);
}

.field input,
.field textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid rgba(15, 23, 42, 0.16);
  border-radius: var(--r1);
  background: rgba(255, 255, 255, 0.9);
  font-family: inherit;
  font-size: 14px;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

.field input:hover,
.field textarea:hover {
  border-color: rgba(15, 23, 42, 0.25);
}

.field input:focus,
.field textarea:focus {
  outline: none;
  border-color: rgba(37, 99, 235, 0.45);
  box-shadow: var(--ring);
}

.field-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 12px;
}

.list > li {
  padding: 12px 12px;
  border-radius: var(--r1);
  border: 1px solid rgba(15, 23, 42, 0.10);
  background: rgba(255, 255, 255, 0.7);
}

.log-title {
  display: flex;
  justify-content: space-between;
  font-weight: 750;
  margin-bottom: 4px;
}

.header-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.ai-meta {
  margin-bottom: 8px;
}

.muted {
  color: var(--muted);
}

.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--r1);
  border: 1px solid rgba(15, 23, 42, 0.10);
  background: rgba(255, 255, 255, 0.65);
}

.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin-top: 12px;
  min-width: 520px;
}

.table th,
.table td {
  text-align: left;
  padding: 10px 10px;
  border-bottom: 1px solid rgba(15, 23, 42, 0.08);
  font-size: 13px;
  vertical-align: top;
}

.table th {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: rgba(15, 23, 42, 0.56);
  background: rgba(255, 255, 255, 0.7);
  position: sticky;
  top: 0;
  z-index: 1;
}

.table tbody tr:hover td {
  background: rgba(37, 99, 235, 0.04);
}

.timeline {
  display: grid;
  gap: 16px;
}

.timeline-shell {
  padding: 6px 0 0 0;
}

.habit-ribbons {
  position: sticky;
  top: 44px;
  left: 0;
  z-index: 2;
  padding: 10px 10px 12px 10px;
  display: grid;
  gap: 8px;
  background: rgba(255, 255, 255, 0.82);
  border-bottom: 1px solid rgba(15, 23, 42, 0.08);
  width: 100vw;
}

.habit-ribbon {
  height: 34px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  border: 1px solid rgba(15, 23, 42, 0.14);
  background: rgba(16, 185, 129, 0.12);
  color: rgba(15, 23, 42, 0.92);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.65);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  transition: transform 120ms ease, filter 120ms ease, background 120ms ease, border-color 120ms ease;
}

.habit-ribbon:hover {
  text-decoration: none;
  filter: brightness(0.99);
  border-color: rgba(16, 185, 129, 0.26);
}

.habit-ribbon:active {
  transform: translateY(1px);
}

.habit-ribbon .chip-dot {
  background: rgba(16, 185, 129, 0.9);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.16);
}

.habit-ribbon.status-paused {
  background: rgba(245, 158, 11, 0.14);
  border-color: rgba(245, 158, 11, 0.26);
}

.habit-ribbon.status-paused .chip-dot {
  background: rgba(245, 158, 11, 0.9);
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.16);
}

.habit-ribbon.status-archived {
  background: rgba(100, 116, 139, 0.14);
  border-color: rgba(100, 116, 139, 0.22);
}

.habit-ribbon.status-archived .chip-dot {
  background: rgba(100, 116, 139, 0.9);
  box-shadow: 0 0 0 3px rgba(100, 116, 139, 0.16);
}

.timeline-scroll {
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  border-radius: 0;
  border: none;
  background: transparent;
  box-shadow: none;
}

.timeline-canvas {
  position: relative;
  min-height: 520px;
}

.timeline-shell[data-day-width] .timeline-grid {
  background-size: calc(var(--day-width, 64px)) 100%;
}

.timeline-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(to right, rgba(15, 23, 42, 0.06) 1px, transparent 1px);
  background-size: var(--day-width, 64px) 100%;
  pointer-events: none;
}

.timeline-scale {
  position: sticky;
  top: 0;
  z-index: 2;
  height: 44px;
  background: rgba(255, 255, 255, 0.82);
  border-bottom: 1px solid rgba(15, 23, 42, 0.08);
}

.timeline-scale {
  border-radius: 0;
  border: none;
}

.timeline-tick {
  position: absolute;
  top: 0;
  width: var(--day-width, 64px);
  height: 100%;
  border-left: 1px solid rgba(15, 23, 42, 0.10);
  padding-left: 8px;
  color: rgba(15, 23, 42, 0.70);
}

.timeline-tick.is-week {
  border-left-color: rgba(15, 23, 42, 0.18);
}

.tick-month {
  font-size: 11px;
  font-weight: 750;
  color: rgba(15, 23, 42, 0.55);
  margin-top: 6px;
}

.tick-day {
  font-size: 13px;
  font-weight: 850;
  letter-spacing: -0.01em;
  margin-top: 2px;
  color: rgba(15, 23, 42, 0.85);
}

.timeline-today {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: linear-gradient(180deg, rgba(37, 99, 235, 0.9), rgba(37, 99, 235, 0.35));
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.08);
}

.timeline-lanes {
  position: relative;
  padding: 14px 10px 18px 10px;
  display: grid;
  gap: 10px;
}

.timeline-lane {
  position: relative;
  height: 34px;
}

.timeline-chip {
  position: absolute;
  top: 0;
  height: 34px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  border: 1px solid rgba(15, 23, 42, 0.14);
  background: rgba(37, 99, 235, 0.14);
  color: rgba(15, 23, 42, 0.92);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.65);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  transition: transform 120ms ease, filter 120ms ease, background 120ms ease, border-color 120ms ease;
}

.timeline-chip:hover {
  text-decoration: none;
  filter: brightness(0.99);
  border-color: rgba(37, 99, 235, 0.26);
}

.timeline-chip:active {
  transform: translateY(1px);
}

.timeline-chip.status-paused {
  background: rgba(245, 158, 11, 0.18);
  border-color: rgba(245, 158, 11, 0.28);
}

.timeline-chip.status-archived {
  background: rgba(100, 116, 139, 0.16);
  border-color: rgba(100, 116, 139, 0.22);
}

.timeline-chip.is-ai {
  background: rgba(148, 163, 184, 0.16);
  border-color: rgba(100, 116, 139, 0.28);
}

.timeline-chip.is-ai .chip-dot {
  background: rgba(100, 116, 139, 0.8);
  box-shadow: 0 0 0 3px rgba(100, 116, 139, 0.16);
}

.timeline-chip.is-ai .chip-text {
  width: 100%;
  color: transparent;
  user-select: none;
}

.chip-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: rgba(37, 99, 235, 0.85);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
}

.timeline-chip.status-paused .chip-dot {
  background: rgba(245, 158, 11, 0.9);
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.16);
}

.timeline-chip.status-archived .chip-dot {
  background: rgba(100, 116, 139, 0.9);
  box-shadow: 0 0 0 3px rgba(100, 116, 139, 0.16);
}

.chip-text {
  font-weight: 800;
  letter-spacing: -0.01em;
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 720px) {
  .site-header .container {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  .container {
    padding: 16px;
  }
  .field-row {
    grid-template-columns: 1fr;
  }
  .grid {
    grid-template-columns: 1fr;
  }
  .actions .button,
  .actions a.button {
    flex: 1;
  }
  .toolbar {
    padding-left: 0;
    padding-right: 0;
  }
}

.empty {
  padding: 24px 0;
  text-align: center;
}

.empty-title {
  font-weight: 900;
  letter-spacing: -0.02em;
  margin-bottom: 6px;
}

.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.35);
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease;
  z-index: 30;
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  height: 100dvh;
  width: min(520px, 96vw);
  background: rgba(255, 255, 255, 0.92);
  border-left: 1px solid rgba(15, 23, 42, 0.12);
  box-shadow: var(--shadow);
  transform: translateX(102%);
  transition: transform 200ms ease;
  z-index: 40;
  display: grid;
  grid-template-rows: auto 1fr;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.drawer-open .drawer-overlay {
  opacity: 1;
  pointer-events: auto;
}

.drawer-open .drawer {
  transform: translateX(0);
}

.drawer-head {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 16px 16px 12px 16px;
  border-bottom: 1px solid rgba(15, 23, 42, 0.10);
  background: rgba(255, 255, 255, 0.96);
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.drawer-title {
  font-weight: 850;
  letter-spacing: -0.02em;
  font-size: 16px;
}

.drawer-meta {
  font-size: 13px;
  margin-top: 4px;
}

.drawer-section {
  padding: 14px 16px;
  border-bottom: 1px solid rgba(15, 23, 42, 0.08);
}

.drawer-section h2 {
  margin: 0 0 10px 0;
}

.ai-detail {
  display: grid;
  gap: 10px;
}

.ai-card {
  border: 1px solid rgba(15, 23, 42, 0.1);
  border-radius: 10px;
  background: rgba(248, 250, 252, 0.9);
  padding: 10px 12px;
}

.ai-card-title {
  font-size: 12px;
  font-weight: 800;
  color: rgba(15, 23, 42, 0.62);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 6px;
}

.ai-segments {
  display: grid;
  gap: 8px;
}

.ai-segment {
  border: 1px solid rgba(15, 23, 42, 0.08);
  background: rgba(255, 255, 255, 0.7);
  border-radius: 8px;
  padding: 8px 10px;
}

.ai-segment-time {
  font-size: 12px;
  color: rgba(15, 23, 42, 0.6);
}

.ai-segment-title {
  margin-top: 2px;
  font-size: 14px;
  font-weight: 700;
  color: rgba(15, 23, 42, 0.9);
}

.ai-segment-type {
  margin-top: 2px;
  font-size: 12px;
  color: rgba(15, 23, 42, 0.56);
}

.ai-list {
  margin: 0;
  padding-left: 18px;
  color: rgba(15, 23, 42, 0.82);
}

.ai-list li + li {
  margin-top: 4px;
}

@media (max-width: 720px) {
  .drawer {
    width: 100vw;
    border-left: none;
  }
}
