:root {
  --bg: #12110f;
  --bg-soft: #181613;
  --surface: #1e1b17;
  --surface-2: #26221c;
  --line: rgba(243, 236, 227, 0.08);
  --text: #f3ece3;
  --muted: #9a9186;
  --accent: #e8b86d;
  --accent-ink: #2a2112;
  --high: #e07a6a;
  --medium: #e8b86d;
  --low: #7dbe8a;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
  --radius: 22px;
  --serif: "Fraunces", "Iowan Old Style", Georgia, serif;
  --sans: "Outfit", "Avenir Next", "Segoe UI", sans-serif;
  color-scheme: dark;
  --ease: 220ms ease;
}

[data-theme="light"] {
  --bg: #f3ece1;
  --bg-soft: #efe6d8;
  --surface: #fffaf2;
  --surface-2: #f7efe3;
  --line: rgba(28, 25, 21, 0.08);
  --text: #1c1915;
  --muted: #6e675c;
  --accent: #b56a2b;
  --accent-ink: #fff8ee;
  --high: #c24b3a;
  --medium: #b56a2b;
  --low: #3d7a4a;
  --shadow: 0 20px 50px rgba(72, 48, 18, 0.12);
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

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

body {
  font-family: var(--sans);
  background:
    radial-gradient(1200px 600px at 10% -10%, color-mix(in srgb, var(--accent) 16%, transparent), transparent 55%),
    radial-gradient(900px 500px at 100% 0%, color-mix(in srgb, var(--high) 10%, transparent), transparent 50%),
    var(--bg);
  color: var(--text);
  line-height: 1.5;
  transition: background-color var(--ease), color var(--ease);
}

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

button {
  cursor: pointer;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.grain {
  pointer-events: none;
  position: fixed;
  inset: 0;
  opacity: 0.18;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  mix-blend-mode: overlay;
}

.app {
  width: min(1180px, calc(100% - 32px));
  margin: 28px auto 64px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background:
    radial-gradient(circle at 30% 30%, #fff3d4, var(--accent) 46%, #8a5a1f);
  box-shadow: 0 0 0 6px color-mix(in srgb, var(--accent) 16%, transparent);
}

.eyebrow {
  margin: 0;
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}

h1,
h2,
h3,
h4 {
  font-family: var(--serif);
  font-weight: 560;
  letter-spacing: -0.03em;
  margin: 0;
}

h1 {
  font-size: 1.7rem;
}

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

.search {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: min(280px, 46vw);
  padding: 0 14px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface) 84%, transparent);
  backdrop-filter: blur(16px);
  transition: box-shadow var(--ease), border-color var(--ease);
}

.search svg {
  width: 18px;
  height: 18px;
  color: var(--muted);
  flex: none;
}

.search input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
}

.icon-btn,
.primary,
.filter,
.text-btn,
.ghost,
.section-nav-btn,
.view-btn,
.theme-choice-btn,
.danger-btn,
.cal-view-btn,
.date-preset-btn {
  border: 0;
  background: none;
}

.icon-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--surface);
  display: grid;
  place-items: center;
  transition: background var(--ease), border-color var(--ease), transform 120ms ease;
}

.icon-btn:hover {
  background: var(--surface-2);
}

.icon-btn:active {
  transform: scale(0.96);
}

.icon-btn svg {
  width: 20px;
  height: 20px;
}

.ghost-btn-sm {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 0;
  background: transparent;
}

.ghost-btn-sm:hover {
  background: var(--surface-2);
}

.ghost-btn-sm svg {
  width: 16px;
  height: 16px;
}

[data-theme="dark"] .icon-sun,
[data-theme="light"] .icon-moon {
  display: none;
}

/* User Account Chip in Topbar */
.user-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 14px 4px 6px;
  height: 44px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line);
  cursor: pointer;
  transition: background var(--ease), border-color var(--ease), transform 120ms ease;
}

.user-chip:hover {
  background: var(--surface-2);
  border-color: color-mix(in srgb, var(--accent) 30%, transparent);
}

.user-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 0.8rem;
  font-weight: 600;
  display: grid;
  place-items: center;
  text-transform: uppercase;
  flex: none;
}

.user-email {
  font-size: 0.85rem;
  color: var(--text);
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Layout */
.layout {
  display: grid;
  grid-template-columns: 310px 1fr;
  gap: 20px;
  align-items: start;
}

.panel,
.stage,
.composer,
.task,
.progress-card,
.empty,
.calendar-view-container,
.calendar-header {
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.panel,
.stage {
  border-radius: var(--radius);
}

.panel {
  padding: 26px 24px;
  position: sticky;
  top: 16px;
}

.date-block {
  margin-bottom: 20px;
}

.date-label {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 0.88rem;
}

.lede {
  color: var(--muted);
  margin: 10px 0 0;
  font-size: 0.92rem;
  line-height: 1.4;
}

/* Section Navigation (Tasks vs Calendar) */
.section-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  background: var(--bg-soft);
  padding: 4px;
  border-radius: 14px;
  margin-bottom: 20px;
}

.section-nav-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 38px;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 500;
  transition: background var(--ease), color var(--ease);
}

.section-nav-btn svg {
  width: 16px;
  height: 16px;
}

.section-nav-btn.is-active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.14);
}

.progress-card {
  margin: 0 0 18px;
  padding: 16px;
  border-radius: 18px;
  display: flex;
  gap: 14px;
  align-items: center;
  box-shadow: none;
}

.progress-ring {
  position: relative;
  width: 84px;
  height: 84px;
  flex: none;
}

.progress-ring svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.ring-track,
.ring-value {
  fill: none;
  stroke-width: 8;
}

.ring-track {
  stroke: var(--surface-2);
}

.ring-value {
  stroke: var(--accent);
  stroke-linecap: round;
  stroke-dasharray: 226;
  stroke-dashoffset: 226;
  transition: stroke-dashoffset 420ms ease;
}

.ring-label {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  text-align: center;
}

.ring-label strong {
  font-family: var(--serif);
  font-size: 1.2rem;
  line-height: 1;
}

.ring-label span,
.muted,
.progress-copy {
  color: var(--muted);
}

.progress-copy {
  margin: 0 0 4px;
}

.filters {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.filter {
  height: 40px;
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--muted);
  transition: background var(--ease), color var(--ease);
}

.filter.is-active {
  background: var(--text);
  color: var(--bg);
}

.priority-legend {
  display: flex;
  gap: 14px;
  margin-top: 18px;
  color: var(--muted);
  font-size: 0.82rem;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 6px;
}

.dot.high { background: var(--high); }
.dot.medium { background: var(--medium); }
.dot.low { background: var(--low); }

/* Stage */
.stage {
  padding: 22px;
  min-height: 660px;
}

.composer {
  padding: 14px;
  border-radius: 18px;
  box-shadow: none;
}

.composer-row {
  display: flex;
  gap: 10px;
}

#task-input,
select,
#due-input,
.task-title-input,
.auth-field input {
  width: 100%;
  height: 48px;
  border: 0;
  border-radius: 14px;
  background: var(--bg-soft);
  padding: 0 14px;
  outline: none;
  color-scheme: inherit;
  color: var(--text);
}

select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239a9186' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

#task-input:focus,
select:focus,
#due-input:focus,
.task-title-input:focus,
.search:focus-within,
.icon-btn:focus-visible,
.primary:focus-visible,
.filter:focus-visible,
.task:focus-within,
.auth-field input:focus {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 45%, transparent);
}

.primary {
  flex: none;
  height: 48px;
  padding: 0 18px;
  border-radius: 14px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
  transition: transform 120ms ease, opacity var(--ease);
}

.primary:hover {
  opacity: 0.94;
}

.primary:active {
  transform: scale(0.98);
}

.composer-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 10px;
}

/* List Head & View Switcher */
.list-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 18px 4px 10px;
}

.list-head-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.view-switcher {
  display: flex;
  background: var(--surface-2);
  padding: 2px;
  border-radius: 10px;
  border: 1px solid var(--line);
}

.view-btn {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: var(--muted);
  transition: background var(--ease), color var(--ease);
}

.view-btn svg {
  width: 14px;
  height: 14px;
}

.view-btn.is-active {
  background: var(--text);
  color: var(--bg);
}

.text-btn {
  color: var(--muted);
  transition: color var(--ease);
}

.text-btn:hover,
.ghost:hover {
  color: var(--text);
}

/* Task List */
.task-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.task {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: start;
  padding: 14px;
  border-radius: 18px;
  box-shadow: none;
  animation: rise 240ms ease;
  transition: background-color var(--ease), border-color var(--ease), transform 120ms ease;
}

.task.is-dragging {
  opacity: 0.45;
}

.task.completed .task-title {
  text-decoration: line-through;
  color: var(--muted);
}

.check {
  width: 22px;
  height: 22px;
  margin-top: 3px;
  border-radius: 50%;
  border: 1.6px solid color-mix(in srgb, var(--text) 28%, transparent);
  background: transparent;
  display: grid;
  place-items: center;
  padding: 0;
  transition: background var(--ease), border-color var(--ease);
}

.task.completed .check {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.check svg {
  width: 12px;
  height: 12px;
  opacity: 0;
}

.task.completed .check svg {
  opacity: 1;
}

.task-title {
  margin: 0;
  font-size: 1.02rem;
  cursor: text;
  word-break: break-word;
}

.task-title-input {
  width: 100%;
  font-size: 1.02rem;
  margin: 0;
}

.task-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.pill {
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  user-select: none;
  transition: transform 120ms ease, background var(--ease), color var(--ease);
}

.pill.interactive {
  cursor: pointer;
}

.pill.interactive:hover {
  background: color-mix(in srgb, var(--surface-2) 65%, var(--accent) 35%);
  color: var(--text);
  transform: translateY(-1px);
}

.pill.high { color: var(--high); }
.pill.medium { color: var(--medium); }
.pill.low { color: var(--low); }
.pill.overdue { color: var(--high); }

.task-actions {
  display: flex;
  gap: 6px;
}

.ghost {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  color: var(--muted);
  display: grid;
  place-items: center;
  transition: color var(--ease), background var(--ease);
}

.ghost:hover {
  background: var(--surface-2);
  color: var(--text);
}

.ghost svg {
  width: 16px;
  height: 16px;
}

/* Task Grid Mode */
.task-list.is-grid {
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}

.task-list.is-grid .task {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 140px;
  padding: 16px;
}

.task-list.is-grid .task-body {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  width: 100%;
}

.task-list.is-grid .task-bottom-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

/* Shimmer Loading Skeleton */
.task-skeleton {
  padding: 16px;
  border-radius: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  display: flex;
  gap: 14px;
  align-items: center;
  position: relative;
  overflow: hidden;
}

.task-skeleton::after {
  content: "";
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--accent) 8%, transparent), transparent);
  animation: shimmer 1.6s infinite;
}

.skeleton-circle {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--surface-2);
  flex: none;
}

.skeleton-lines {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.skeleton-line {
  height: 14px;
  border-radius: 6px;
  background: var(--surface-2);
}

.skeleton-line.short { width: 40%; }
.skeleton-line.long { width: 75%; }

@keyframes shimmer {
  100% { transform: translateX(100%); }
}

/* -------------------------------------------------------------
   Calendar & Schedule Styles (Phase 6B Redesign)
   ------------------------------------------------------------- */

.calendar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-radius: 18px;
  margin-bottom: 16px;
  box-shadow: none;
  gap: 16px;
  flex-wrap: wrap;
}

.calendar-header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.calendar-header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.calendar-nav-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.cal-nav-btn {
  width: 36px;
  height: 36px;
}

.cal-today-btn {
  font-weight: 500;
  font-size: 0.88rem;
  padding: 6px 12px;
  border-radius: 8px;
  background: var(--surface-2);
}

.calendar-date-heading {
  font-size: 1.22rem;
  font-family: var(--serif);
}

.cal-view-selector {
  display: flex;
  background: var(--bg-soft);
  padding: 3px;
  border-radius: 11px;
  border: 1px solid var(--line);
}

.cal-view-btn {
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--muted);
  transition: background var(--ease), color var(--ease);
}

.cal-view-btn.is-active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.cal-add-btn {
  height: 38px;
  font-size: 0.85rem;
  padding: 0 14px;
}

.calendar-view-container {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Time Grid: Day, 3-Day, Week */
.timegrid-header-row {
  display: flex;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 95%, transparent);
  position: sticky;
  top: 0;
  z-index: 20;
}

.timegrid-axis-spacer {
  width: 60px;
  flex: none;
  border-right: 1px solid var(--line);
}

.timegrid-col-header {
  flex: 1;
  padding: 10px 8px;
  text-align: center;
  border-right: 1px solid var(--line);
  user-select: none;
}

.timegrid-col-header:last-child {
  border-right: 0;
}

.col-header-weekday {
  font-size: 0.76rem;
  text-transform: uppercase;
  color: var(--muted);
  letter-spacing: 0.06em;
}

.col-header-daynum {
  font-size: 1.15rem;
  font-family: var(--serif);
  font-weight: 600;
  margin-top: 2px;
  display: inline-block;
  width: 28px;
  height: 28px;
  line-height: 28px;
  border-radius: 50%;
}

.timegrid-col-header.is-today .col-header-daynum {
  background: var(--accent);
  color: var(--accent-ink);
}

.timegrid-body-scroll {
  max-height: 580px;
  overflow-y: auto;
  position: relative;
}

.timegrid-canvas {
  display: flex;
  position: relative;
  min-height: 780px; /* 15 hours * 52px */
}

.timegrid-time-axis {
  width: 60px;
  flex: none;
  border-right: 1px solid var(--line);
}

.time-axis-marker {
  height: 52px;
  font-size: 0.72rem;
  color: var(--muted);
  text-align: right;
  padding-right: 8px;
  transform: translateY(-8px);
  user-select: none;
}

.timegrid-columns-container {
  flex: 1;
  display: flex;
  position: relative;
}

.timegrid-day-column {
  flex: 1;
  border-right: 1px solid var(--line);
  position: relative;
  min-height: 100%;
}

.timegrid-day-column:last-child {
  border-right: 0;
}

.timegrid-hour-line {
  position: absolute;
  left: 0;
  right: 0;
  height: 52px;
  border-top: 1px solid var(--line);
  cursor: pointer;
}

.timegrid-hour-line:hover {
  background: color-mix(in srgb, var(--accent) 4%, transparent);
}

/* Time Block Cards */
.time-block-card {
  position: absolute;
  border-radius: 10px;
  background: var(--surface-2);
  border-left: 4px solid var(--accent);
  padding: 6px 10px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.22);
  cursor: pointer;
  z-index: 10;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  transition: transform 120ms ease, box-shadow var(--ease);
}

.time-block-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.32);
  z-index: 15;
}

.time-block-card.accent {
  border-left-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 14%, var(--surface-2));
}

.time-block-card.high {
  border-left-color: var(--high);
  background: color-mix(in srgb, var(--high) 14%, var(--surface-2));
}

.time-block-card.medium {
  border-left-color: var(--medium);
  background: color-mix(in srgb, var(--medium) 14%, var(--surface-2));
}

.time-block-card.low {
  border-left-color: var(--low);
  background: color-mix(in srgb, var(--low) 14%, var(--surface-2));
}

.time-block-title {
  font-weight: 560;
  font-size: 0.84rem;
  margin: 0;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.time-block-time {
  font-size: 0.72rem;
  color: var(--muted);
  margin: 2px 0 0;
}

/* Month View */
.month-weekday-header {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  background: color-mix(in srgb, var(--surface) 95%, transparent);
  border-bottom: 1px solid var(--line);
  padding: 10px 0;
  text-align: center;
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.month-days-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  grid-auto-rows: minmax(105px, 1fr);
}

.month-day-cell {
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  cursor: pointer;
  transition: background var(--ease);
  min-height: 105px;
}

.month-day-cell:nth-child(7n) {
  border-right: 0;
}

.month-day-cell:hover {
  background: color-mix(in srgb, var(--accent) 3%, transparent);
}

.month-day-cell.is-other-month {
  opacity: 0.42;
}

.month-cell-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.month-cell-daynum {
  font-size: 0.86rem;
  font-weight: 600;
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 50%;
}

.month-day-cell.is-today .month-cell-daynum {
  background: var(--accent);
  color: var(--accent-ink);
}

.month-blocks-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow: hidden;
}

.month-block-chip {
  padding: 3px 6px;
  border-radius: 6px;
  font-size: 0.74rem;
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  background: var(--surface-2);
  border-left: 3px solid var(--accent);
}

.month-block-chip.accent { border-left-color: var(--accent); }
.month-block-chip.high { border-left-color: var(--high); }
.month-block-chip.medium { border-left-color: var(--medium); }
.month-block-chip.low { border-left-color: var(--low); }

/* -------------------------------------------------------------
   Task Due Date Picker Modal (Phase 6B)
   ------------------------------------------------------------- */

.date-picker-card {
  width: min(380px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  border-radius: var(--radius);
  padding: 24px;
  animation: rise 240ms ease;
}

.truncate-text {
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.date-presets-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 16px;
}

.date-preset-btn {
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--bg-soft);
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 500;
  text-align: center;
  transition: background var(--ease), color var(--ease);
}

.date-preset-btn:hover {
  background: var(--surface-2);
}

.date-preset-btn.danger-preset {
  color: var(--high);
}

.mini-cal-container {
  background: var(--bg-soft);
  border-radius: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  margin-bottom: 16px;
}

.mini-cal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.mini-cal-month-label {
  font-size: 0.88rem;
  font-weight: 600;
}

.mini-cal-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  font-size: 0.72rem;
  color: var(--muted);
  margin-bottom: 6px;
}

.mini-cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}

.mini-cal-day {
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  font-size: 0.82rem;
  color: var(--text);
  border: 0;
  background: transparent;
  cursor: pointer;
  transition: background var(--ease), color var(--ease);
}

.mini-cal-day:hover {
  background: var(--surface-2);
}

.mini-cal-day.is-other-month {
  color: var(--muted);
  opacity: 0.4;
}

.mini-cal-day.is-today {
  border: 1px solid var(--accent);
}

.mini-cal-day.is-selected {
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
}

.date-picker-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.date-selected-label {
  font-size: 0.82rem;
}

.date-picker-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Empty State */
.empty {
  margin-top: 28px;
  padding: 42px 20px;
  text-align: center;
  border-radius: 18px;
  box-shadow: none;
  color: var(--muted);
}

.empty svg {
  width: 120px;
  height: 80px;
  margin-bottom: 8px;
}

.empty h3 {
  margin: 0 0 6px;
  font-size: 1.3rem;
  color: var(--text);
}

.empty p {
  margin: 0;
  font-size: 0.92rem;
}

/* Auth Gate (Centered Standalone View) */
.auth-gate {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: calc(100vh - 160px);
  padding: 20px 0;
  animation: rise 320ms ease;
}

.auth-card {
  width: min(440px, 100%);
  background: color-mix(in srgb, var(--surface) 96%, transparent);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  border-radius: var(--radius);
  padding: 36px 32px;
}

.auth-header {
  text-align: center;
  margin-bottom: 24px;
}

.auth-brand-mark {
  margin: 0 auto 12px;
}

.auth-header h2 {
  font-size: 1.6rem;
  margin: 6px 0 8px;
}

.auth-subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.4;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  background: var(--bg-soft);
  padding: 4px;
  border-radius: 14px;
  margin-bottom: 20px;
}

.auth-tab {
  height: 38px;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-weight: 500;
  font-size: 0.9rem;
  transition: background var(--ease), color var(--ease);
}

.auth-tab.is-active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

.btn-google {
  width: 100%;
  height: 48px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  font-weight: 500;
  font-size: 0.94rem;
  cursor: pointer;
  transition: background var(--ease), border-color var(--ease), transform 120ms ease;
}

.btn-google:hover {
  background: var(--surface-2);
  border-color: color-mix(in srgb, var(--accent) 30%, transparent);
}

.btn-google:active {
  transform: scale(0.99);
}

.google-icon {
  width: 18px;
  height: 18px;
  flex: none;
}

.auth-divider {
  display: flex;
  align-items: center;
  text-align: center;
  margin: 20px 0;
  color: var(--muted);
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1;
  border-bottom: 1px solid var(--line);
}

.auth-divider span {
  padding: 0 12px;
}

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

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

.auth-field label {
  font-size: 0.84rem;
  color: var(--muted);
}

.auth-field-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.auth-forgot {
  font-size: 0.8rem;
  color: var(--accent);
  padding: 0;
  cursor: pointer;
}

.auth-forgot:hover {
  text-decoration: underline;
}

.auth-message {
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 0.86rem;
  line-height: 1.4;
}

.auth-message.is-error {
  background: color-mix(in srgb, var(--high) 15%, transparent);
  border: 1px solid color-mix(in srgb, var(--high) 40%, transparent);
  color: var(--high);
}

.auth-message.is-success {
  background: color-mix(in srgb, var(--low) 15%, transparent);
  border: 1px solid color-mix(in srgb, var(--low) 40%, transparent);
  color: var(--low);
}

.auth-submit {
  width: 100%;
  height: 48px;
  margin-top: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.auth-submit:disabled,
.btn-google:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Modals (Settings, Migration, Timeblock) */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(12px);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 100;
  animation: fadeIn 200ms ease;
}

.settings-card,
.timeblock-card,
.migration-card {
  width: min(460px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  border-radius: var(--radius);
  padding: 28px;
  animation: rise 280ms ease;
}

.settings-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 20px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.settings-title-group h3 {
  font-size: 1.4rem;
  margin: 0 0 2px;
}

.settings-title-group p {
  margin: 0;
  font-size: 0.86rem;
}

.settings-body {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

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

.settings-section h4 {
  font-size: 0.95rem;
  color: var(--text);
}

.settings-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-soft);
  padding: 10px 14px;
  border-radius: 12px;
}

.settings-label {
  font-size: 0.88rem;
  font-weight: 500;
}

.settings-sub {
  margin: 2px 0 0;
  font-size: 0.78rem;
  color: var(--muted);
}

.settings-value {
  font-size: 0.88rem;
  color: var(--muted);
}

.code-font {
  font-family: monospace;
  font-size: 0.8rem;
  background: var(--surface-2);
  padding: 2px 6px;
  border-radius: 6px;
}

.theme-picker-group {
  display: flex;
  gap: 4px;
  background: var(--surface-2);
  padding: 3px;
  border-radius: 10px;
}

.theme-choice-btn {
  padding: 4px 10px;
  border-radius: 7px;
  font-size: 0.8rem;
  color: var(--muted);
  transition: background var(--ease), color var(--ease);
}

.theme-choice-btn.is-active {
  background: var(--text);
  color: var(--bg);
}

.settings-danger-zone {
  margin-top: 10px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.danger-btn {
  width: 100%;
  height: 44px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--high) 15%, transparent);
  border: 1px solid color-mix(in srgb, var(--high) 35%, transparent);
  color: var(--high);
  font-weight: 600;
  font-size: 0.9rem;
  transition: background var(--ease);
}

.danger-btn:hover {
  background: color-mix(in srgb, var(--high) 25%, transparent);
}

.timeblock-form-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
}

.danger-text {
  color: var(--high);
  font-size: 0.88rem;
}

.danger-text:hover {
  text-decoration: underline;
}

.migration-icon {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  color: var(--accent);
  display: grid;
  place-items: center;
  margin: 0 auto 16px;
}

.migration-icon svg {
  width: 26px;
  height: 26px;
}

.migration-card {
  text-align: center;
}

.migration-copy {
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.5;
  margin: 0 0 24px;
}

.migration-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(20px);
  background: var(--text);
  color: var(--bg);
  padding: 12px 18px;
  border-radius: 999px;
  font-weight: 500;
  font-size: 0.9rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  opacity: 0;
  pointer-events: none;
  transition: 240ms ease;
  z-index: 200;
}

.toast.is-on {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@media (max-width: 860px) {
  .app {
    width: min(100% - 20px, 720px);
    margin-top: 16px;
  }

  .layout,
  .composer-row,
  .composer-meta {
    grid-template-columns: 1fr;
    display: grid;
  }

  .composer-row {
    display: grid;
  }

  .panel {
    position: static;
  }

  .stage {
    min-height: auto;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .search {
    min-width: 0;
    flex: 1;
  }

  .topbar-actions {
    width: 100%;
    justify-content: space-between;
  }

  .calendar-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .calendar-header-right {
    width: 100%;
    justify-content: space-between;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
