:root {
  --bg: #f4f5f7;
  --bg-elevated: rgba(255, 255, 255, 0.78);
  --ink: #111827;
  --muted: #6b7280;
  --line: rgba(15, 23, 42, 0.08);
  --accent: #0a84ff;
  --accent-2: #2563eb;
  --accent-soft: rgba(10, 132, 255, 0.08);
  --ok: #166534;
  --warn: #b45309;
  --danger: #b91c1c;
  --shadow: 0 24px 60px rgba(15, 23, 42, 0.08);
  --radius-xl: 1.75rem;
  --radius-lg: 1.35rem;
  --radius-md: 1rem;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100dvh;
  color: var(--ink);
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC", "PingFang SC",
    sans-serif;
  -webkit-text-size-adjust: 100%;
  background:
    radial-gradient(circle at top left, rgba(109, 181, 255, 0.18), transparent 34%),
    radial-gradient(circle at top right, rgba(255, 255, 255, 0.8), transparent 28%),
    linear-gradient(180deg, #f8fafc 0%, #eff4fa 45%, #f7f8fb 100%);
}

h1,
h2,
h3 {
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC", "PingFang SC",
    sans-serif;
  letter-spacing: -0.02em;
}

.bg-grid {
  display: none;
}

.app-shell {
  position: relative;
  z-index: 1;
  width: min(1080px, calc(100% - 2rem));
  margin: max(0.9rem, env(safe-area-inset-top)) auto 2rem;
  padding-bottom: max(1rem, env(safe-area-inset-bottom));
  display: grid;
  gap: 0.8rem;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 1rem;
  padding: 0.12rem 0;
}

.topbar-copy {
  display: grid;
  gap: 0.12rem;
}

.topbar-status {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.45rem;
}

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

.topbar h1 {
  margin: 0.14rem 0 0;
  font-size: clamp(2.35rem, 4vw, 3rem);
  font-weight: 700;
}

.auth-shell {
  width: min(33rem, calc(100% - 1.5rem));
  gap: 0.9rem;
}

.auth-shell-header,
.auth-shell-copy,
.auth-shell-card {
  display: grid;
  gap: 0.34rem;
}

.auth-shell-title {
  margin: 0;
  font-size: clamp(2rem, 1.4rem + 1vw, 2.65rem);
  line-height: 1.04;
  letter-spacing: -0.04em;
}

.auth-shell-kicker {
  margin: 0;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.auth-shell-heading {
  margin: 0.08rem 0 0;
  font-size: clamp(1.38rem, 1.12rem + 0.55vw, 1.72rem);
  line-height: 1.12;
}

.auth-shell-body,
.auth-shell-note {
  margin: 0;
  color: var(--muted);
  line-height: 1.58;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 999px;
  padding: 0.42rem 0.82rem;
  font-size: 0.8rem;
  font-weight: 700;
}

.pill-primary {
  border-color: rgba(10, 132, 255, 0.14);
  background: rgba(255, 255, 255, 0.88);
  color: #0f172a;
}

.pill-warn {
  border-color: rgba(220, 38, 38, 0.12);
  background: rgba(255, 244, 244, 0.92);
  color: #b42318;
}

.tabs {
  display: flex;
  width: fit-content;
  gap: 0.38rem;
  flex-wrap: wrap;
  padding: 0.34rem;
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(18px);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.72);
}

.tab {
  border: 1px solid transparent;
  background: transparent;
  color: #6b7280;
  border-radius: 999px;
  min-height: 2.4rem;
  padding: 0.52rem 0.95rem;
  font-size: 0.88rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  white-space: nowrap;
  transition: background 150ms ease, color 150ms ease, transform 150ms ease;
}

.tab:hover {
  transform: translateY(-1px);
}

.tab.active {
  color: white;
  border-color: transparent;
  background: linear-gradient(180deg, #1f2937, #111827);
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.18);
}

.tab-capture {
  color: white;
  background: linear-gradient(180deg, #1f2937, #111827);
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.18);
  font-size: 1.25rem;
  min-width: 3rem;
}

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

.capture-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: rgba(15, 23, 42, 0.42);
  backdrop-filter: blur(12px);
  animation: capture-overlay-in 150ms ease;
}

.capture-sheet {
  width: min(42rem, 100%);
  max-height: min(50rem, calc(100dvh - 2rem));
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  border: 1px solid rgba(255, 255, 255, 0.84);
  border-radius: 1.75rem;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(246, 249, 253, 0.97)),
    white;
  box-shadow: 0 32px 90px rgba(15, 23, 42, 0.3);
  padding: 1.1rem;
  animation: capture-sheet-in 180ms ease;
}

.capture-form,
.capture-detail-fields {
  display: grid;
  gap: 0.78rem;
}

.capture-sheet-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 1rem;
}

.capture-sheet-head h2 {
  margin: 0.12rem 0 0;
  font-size: 1.55rem;
}

.capture-close {
  min-height: 2.2rem;
  padding: 0.45rem 0.72rem;
}

.capture-title-field input {
  min-height: 3.5rem;
  border-radius: 1.15rem;
  padding: 0.82rem 1rem;
  font-size: 1.08rem;
  font-weight: 650;
}

.capture-recognition {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-width: 0;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
}

.capture-recognition .chip-row {
  min-width: 0;
}

.capture-intents {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.5rem;
}

.capture-intent {
  min-width: 0;
  min-height: 2.9rem;
  padding: 0.55rem 0.45rem;
  white-space: normal;
  line-height: 1.2;
}

.capture-intent.primary-intent {
  border-color: transparent;
  background: linear-gradient(180deg, #1f2937, #111827);
  color: white;
  box-shadow: 0 12px 26px rgba(15, 23, 42, 0.2);
}

.capture-intent.start-intent:not(.primary-intent) {
  border-color: rgba(22, 101, 52, 0.16);
  color: #166534;
  background: rgba(240, 253, 244, 0.88);
}

.capture-hint {
  margin: -0.25rem 0 0;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.4;
  text-align: center;
}

.capture-project-context {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  border-radius: 0.9rem;
  background: rgba(239, 246, 255, 0.9);
  padding: 0.72rem 0.85rem;
  color: #1e3a8a;
  font-size: 0.82rem;
}

.capture-details {
  border-top: 1px solid var(--line);
  padding-top: 0.72rem;
}

.capture-details > summary {
  cursor: pointer;
  color: #334155;
  font-size: 0.86rem;
  font-weight: 750;
}

.capture-detail-fields {
  padding-top: 0.82rem;
}

.capture-detail-fields > button {
  width: 100%;
  min-height: 2.9rem;
}

.tag-field {
  display: grid;
  min-width: 0;
  gap: 0.28rem;
  color: var(--muted);
  font-size: 0.86rem;
}

.tag-editor {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.38rem;
  min-height: 2.68rem;
  border: 1px solid rgba(15, 23, 42, 0.1);
  border-radius: 1rem;
  background: rgba(255, 255, 255, 0.9);
  padding: 0.34rem 0.46rem;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

.tag-editor:focus-within {
  border-color: var(--accent-2);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.tag-token-list {
  display: contents;
}

.tag-token {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  max-width: 100%;
  min-height: 1.9rem;
  border: 1px solid rgba(37, 99, 235, 0.12);
  border-radius: 999px;
  background: rgba(239, 246, 255, 0.92);
  color: #1e40af;
  padding: 0.28rem 0.58rem;
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.1;
  overflow-wrap: anywhere;
}

button.tag-token-remove {
  min-height: 1.9rem;
  border-color: rgba(15, 23, 42, 0.09);
  background: rgba(241, 245, 249, 0.95);
  color: #334155;
  padding: 0.28rem 0.52rem 0.28rem 0.62rem;
  box-shadow: none;
}

button.tag-token-remove:hover {
  transform: none;
  box-shadow: none;
}

.tag-token-derived {
  border-style: dashed;
}

.tag-editor input {
  flex: 1 1 10rem;
  width: auto;
  min-width: 7rem;
  min-height: 1.9rem;
  border: 0;
  border-radius: 0;
  background: transparent;
  padding: 0.25rem 0.34rem;
  box-shadow: none;
}

.tag-editor input:focus {
  border: 0;
  box-shadow: none;
}

.field-hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.35;
}

.field-error {
  margin: 0;
  color: var(--danger);
  font-size: 0.72rem;
  line-height: 1.35;
}

.recurrence-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.62rem;
  border: 1px solid rgba(10, 132, 255, 0.12);
  border-radius: 1rem;
  background: rgba(239, 246, 255, 0.56);
  padding: 0.78rem;
}

.weekday-picker,
.recurrence-preview,
.recurrence-advanced {
  grid-column: 1 / -1;
}

.weekday-picker {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 0.3rem;
}

.weekday-button {
  min-height: 2.3rem;
  padding: 0.35rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.82);
  color: var(--muted);
}

.weekday-button.active {
  border-color: transparent;
  background: var(--accent);
  color: white;
}

.recurrence-preview {
  margin: 0;
  color: #1e3a8a;
  font-size: 0.8rem;
  font-weight: 650;
}

.recurrence-advanced > summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.recurrence-advanced > label {
  margin-top: 0.5rem;
}

.recurrence-panel {
  margin-top: 0.84rem;
}

.recurrence-rule-list {
  gap: 0;
}

.recurrence-rule-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.75rem;
  padding: 0.86rem 0;
  border-top: 1px solid var(--line);
}

.recurrence-rule-heading,
.recurrence-section-head {
  align-items: center;
  justify-content: space-between;
}

.recurrence-rule-actions {
  align-items: center;
  justify-content: flex-end;
}

.recurrence-pause-menu .row-more-menu label {
  grid-column: 1 / -1;
}

@keyframes capture-overlay-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes capture-sheet-in {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.panel {
  display: none;
  gap: 0.84rem;
}

.panel.active {
  display: grid;
  animation: panel-in 180ms ease;
}

@keyframes panel-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.panel-flow {
  gap: 0.95rem;
}

.flow-hero {
  gap: 0.78rem;
}

.today-hero,
.capture-shell,
.review-hero {
  gap: 0.78rem;
}

.recent-session-correction {
  border-color: rgba(37, 99, 235, 0.2);
  background: rgba(239, 246, 255, 0.72);
}

.recent-session-correction .title {
  display: block;
  margin: 0.18rem 0 0.22rem;
}

.recent-session-correction .session-outcome-note {
  margin-top: 0.35rem;
  color: #334155;
}

.command-card {
  border-color: rgba(255, 255, 255, 0.9);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.95), rgba(250, 251, 255, 0.88)),
    rgba(255, 255, 255, 0.86);
}

.command-card h2 {
  margin: 0.18rem 0 0;
  font-size: clamp(1.45rem, 2vw, 1.86rem);
}

.metric-chip {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  background: rgba(245, 247, 250, 0.92);
  color: #4b5563;
  padding: 0.3rem 0.7rem;
  font-size: 0.76rem;
  font-weight: 700;
}

.hero-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.65rem;
}

.metric-panel {
  display: grid;
  gap: 0.2rem;
  padding: 0.88rem 0.92rem;
  border-radius: 1.15rem;
  border: 1px solid rgba(15, 23, 42, 0.06);
  background: rgba(248, 250, 252, 0.92);
}

.metric-label {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.05em;
}

.metric-value {
  color: var(--ink);
  font-size: 1.55rem;
  font-weight: 700;
  line-height: 1.1;
}

.two-col {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.82rem;
}

.command-grid {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 0.82rem;
}

.ops-grid {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 0.82rem;
}

.flow-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.82rem;
}

.flow-core {
  align-items: start;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.82rem;
}

.stage-card,
.kpi-card {
  display: grid;
  gap: 0.44rem;
}

.kpi-card {
  padding: 0.78rem;
}

.stage-kpi {
  margin: 0;
  color: var(--ink);
  font-family: "SF Pro Display", "Avenir Next", "PingFang SC", sans-serif;
  font-size: 1.18rem;
  font-weight: 700;
}

.stage-card > button {
  margin-top: 0.12rem;
}

.card {
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.9);
  border-radius: var(--radius-lg);
  box-shadow: 0 16px 36px rgba(15, 23, 42, 0.06);
  backdrop-filter: blur(20px);
  padding: 1rem;
  min-width: 0;
}

.activity-banner,
.focus-banner {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: var(--radius-lg);
  box-shadow: 0 14px 28px rgba(15, 23, 42, 0.05);
  padding: 0.86rem 1rem;
}

.activity-banner.warn {
  border-color: rgba(245, 158, 11, 0.3);
  background: rgba(255, 251, 235, 0.92);
}

.activity-banner.error {
  border-color: rgba(220, 38, 38, 0.25);
  background: rgba(254, 242, 242, 0.94);
}

.activity-banner.success {
  border-color: rgba(34, 197, 94, 0.25);
  background: rgba(240, 253, 244, 0.94);
}

.activity-text,
.summary-headline {
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.4;
  color: #0f172a;
  font-weight: 600;
}

.activity-dot {
  width: 0.56rem;
  height: 0.56rem;
  border-radius: 999px;
  background: currentColor;
  flex: none;
}

.activity-banner.warn,
.activity-banner.error,
.activity-banner.success {
  color: #0f172a;
}

.card h2,
.card h3 {
  margin: 0 0 0.62rem;
}

.section-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.8rem;
}

.section-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2rem;
  min-height: 2rem;
  padding: 0 0.7rem;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.05);
  color: #4b5563;
  font-size: 0.8rem;
  font-weight: 700;
}

.section-description {
  margin: -0.35rem 0 0.8rem;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.4;
}

.compact-head {
  justify-content: flex-end;
  margin-bottom: 0.72rem;
}

.notify-card h2,
.notify-card h3 {
  margin: 0;
  font-size: 1.04rem;
}

.summary-card {
  display: grid;
  gap: 0.68rem;
}

.today-stats {
  gap: 0.42rem;
}

.today-stat {
  background: rgba(247, 249, 252, 0.95);
}

.capture-head {
  align-items: start;
}

.capture-presets {
  gap: 0.42rem;
}

.capture-actions {
  align-items: center;
}

.capture-feedback {
  align-items: start;
}

.review-hero .kpi-grid {
  margin-top: 0.08rem;
}

.summary-chip {
  font-size: 0.78rem;
  font-weight: 700;
}

.summary-list {
  margin: 0;
  padding-left: 1rem;
  display: grid;
  gap: 0.42rem;
  color: #334155;
  font-size: 0.88rem;
  line-height: 1.45;
}

.summary-list li {
  padding-left: 0.08rem;
}

.form {
  display: grid;
  gap: 0.62rem;
}

label {
  display: grid;
  gap: 0.28rem;
  font-size: 0.86rem;
  color: var(--muted);
}

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

input,
textarea,
select {
  width: 100%;
  border-radius: 1rem;
  border: 1px solid rgba(15, 23, 42, 0.1);
  background: rgba(255, 255, 255, 0.9);
  color: var(--ink);
  min-height: 2.68rem;
  padding: 0.6rem 0.8rem;
  font-size: 0.96rem;
  line-height: 1.35;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--accent-2);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

textarea {
  min-height: 5rem;
  resize: vertical;
}

.capture-shell textarea {
  min-height: 8rem;
}

button {
  border: 1px solid transparent;
  border-radius: 999px;
  cursor: pointer;
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
  color: white;
  min-height: 2.52rem;
  padding: 0.56rem 0.94rem;
  font-weight: 700;
  font-size: 0.88rem;
  line-height: 1;
  touch-action: manipulation;
  box-shadow: 0 10px 24px rgba(37, 99, 235, 0.22);
  transition: transform 130ms ease, box-shadow 130ms ease, opacity 130ms ease;
}

button:hover {
  transform: translateY(-1px);
}

button:focus-visible {
  outline: 2px solid var(--accent-2);
  outline-offset: 2px;
}

button.ghost {
  border: 1px solid rgba(15, 23, 42, 0.08);
  background: rgba(255, 255, 255, 0.72);
  color: #1f2937;
  box-shadow: none;
}

.action-button {
  min-height: 2.2rem;
  padding: 0.46rem 0.82rem;
  font-size: 0.82rem;
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.54rem;
}

.item-row {
  position: relative;
  border: 1px solid rgba(15, 23, 42, 0.07);
  border-radius: var(--radius-md);
  background: rgba(248, 250, 252, 0.8);
  padding: 0.88rem 0.92rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.8rem;
}

.item-row.item-reorderable {
  display: grid;
  grid-template-columns: 2.2rem minmax(0, 1fr) auto;
  align-items: center;
}

.reorder-handle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.2rem;
  min-width: 2.2rem;
  min-height: 2.5rem;
  padding: 0;
  border: 0;
  border-radius: 0.72rem;
  background: transparent;
  color: #64748b;
  box-shadow: none;
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  font-size: 1.35rem;
  line-height: 1;
}

.reorder-handle:hover {
  color: #0a84ff;
  background: rgba(10, 132, 255, 0.08);
  transform: none;
}

.reorder-handle:focus-visible {
  outline: 2px solid #0a84ff;
  outline-offset: 2px;
}

.reorder-list.dragging,
.reorder-list.dragging .reorder-handle {
  cursor: grabbing;
}

.item-row.item-dragging {
  border-color: rgba(10, 132, 255, 0.45);
  background: rgba(239, 246, 255, 0.96);
  box-shadow: 0 12px 28px rgba(37, 99, 235, 0.16);
  opacity: 0.78;
}

.item-row.item-highlight {
  border-color: #0ea5e9;
  box-shadow: 0 0 0 2px rgba(14, 165, 233, 0.16);
}

.item-row .title {
  display: block;
  font-weight: 700;
  font-size: 1rem;
  line-height: 1.28;
}

.row-main {
  display: grid;
  flex: 1 1 auto;
  gap: 0.52rem;
  min-width: 0;
  max-width: 100%;
}

.action-note {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: start;
  gap: 0.48rem;
  min-width: 0;
  border-left: 3px solid rgba(37, 99, 235, 0.28);
  border-radius: 0.35rem 0.72rem 0.72rem 0.35rem;
  background: rgba(239, 246, 255, 0.72);
  padding: 0.5rem 0.62rem;
}

.action-note-label {
  color: #1d4ed8;
  font-size: 0.74rem;
  font-weight: 750;
  line-height: 1.5;
}

.action-note-text {
  min-width: 0;
  margin: 0;
  color: #334155;
  font-size: 0.84rem;
  line-height: 1.5;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.row-actions {
  align-items: center;
  justify-content: flex-end;
}

.item-chips {
  gap: 0.38rem;
  max-width: 100%;
}

.meta-chip {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  max-width: 100%;
  min-height: 1.7rem;
  padding: 0.28rem 0.62rem;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.05);
  border: 1px solid rgba(15, 23, 42, 0.06);
  color: #4b5563;
  font-size: 0.74rem;
  font-weight: 600;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.suggestion-chip {
  background: rgba(10, 132, 255, 0.08);
  border-color: rgba(10, 132, 255, 0.12);
  color: #0a84ff;
}

.meta {
  margin: 0.16rem 0 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.34;
  word-break: break-word;
}

.flow-hint {
  color: #0f3a78;
}

.empty-state {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 5.4rem;
  border-radius: 1.1rem;
  border: 1px dashed rgba(15, 23, 42, 0.1);
  background: rgba(248, 250, 252, 0.52);
  color: #6b7280;
  font-size: 0.92rem;
  font-weight: 600;
}

.suggestion-meta {
  color: #0c4a6e;
}

.delivery-status {
  border-radius: 999px;
  padding: 0.22rem 0.6rem;
  font-size: 0.74rem;
  font-weight: 700;
  border: 1px solid rgba(15, 23, 42, 0.08);
  color: #4b5563;
  background: rgba(248, 250, 252, 0.92);
}

.delivery-status.status-sent {
  border-color: #22c55e;
  color: var(--ok);
  background: #dcfce7;
}

.delivery-status.status-failed {
  border-color: #f59e0b;
  color: #92400e;
  background: #fef3c7;
}

.delivery-status.status-gone {
  border-color: #ef4444;
  color: #991b1b;
  background: #fee2e2;
}

.delivery-error {
  color: var(--danger);
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.primary-actions {
  align-items: flex-start;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.46rem;
}

button.chip {
  min-height: 2.3rem;
  padding: 0.42rem 0.72rem;
  font-size: 0.82rem;
  font-weight: 650;
}

.details-card > summary {
  display: flex;
  align-items: center;
  cursor: pointer;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 700;
}

.details-card[open] > summary {
  margin-bottom: 0.55rem;
}

.details-card > summary {
  list-style: none;
}

.details-card > summary::-webkit-details-marker {
  display: none;
}

.details-card > summary::after {
  content: "展开";
  margin-left: 0.45rem;
  color: var(--accent);
  font-weight: 600;
}

.details-card[open] > summary::after {
  content: "收起";
}

.details-card {
  background: rgba(255, 255, 255, 0.88);
}

.row-more {
  flex: 0 0 auto;
}

.row-more[open] {
  display: grid;
  flex: 1 0 100%;
  gap: 0.42rem;
  min-width: 0;
}

.row-more[open] > summary {
  justify-self: end;
}

.row-more > summary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.2rem;
  height: 2.2rem;
  box-sizing: border-box;
  list-style: none;
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  color: #64748b;
  cursor: pointer;
  transition: color 130ms ease, background 130ms ease, border-color 130ms ease;
}

.row-more > summary::-webkit-details-marker {
  display: none;
}

.row-more > summary:hover,
.row-more[open] > summary {
  border-color: rgba(10, 132, 255, 0.2);
  background: rgba(10, 132, 255, 0.08);
  color: var(--accent);
}

.row-more > summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.row-more > summary span {
  font-size: 1.2rem;
  font-weight: 800;
  line-height: 1;
}

.row-more-menu {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(7.5rem, 1fr));
  gap: 0.3rem;
  width: 100%;
  min-width: 0;
  padding: 0.42rem;
  border: 1px solid rgba(15, 23, 42, 0.09);
  border-radius: 0.9rem;
  background: rgba(241, 245, 249, 0.92);
}

.row-more-menu .action-button {
  display: flex;
  align-items: center;
  width: 100%;
  justify-content: flex-start;
  min-height: 2.25rem;
  box-shadow: none;
  text-align: left;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.56rem;
}

.inline-form {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.logs {
  margin-top: 0.38rem;
}

.log-line {
  border-left: 3px solid #93c5fd;
  padding-left: 0.5rem;
  font-size: 0.82rem;
}

.log-line.warn {
  border-color: #f59e0b;
}

.log-line.error {
  border-color: #dc2626;
}

.log-line.success {
  border-color: #16a34a;
}

.focus-banner {
  justify-content: space-between;
}

.section-highlight {
  border-color: rgba(14, 165, 233, 0.55);
  box-shadow: 0 0 0 2px rgba(14, 165, 233, 0.12);
}

.review-shortcuts {
  margin-top: 0.5rem;
}

.risk-link {
  min-height: 2rem;
  padding: 0.42rem 0.72rem;
  font-size: 0.82rem;
}

.quantified-review-hero,
.quantified-advice-card,
.session-form {
  display: grid;
  gap: 0.78rem;
}

.danger-action {
  color: var(--danger);
}

.completed-sequence .item-row {
  background: rgba(248, 250, 252, 0.66);
}

.quantified-kpis {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.review-day-strip {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 0.45rem;
}

.review-day-cell {
  display: grid;
  gap: 0.2rem;
  min-width: 0;
  padding: 0.68rem;
  border: 1px solid var(--line);
  border-radius: 0.9rem;
  background: rgba(248, 250, 252, 0.84);
}

.review-day-cell span {
  color: var(--accent-2);
  font-size: 1.12rem;
  font-weight: 800;
}

.review-day-cell small {
  color: var(--muted);
  line-height: 1.35;
}

.advice-row {
  align-items: center;
}

.breakdown-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
  padding-top: 0.78rem;
}

.breakdown-grid h4 {
  margin: 0 0 0.45rem;
}

.breakdown-row {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  margin: 0;
  padding: 0.42rem 0;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
}

.breakdown-row strong {
  color: var(--ink);
}

.time-ledger .session-form {
  padding-top: 0.8rem;
}

.session-ledger-list {
  margin-top: 0.75rem;
}

@media (max-width: 920px) {
  .command-grid,
  .ops-grid {
    grid-template-columns: 1fr;
  }

  .flow-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .hero-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .quantified-kpis {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .review-day-strip {
    overflow-x: auto;
    grid-template-columns: repeat(7, minmax(8.5rem, 1fr));
  }
}

@media (max-width: 840px) {
  .app-shell {
    width: calc(100% - 0.9rem);
    margin: max(0.62rem, env(safe-area-inset-top)) auto 0;
    padding-bottom: calc(5.15rem + env(safe-area-inset-bottom));
    gap: 0.7rem;
  }

  .bg-grid {
    display: none;
  }

  .topbar {
    align-items: center;
    gap: 0.7rem;
    padding: 0.1rem 0.18rem;
  }

  .topbar-copy {
    gap: 0;
  }

  .topbar h1 {
    font-size: 2rem;
    line-height: 1;
  }

  .topbar-status {
    width: auto;
    max-width: 72%;
    margin-left: auto;
    gap: 0.32rem;
  }

  .topbar-status .pill {
    padding: 0.34rem 0.62rem;
    font-size: 0.74rem;
  }

  .topbar-status button {
    min-height: 2.2rem;
    padding: 0.44rem 0.7rem;
    font-size: 0.8rem;
  }

  .two-col,
  .command-grid,
  .ops-grid,
  .flow-grid,
  .grid-2 {
    grid-template-columns: 1fr;
  }

  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .quantified-kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.55rem;
  }

  .quantified-kpis .kpi-card:last-child {
    grid-column: 1 / -1;
  }

  .breakdown-grid {
    grid-template-columns: 1fr;
  }

  .mobile-form-grid {
    grid-template-columns: 1fr;
  }

  .item-row {
    flex-direction: column;
    align-items: start;
    gap: 0.68rem;
  }

  .item-row.item-reorderable {
    display: grid;
    grid-template-columns: 2.2rem minmax(0, 1fr);
    align-items: start;
    column-gap: 0.62rem;
    row-gap: 0.68rem;
  }

  .item-row.item-reorderable > .row-actions {
    grid-column: 1 / -1;
  }

  .reorder-handle {
    width: 2.2rem;
    min-width: 2.2rem;
    min-height: 2.75rem;
    border: 1px solid rgba(15, 23, 42, 0.08);
    background: rgba(255, 255, 255, 0.72);
    font-size: 1.45rem;
  }

  .tabs {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 20;
    display: grid;
    width: auto;
    grid-template-columns: minmax(0, 1fr) 3.5rem minmax(0, 1fr);
    gap: 0.52rem;
    overflow: visible;
    border-top: 1px solid #b8c6d8;
    border-left: none;
    border-right: none;
    border-bottom: none;
    border-radius: 0;
    background: rgba(255, 255, 255, 0.94);
    backdrop-filter: blur(20px);
    box-shadow: 0 -8px 30px rgba(15, 23, 42, 0.08);
    padding: 0.42rem max(0.72rem, env(safe-area-inset-left))
      calc(0.5rem + env(safe-area-inset-bottom)) max(0.72rem, env(safe-area-inset-right));
  }

  .tab {
    width: 100%;
    min-width: 0;
    min-height: 2.75rem;
    padding-inline: 0.72rem;
  }

  .tab-capture {
    width: 3.5rem;
    min-width: 3.5rem;
    min-height: 3.5rem;
    border-radius: 50%;
    transform: translateY(-0.36rem);
  }

  .tab-capture:hover {
    transform: translateY(-0.42rem);
  }

  .capture-overlay {
    place-items: end center;
    padding: 0;
  }

  .capture-sheet {
    width: 100%;
    max-height: min(88dvh, 46rem);
    border-left: none;
    border-right: none;
    border-bottom: none;
    border-radius: 1.5rem 1.5rem 0 0;
    padding: 1rem 0.9rem calc(1rem + env(safe-area-inset-bottom));
    scroll-padding-bottom: calc(1rem + env(safe-area-inset-bottom));
    scrollbar-gutter: auto;
  }

  .capture-sheet-head h2 {
    font-size: 1.42rem;
  }

  .capture-title-field input {
    min-height: 3.35rem;
  }

  .capture-intents {
    gap: 0.38rem;
  }

  .capture-intent {
    font-size: 0.8rem;
  }

  .pill {
    min-height: 2.1rem;
  }

  .activity-banner,
  .focus-banner,
  .card {
    padding: 0.88rem;
  }

  .activity-banner,
  .focus-banner {
    border-radius: 1.05rem;
  }

  .activity-text,
  .summary-headline {
    font-size: 0.86rem;
  }

  .card {
    border-radius: 1.16rem;
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.055);
  }

  .chip-row {
    flex-wrap: nowrap;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    padding-bottom: 0.12rem;
    scroll-snap-type: inline proximity;
  }

  .chip-row::-webkit-scrollbar {
    display: none;
  }

  .item-chips .meta-chip {
    scroll-snap-align: start;
  }

  .item-chips {
    flex-wrap: wrap;
    overflow: visible;
    padding-bottom: 0;
    scroll-snap-type: none;
  }

  .today-stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.42rem;
    overflow: visible;
    padding-bottom: 0;
  }

  .today-stat {
    justify-content: center;
    min-width: 0;
    min-height: 2.3rem;
    padding: 0.38rem 0.48rem;
    line-height: 1.2;
    text-align: center;
    white-space: normal;
  }

  .kpi-card {
    padding: 0.72rem;
  }

  .kpi-card .meta {
    line-height: 1.25;
  }

  .inline-form {
    flex-direction: column;
  }

  .inline-form > button {
    width: 100%;
  }

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

  .compact-head {
    align-items: start;
  }

  .row-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .action-button,
  .row-more > summary {
    min-height: 2.7rem;
  }

  .row-more > summary {
    width: 2.7rem;
    height: 2.7rem;
  }

  .row-more-menu {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .recurrence-fields,
  .recurrence-rule-row {
    grid-template-columns: 1fr;
  }

  .recurrence-rule-actions {
    justify-content: flex-start;
  }

  .capture-actions > button {
    flex: 1 1 0;
  }

}

@media (max-width: 840px) and (hover: none) {
  button:hover {
    transform: none;
  }

  .tab-capture:hover {
    transform: translateY(-0.36rem);
  }
}

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