:root {
  --canvas: #f1eee8;
  --surface: #ffffff;
  --surface-2: #f8f6f1;
  --ink: #2b2723;
  --muted: #6f675c;
  --line: #e0dbd2;
  --line-strong: #b8b0a3;
  --brand: #c83f36;
  --brand-dark: #9f2f29;
  --brand-soft: #fbeae7;
  --gold: #b7791f;
  --gold-deep: #8a5a14;
  --gold-soft: #f9f0db;
  --warn: #c05621;
  --warn-deep: #8f3e12;
  --warn-soft: #fbeadf;
  --green: #2e7d57;
  --green-soft: #e2f1e8;
  --teal: #26717a;
  --teal-soft: #e2efef;
  --blue: #3b6ea5;
  --blue-deep: #2c567f;
  --blue-soft: #e8eff8;
  --error: #b3261e;
  --disabled-ink: #a39b8e;
  --disabled-surface: #ece8e1;
  --shadow: 0 10px 26px rgba(59, 52, 44, 0.08);
  /* Capacitor 8 injects --safe-area-inset-* on Android 15+; browsers fall back to env(). */
  --top-safe: var(--safe-area-inset-top, env(safe-area-inset-top, 0px));
  --bottom-safe: var(--safe-area-inset-bottom, env(safe-area-inset-bottom, 0px));
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-height: 100%;
  background: var(--canvas);
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  line-height: 1.5;
}

button,
input,
select,
textarea {
  font: inherit;
  letter-spacing: 0;
}

button,
select,
input[type="checkbox"],
.file-button {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(59, 110, 165, 0.3);
  outline-offset: 2px;
}

h1,
h2,
h3,
p,
blockquote {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 1.75rem;
  line-height: 1.05;
}

h2 {
  margin-bottom: 0;
  font-size: 1.15rem;
  line-height: 1.25;
}

h3 {
  margin-bottom: 0;
  font-size: 1rem;
}

.app-header {
  position: sticky;
  z-index: 20;
  top: 0;
  padding-top: var(--top-safe);
  border-bottom: 1px solid rgba(224, 219, 210, 0.9);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(14px);
}

.header-inner {
  width: min(1180px, calc(100% - 28px));
  min-height: 72px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand-lockup {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 11px;
}

.brand-mark {
  width: 46px;
  height: 46px;
  flex: 0 0 46px;
  border-radius: 8px;
}

.eyebrow,
.section-kicker {
  margin-bottom: 2px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: uppercase;
}

.header-actions,
.button-row,
.settings-actions,
.task-actions,
.meta-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.quick-capture-header {
  display: inline-grid;
  color: var(--brand);
}

.icon-btn,
.primary-btn,
.secondary-btn,
.text-btn,
.file-button {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font-weight: 600;
  text-decoration: none;
}

.icon-btn {
  width: 44px;
  min-height: 44px;
  padding: 0;
  border-color: var(--line);
  background: var(--surface);
  color: var(--ink);
}

.icon-btn.compact {
  width: 44px;
  min-height: 44px;
}

.icon-btn svg,
.primary-btn svg,
.secondary-btn svg,
.text-btn svg,
.file-button svg,
.settings-title svg,
.search-box svg {
  width: 18px;
  height: 18px;
  stroke-width: 2;
}

.primary-btn,
.secondary-btn,
.text-btn,
.file-button {
  padding: 0.62rem 0.85rem;
}

.primary-btn {
  border-color: var(--brand);
  background: var(--brand);
  color: #fff;
  font-weight: 700;
}

.primary-btn:hover {
  border-color: var(--brand-dark);
  background: var(--brand-dark);
}

.secondary-btn,
.file-button {
  border-color: var(--line);
  background: var(--surface);
  color: var(--ink);
}

.text-btn {
  min-height: 44px;
  padding-inline: 0.4rem;
  background: transparent;
  color: var(--muted);
}

.danger-text {
  color: var(--brand-dark);
}

.destructive-btn {
  border-color: var(--brand-dark);
  background: var(--brand-dark);
}

.account-danger-zone {
  border-bottom: 0;
}

.account-page {
  display: grid;
  place-items: center;
  padding: 24px;
}

.account-page-shell {
  width: min(560px, 100%);
  border: 1px solid var(--line);
  border-top: 5px solid var(--brand);
  border-radius: 8px;
  display: grid;
  gap: 16px;
  padding: 24px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.account-page-shell > * {
  margin: 0;
}

.account-page-shell .secondary-btn {
  text-decoration: none;
}

.settings-links,
.legal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.settings-links a {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 12px;
  color: var(--ink);
  text-decoration: none;
}

.settings-links svg {
  width: 17px;
  height: 17px;
}

.legal-page {
  align-items: start;
}

.legal-page-shell {
  width: min(760px, 100%);
  gap: 22px;
}

.legal-heading {
  display: flex;
  align-items: center;
  gap: 16px;
}

.legal-heading h1,
.legal-heading p {
  margin: 0;
}

.legal-page-shell section {
  border-top: 1px solid var(--line);
  padding-top: 18px;
}

.legal-page-shell h2 {
  margin: 0 0 8px;
  font-size: 1.16rem;
}

.legal-page-shell p,
.legal-page-shell li {
  line-height: 1.72;
}

.legal-page-shell ul,
.legal-page-shell ol {
  margin: 8px 0 0;
  padding-left: 1.4rem;
}

.legal-page-shell a:not(.primary-btn):not(.secondary-btn) {
  color: var(--blue);
}

.legal-actions a {
  flex: 1 1 150px;
  justify-content: center;
  text-decoration: none;
}

.support-note {
  border-left: 4px solid var(--gold);
  padding: 12px 14px;
  background: var(--gold-soft);
}

.support-note p {
  margin: 4px 0 0;
}

.local-merge-account {
  color: var(--muted);
}

.local-merge-preview {
  max-height: 180px;
  overflow: auto;
  margin: 0;
  padding: 12px 12px 12px 32px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
}

.feedback-report-list {
  display: grid;
  gap: 12px;
}

.feedback-report-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--surface);
}

.feedback-report-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.feedback-report-heading strong,
.feedback-report-card p {
  margin: 0;
}

.feedback-report-status {
  border-radius: 999px;
  padding: 4px 8px;
  background: var(--gold-soft);
  font-size: 0.78rem;
  white-space: nowrap;
}

.feedback-messages {
  display: grid;
  gap: 6px;
  margin-top: 10px;
}

.feedback-message {
  border-left: 3px solid var(--line);
  padding-left: 9px;
  color: var(--muted);
}

.feedback-message.is-admin {
  border-left-color: var(--brand);
  color: var(--ink);
}

.feedback-reply-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  margin-top: 12px;
}

.admin-feedback-shell { max-width: 980px; }

.admin-feedback-header,
.admin-feedback-filters,
.admin-feedback-actions,
.admin-feedback-attachments {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.admin-feedback-header h1 { margin: 0; }
.admin-feedback-header { margin-bottom: 18px; }
.admin-feedback-filters {
  display: grid;
  grid-template-columns: minmax(0, 180px) minmax(0, 180px) auto;
  align-items: end;
  justify-content: start;
  margin: 0 0 14px;
  padding: 0;
}
.admin-feedback-filters .icon-btn { width: 44px; min-height: 44px; font-size: 1.25rem; }
.admin-feedback-card { overflow-wrap: anywhere; }
.admin-feedback-description { white-space: pre-wrap; }
.admin-feedback-context { margin-top: 7px !important; color: var(--muted); font-size: 0.82rem; }

.admin-feedback-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 8px 14px;
  margin: 14px 0;
}

.admin-feedback-meta div { min-width: 0; }
.admin-feedback-meta dt { color: var(--muted); font-size: 0.78rem; }
.admin-feedback-meta dd { margin: 2px 0 0; }
.admin-feedback-actions { justify-content: flex-start; margin-top: 14px; }
.admin-feedback-attachments { justify-content: flex-start; margin: 12px 0; }

.admin-report-details,
.admin-report-process {
  margin-top: 12px;
  border-top: 1px solid var(--line);
  padding-top: 8px;
}

.admin-report-details summary,
.admin-report-process summary {
  min-height: 36px;
  display: flex;
  align-items: center;
  cursor: pointer;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 600;
}

.admin-report-process[open] summary { color: var(--ink); }

@media (max-width: 680px) {
  .admin-feedback-header { align-items: flex-start; }
  .admin-feedback-header .connection-account { margin-top: 3px; }
  .admin-feedback-filters { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 44px; gap: 8px; }
  .admin-feedback-filters label { min-width: 0; }
  .admin-feedback-filters select { min-width: 0; }
  .admin-feedback-card { padding: 12px; }
  .admin-feedback-meta { grid-template-columns: 1fr; margin: 8px 0 0; }
}

.full {
  width: 100%;
}

button:disabled,
.is-disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.shell {
  width: min(1180px, calc(100% - 28px));
  margin: 0 auto;
  padding: 18px 0 52px;
}

.public-site-links {
  width: min(1180px, calc(100% - 28px));
  margin: 0 auto;
  padding: 0 0 32px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
  color: var(--muted);
  font-size: 0.82rem;
}

.public-site-links a {
  color: var(--ink-soft);
  text-underline-offset: 3px;
}

.public-site-links a:focus-visible {
  outline: 3px solid var(--brand-soft);
  outline-offset: 3px;
}

.status-strip {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.72);
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--muted);
}

.status-strip.online .status-dot {
  background: var(--green);
}

.status-strip.error .status-dot {
  background: var(--error);
}

.status-strip.syncing .status-dot {
  background: var(--gold);
  box-shadow: 0 0 0 5px var(--gold-soft);
}

.status-copy {
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.status-copy span {
  min-width: 0;
  color: var(--muted);
  font-size: 0.87rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#loginButton {
  max-width: min(240px, 50vw);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.metrics {
  margin-top: 10px;
  border: 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  background: transparent;
}

.metric {
  min-height: 60px;
  border: 1px solid transparent;
  border-radius: 8px;
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: var(--surface);
  color: var(--ink);
  text-align: left;
}

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

.metric span {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 500;
}

.metric strong {
  font-size: 1.35rem;
  line-height: 1;
}

.metric-label-compact {
  display: none;
}

.metric.is-hot.danger {
  background: var(--warn-soft);
  color: var(--warn-deep);
}

.metric.is-hot.waiting {
  background: var(--blue-soft);
  color: var(--blue-deep);
}

.metric[aria-pressed="true"] {
  outline: 2px solid var(--gold);
  outline-offset: 1px;
}

.metric.danger[aria-pressed="true"] {
  outline-color: var(--warn);
}

.metric.waiting[aria-pressed="true"] {
  outline-color: var(--blue);
}

.metric.month[aria-pressed="true"] {
  outline-color: var(--line-strong);
}

.capture-band {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-top: 4px solid var(--brand);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 5px 16px rgba(59, 52, 44, 0.06);
}

.capture-band,
.today-panel,
.list-panel,
#activeFocusPanel {
  scroll-margin-top: 86px;
}

.capture-band form {
  padding: 16px;
}

.capture-heading,
.panel-heading,
.dialog-heading,
.settings-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.capture-heading {
  margin-bottom: 10px;
}

.capture-tools {
  display: flex;
  align-items: center;
  gap: 8px;
}

.calendar-capture-toggle {
  display: none;
}

#voiceCaptureButton.is-listening {
  border-color: var(--brand);
  background: var(--brand-soft);
  color: var(--brand-dark);
  box-shadow: 0 0 0 4px rgba(207, 61, 51, 0.12);
}

textarea,
input,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 0.68rem 0.75rem;
}

textarea {
  min-height: 118px;
  resize: vertical;
}

#dumpInput {
  min-height: 80px;
  border-color: var(--line-strong);
  background: #fff;
  font-size: 1rem;
}

.capture-main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 112px;
  gap: 10px;
  align-items: stretch;
}

.capture-main .primary-btn {
  min-height: 80px;
}

.capture-intelligence {
  min-height: 32px;
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 500;
}

.capture-intelligence svg {
  width: 16px;
  height: 16px;
  color: var(--muted);
}

.capture-intelligence.is-working {
  color: var(--teal);
}

.capture-intelligence.is-fallback {
  color: var(--gold-deep);
}

.ai-preview-form {
  width: min(780px, calc(100vw - 28px));
}

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

.ai-suggestion {
  border: 1px solid var(--line);
  border-left: 4px solid var(--brand);
  border-radius: 8px;
  padding: 12px;
  background: var(--surface-2);
}

.ai-suggestion-heading {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) 38px;
  align-items: center;
  gap: 8px;
}

.ai-suggestion-number {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--brand-soft);
  color: var(--brand-dark);
  font-size: 0.78rem;
  font-weight: 600;
}

.ai-suggestion-title {
  min-width: 0;
  font-weight: 600;
}

.ai-suggestion-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 0.8fr) minmax(0, 1fr) minmax(0, 1fr);
  gap: 8px;
  margin-top: 9px;
}

.ai-suggestion-grid label {
  min-width: 0;
}

.ai-suggestion-grid label > span {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 500;
}

.ai-notes-field {
  grid-column: 1 / -1;
}

.ai-suggestion-reason {
  margin: 8px 0 0 36px;
  color: var(--muted);
  font-size: 0.8rem;
}

.capture-settings {
  margin-top: 8px;
  border-top: 1px solid var(--line);
}

.capture-settings summary {
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.84rem;
  font-weight: 600;
  list-style: none;
}

.capture-settings summary::-webkit-details-marker {
  display: none;
}

.capture-settings summary svg {
  width: 17px;
  height: 17px;
  flex: 0 0 auto;
}

.capture-settings summary small {
  margin-left: auto;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 500;
}

.capture-settings-panel {
  margin-bottom: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
}

.capture-setting-group + .capture-setting-group {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.capture-setting-group h3 {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.78rem;
}

.capture-schedule-controls {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.capture-schedule-controls input,
.capture-schedule-controls select {
  min-width: 0;
}

.capture-schedule-hint {
  margin: 8px 0 0;
}

/* 讓「知道了」跟著句子自然接在後面，換行時才不會浮在右上角。 */
.view-hint {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.7;
}

.view-hint .text-btn {
  display: inline;
  margin-left: 8px;
  font-size: 0.82rem;
  white-space: nowrap;
}

.empty-hint {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.65;
}

/* 更新提示：一行安靜的字，不是彈窗，也不擋住任何操作。 */
.update-notice {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px 10px;
  margin: 0 0 10px;
  padding: 9px 12px;
  border: 1px solid color-mix(in srgb, var(--gold) 40%, var(--line));
  border-radius: 10px;
  background: color-mix(in srgb, var(--gold) 8%, var(--surface));
  color: var(--ink);
  font-size: 0.84rem;
  line-height: 1.6;
}

.update-notice .text-btn {
  flex-shrink: 0;
  font-size: 0.84rem;
}

.about-line {
  margin: 0;
  font-size: 0.92rem;
  font-weight: 700;
}

.about-copy {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.7;
}

.about-version {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.about-version strong {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.about-version .text-btn {
  margin-left: auto;
  font-size: 0.82rem;
}

.about-version .text-btn:disabled {
  opacity: 0.5;
  cursor: progress;
}

/* summary 已改為 .settings-title（內含 h3），收合樣式統一由 .settings-collapse 提供。 */

.how-to-use dl {
  margin: 6px 0 0;
}

.how-to-use dt {
  margin-top: 10px;
  font-size: 0.86rem;
  font-weight: 700;
}

.how-to-use dd {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.65;
}

.how-to-use > p {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.65;
}

.select-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 12px;
  margin-top: 10px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-2);
}

.select-bar #selectCount {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 600;
}

.select-bar-actions {
  display: flex;
  gap: 8px;
  margin-left: auto;
  flex-wrap: wrap;
}

.select-bar-actions button {
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
}

.select-bar-actions button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.select-bar-actions .select-delete:not(:disabled) {
  border-color: color-mix(in srgb, var(--warn) 45%, var(--line));
  color: var(--warn);
}

.select-check {
  display: inline-flex;
  align-items: center;
  padding: 2px 0 0 2px;
  cursor: pointer;
}

.select-check input {
  width: 22px;
  height: 22px;
  accent-color: var(--brand);
  cursor: pointer;
}

/* 選取模式多一欄放勾選框，欄位樣板要跟著補，否則卡片內容會被擠掉。 */
.task-card.is-selectable {
  grid-template-columns: 4px auto minmax(0, 1fr);
  align-items: start;
}

.task-card.is-selectable .select-check {
  padding: 12px 0 0 10px;
}

.journal-item.is-selectable {
  grid-template-columns: auto minmax(0, 1fr) auto auto;
}

.task-card.is-selected,
.journal-item.is-selected {
  border-color: color-mix(in srgb, var(--brand) 40%, var(--line));
  background: color-mix(in srgb, var(--brand) 4%, var(--surface));
}

.toast-undo {
  margin-left: 12px;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  font-weight: 700;
  text-decoration: underline;
  cursor: pointer;
}

.capture-rules summary {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.8rem;
  list-style: none;
}

.capture-rules summary::-webkit-details-marker {
  display: none;
}

.capture-rules summary svg {
  width: 15px;
  height: 15px;
  opacity: 0.85;
}

.capture-rules ul {
  margin: 4px 0 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.65;
}

.capture-controls {
  margin-top: 10px;
  display: grid;
  grid-template-columns: repeat(3, minmax(130px, 1fr));
  gap: 8px;
  align-items: end;
}

label {
  min-width: 0;
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 500;
}

.work-layout {
  margin-top: 14px;
  display: grid;
  grid-template-columns: minmax(280px, 340px) minmax(0, 1fr);
  grid-template-areas:
    "today list"
    "capture list";
  gap: 14px;
  align-items: start;
}

.work-layout > .capture-band {
  grid-area: capture;
  margin-top: 0;
}

.today-panel {
  grid-area: today;
}

.list-panel {
  grid-area: list;
}

.work-layout.journal-view {
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas:
    "capture"
    "list";
}

.work-layout.journal-view .today-panel {
  display: none;
}

body.active-focus-view .metrics,
body.active-focus-view .capture-band,
body.active-focus-view .list-panel {
  display: none;
}

body.active-focus-view .work-layout {
  grid-template-columns: minmax(0, 720px);
  grid-template-areas: "today";
  justify-content: center;
}

body.active-focus-view .today-panel {
  position: static;
  top: auto;
}

body.active-focus-view .active-focus {
  overflow: visible;
}

@media (min-width: 901px) {
  .work-layout:not(.journal-view) > .capture-band .capture-main {
    grid-template-columns: 1fr;
  }

  .work-layout:not(.journal-view) > .capture-band .primary-btn {
    width: 100%;
    min-height: 48px;
  }
}

.today-panel,
.list-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.today-panel {
  border-top: 4px solid var(--gold);
  padding: 16px;
  box-shadow: var(--shadow);
}

.list-panel {
  border-top: 4px solid var(--line-strong);
}

#todayPanelKicker {
  color: var(--gold-deep);
}

body[data-view="focus"] .today-panel {
  border-top-color: var(--teal);
}

body[data-view="focus"] #todayPanelKicker {
  color: var(--teal);
}

body[data-view="focus"] .companion-note {
  border-left-color: var(--teal);
}

body[data-view="today"] .list-panel {
  border-top-color: var(--gold);
}

body[data-view="focus"] .list-panel {
  border-top-color: var(--teal);
}

body[data-view="waiting"] .list-panel {
  border-top-color: var(--blue);
}

body[data-view="done"] .list-panel {
  border-top-color: var(--green);
}

body[data-view="overdue"] .list-panel {
  border-top-color: var(--warn);
}

body[data-view="today"] #listKicker {
  color: var(--gold-deep);
}

body[data-view="focus"] #listKicker {
  color: var(--teal);
}

body[data-view="waiting"] #listKicker {
  color: var(--blue-deep);
}

body[data-view="done"] #listKicker {
  color: var(--green);
}

body[data-view="overdue"] #listKicker {
  color: var(--warn-deep);
}

.panel-heading {
  margin-bottom: 12px;
}

.panel-heading.small {
  margin-bottom: 8px;
}

.companion-note {
  margin: -2px 0 12px;
  border-left: 3px solid var(--gold);
  padding: 3px 2px 3px 10px;
  color: var(--muted);
}

.focus-task {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px;
  background: var(--surface-2);
}

.focus-task.urgent {
  border-color: var(--warn);
  background: var(--warn-soft);
}

.focus-task:has(.focus-empty) {
  border: 0;
  padding: 8px 2px 2px;
  background: transparent;
}

.focus-task-copy strong,
.focus-task-copy span {
  display: block;
  overflow-wrap: anywhere;
}

.focus-task-copy strong {
  font-size: 1.05rem;
  line-height: 1.4;
}

.focus-task-copy span {
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 500;
}

.focus-task-actions {
  margin-top: 13px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 42px;
  gap: 7px;
}

.focus-task-actions .primary-btn,
.focus-task-actions .secondary-btn {
  padding-inline: 0.55rem;
}

.focus-task-actions .complete-focus,
.active-focus-actions .complete-focus {
  border-color: var(--green);
  background: var(--green);
}

.active-focus-actions .complete-focus:hover {
  border-color: #256a49;
  background: #256a49;
}

body.active-focus-view .companion-note,
body.active-focus-view .count-badge {
  display: none;
}

.focus-empty {
  display: grid;
  justify-items: start;
  gap: 4px;
  color: var(--muted);
}

.focus-empty svg {
  width: 24px;
  height: 24px;
  color: var(--green);
}

.focus-empty strong {
  color: var(--ink);
}

.focus-empty span {
  font-size: 0.82rem;
}

.next-up {
  margin-top: 17px;
}

.next-up > .section-kicker {
  margin-bottom: 7px;
}

.companion-note p {
  margin: 0;
  font-size: 0.83rem;
  font-weight: 500;
  line-height: 1.45;
}

.focus-plan-launch {
  width: 100%;
  min-height: 56px;
  margin-bottom: 10px;
  border: 1px solid var(--teal);
  border-radius: 8px;
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) 18px;
  align-items: center;
  gap: 9px;
  padding: 9px 11px;
  background: var(--teal-soft);
  color: var(--ink);
  text-align: left;
}

.focus-plan-launch > svg:first-child {
  color: var(--teal);
}

.focus-plan-launch > svg:last-child {
  color: var(--muted);
}

.focus-plan-launch span,
.focus-plan-launch strong,
.focus-plan-launch small {
  min-width: 0;
  display: block;
}

.focus-plan-launch strong {
  font-size: 0.92rem;
}

.focus-plan-launch small {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 500;
}

.active-focus {
  margin-bottom: 10px;
  border: 2px solid var(--teal);
  border-radius: 8px;
  overflow: visible;
  background: #fff;
}

.active-focus-head {
  border-radius: 6px 6px 0 0;
}

.active-focus-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 11px;
  background: var(--teal-soft);
}

.active-focus-head span {
  color: var(--teal);
  font-size: 0.78rem;
  font-weight: 650;
}

.active-focus-progress {
  height: 5px;
  background: var(--line);
}

.active-focus-progress span {
  height: 100%;
  display: block;
  background: var(--teal);
  transition: width 0.2s ease;
}

.active-focus-body {
  padding: 13px;
}

.focus-clock {
  margin-bottom: 4px;
  color: var(--teal);
  font-size: 2rem;
  font-weight: 800;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.active-focus-body h3 {
  overflow-wrap: anywhere;
}

.active-focus-body p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.active-focus-actions {
  margin-top: 12px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 7px;
}

.active-focus-actions .primary-btn,
.active-focus-actions .secondary-btn {
  padding-inline: 0.55rem;
}

.active-focus-subactions {
  margin-top: 7px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.active-focus-subactions > .text-btn,
.focus-more-actions summary {
  min-width: 0;
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 6px;
  font-size: 0.78rem;
  font-weight: 600;
  text-align: center;
}

.active-focus-subactions svg,
.focus-more-actions svg {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
}

.focus-more-actions {
  min-width: 0;
  position: relative;
}

.focus-more-actions summary {
  border-radius: 6px;
  color: var(--muted);
  cursor: pointer;
  list-style: none;
}

.focus-more-actions summary::-webkit-details-marker {
  display: none;
}

.focus-more-actions[open] {
  z-index: 4;
}

.focus-more-actions[open] > summary {
  background: var(--surface-2);
}

.focus-more-actions > div {
  position: absolute;
  z-index: 5;
  right: 0;
  top: calc(100% + 5px);
  width: 220px;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  padding: 7px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.focus-more-actions > div .text-btn {
  min-height: 38px;
}

.focus-assist-btn {
  width: 100%;
  min-height: 42px;
  margin-top: 8px;
  border: 1px solid var(--gold);
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  background: var(--gold-soft);
  color: var(--gold-deep);
  font-weight: 650;
}

.focus-assist-btn svg {
  width: 18px;
  height: 18px;
}

.focus-help-choices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.focus-candidate-choices {
  max-height: 230px;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  overflow: auto;
  background: #fff;
}

.focus-candidate-choices[hidden] {
  display: none;
}

.focus-candidate-choices label {
  grid-template-columns: 20px minmax(0, 1fr);
  align-items: start;
  gap: 8px;
  padding: 9px 10px;
  color: var(--ink);
}

.focus-candidate-choices label + label {
  border-top: 1px solid var(--line);
}

.focus-candidate-choices input {
  margin-top: 2px;
}

.focus-candidate-choices strong,
.focus-candidate-choices small {
  display: block;
  overflow-wrap: anywhere;
}

.focus-candidate-choices small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.73rem;
}

.focus-help-choices button {
  min-height: 78px;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  align-items: center;
  gap: 9px;
  padding: 11px;
  background: #fff;
  color: var(--ink);
  text-align: left;
}

.focus-help-choices button:hover {
  border-color: var(--teal);
  background: var(--teal-soft);
}

.focus-help-choices svg {
  color: var(--teal);
}

.focus-help-choices strong,
.focus-help-choices small {
  display: block;
}

.focus-help-choices small {
  margin-top: 2px;
  color: var(--muted);
}

.focus-help-result > p {
  border-left: 4px solid var(--gold);
  padding: 8px 10px;
  background: var(--gold-soft);
  font-weight: 500;
}

.focus-help-result ol {
  margin: 14px 0;
  padding-left: 1.5rem;
}

.focus-help-result li {
  margin-block: 8px;
  padding-left: 4px;
  font-weight: 500;
}

.active-focus-done {
  padding: 16px;
  color: var(--green);
}

.active-focus-done strong,
.active-focus-done span {
  display: block;
}

.active-focus-done span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.8rem;
}

.focus-planner-form {
  width: min(720px, calc(100vw - 28px));
}

.choice-fieldset {
  margin: 0 0 18px;
  border: 0;
  padding: 0;
}

.choice-fieldset legend {
  margin-bottom: 9px;
  color: var(--ink);
  font-weight: 650;
}

.segmented-options {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}

.segmented-options.energy-options {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.segmented-options label {
  position: relative;
}

.segmented-options input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segmented-options span {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  place-items: center;
  padding: 6px;
  background: #fff;
  color: var(--ink);
  font-weight: 600;
}

.segmented-options input:checked + span {
  border-color: var(--teal);
  background: var(--teal-soft);
  color: var(--teal);
  box-shadow: inset 0 0 0 1px var(--teal);
}

.segmented-options input:focus-visible + span {
  outline: 3px solid rgba(59, 110, 165, 0.3);
  outline-offset: 2px;
}

.custom-duration {
  margin-top: 9px;
  grid-template-columns: minmax(0, 1fr) 130px;
  align-items: center;
}

.focus-plan-note,
.focus-plan-summary {
  border-left: 4px solid var(--teal);
  display: block;
  padding: 9px 12px;
  background: var(--teal-soft);
  color: var(--ink);
  font-size: 0.83rem;
  font-weight: 500;
}

.focus-plan-summary p {
  margin: 0;
}

.focus-plan-blocks {
  margin: 14px 0 0;
  padding: 0;
  display: grid;
  gap: 8px;
  list-style: none;
  counter-reset: focus-block;
}

.focus-plan-blocks li {
  min-height: 58px;
  border-bottom: 1px solid var(--line);
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  padding: 8px 3px;
  counter-increment: focus-block;
}

.focus-plan-blocks li::before {
  content: counter(focus-block);
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--teal-soft);
  color: var(--teal);
  font-size: 0.78rem;
  font-weight: 650;
}

.focus-plan-blocks li.is-break::before {
  content: "休";
  border-radius: 8px;
  background: var(--green-soft);
  color: var(--green);
}

.focus-plan-block-copy strong,
.focus-plan-block-copy small {
  display: block;
  overflow-wrap: anywhere;
}

.focus-plan-block-copy small {
  margin-top: 2px;
  color: var(--muted);
}

.focus-plan-minutes {
  color: var(--teal);
  font-weight: 650;
  white-space: nowrap;
}

.count-badge,
.connection-pill {
  min-width: 28px;
  min-height: 28px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.2rem 0.55rem;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 650;
}

.connection-pill.connected {
  background: var(--green-soft);
  color: var(--green);
}

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

.focus-next-task {
  border-left: 3px solid var(--line-strong);
  border-radius: 0 6px 6px 0;
  padding: 0;
  background: var(--surface-2);
  font-weight: 600;
  overflow-wrap: anywhere;
}

.focus-next-task-toggle {
  position: relative;
  width: 100%;
  min-height: 54px;
  border: 0;
  padding: 9px 36px 9px 10px;
  background: transparent;
  color: var(--ink);
  text-align: left;
}

.focus-next-task-toggle > span {
  display: block;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.focus-next-task-toggle > svg {
  position: absolute;
  top: 50%;
  right: 10px;
  width: 17px;
  height: 17px;
  transform: translateY(-50%);
  color: var(--muted);
}

.focus-next-task.urgent {
  border-left-color: var(--warn);
}

.focus-next-task small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 500;
}

.focus-next-task-actions {
  display: none;
  border-top: 1px solid var(--line);
  padding: 9px 10px 10px;
}

.focus-next-task.expanded .focus-next-task-actions {
  display: block;
}

.focus-next-task-actions p {
  margin: 0 0 7px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 500;
}

.focus-next-task-actions > div {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.focus-next-task-actions button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0.35rem 0.55rem;
  background: rgba(255, 255, 255, 0.82);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
}

.focus-next-task-actions button.complete {
  border-color: var(--green);
  background: var(--green);
  color: #fff;
}

.focus-next-task-actions button.icon-action {
  width: 40px;
  padding: 0;
}

.message-output,
.tone-preview {
  margin-bottom: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 11px;
  background: var(--surface-2);
  color: var(--ink);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.message-task-context {
  margin-bottom: 10px;
  border-left: 4px solid var(--blue);
  padding: 9px 11px;
  background: var(--blue-soft);
}

.message-task-context span,
.message-task-context strong {
  display: block;
}

.message-task-context span {
  margin-bottom: 2px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 500;
}

.message-task-context strong {
  overflow-wrap: anywhere;
}

.list-toolbar {
  min-height: 98px;
  border-bottom: 1px solid var(--line);
  display: grid;
  grid-template-columns: minmax(0, 1fr) 190px;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
}

.list-toolbar-title h2 {
  margin: 0;
}

.list-toolbar-title {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.task-display-switch {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: inline-grid;
  grid-template-columns: repeat(3, 44px);
  padding: 2px;
  background: var(--surface-2);
}

.task-display-switch button {
  width: 44px;
  min-height: 44px;
  border: 0;
  border-radius: 6px;
  display: grid;
  place-items: center;
  background: transparent;
  color: var(--muted);
}

.task-display-switch button[aria-pressed="true"] {
  background: var(--surface);
  color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--line-strong);
}

.task-display-switch svg {
  width: 18px;
  height: 18px;
}

.view-tabs {
  grid-column: 1 / -1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
}

.view-tabs::-webkit-scrollbar {
  display: none;
}

.tab {
  flex: 0 0 auto;
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 0.42rem 0.7rem;
  background: transparent;
  color: var(--muted);
  font-weight: 600;
}

.tab[aria-pressed="true"] {
  border-color: var(--line-strong);
  background: var(--surface);
  color: var(--ink);
}

body[data-view="today"] .tab[aria-pressed="true"] {
  border-color: var(--gold);
  background: var(--gold-soft);
  color: var(--gold-deep);
}

body[data-view="focus"] .tab[aria-pressed="true"] {
  border-color: var(--teal);
  background: var(--teal-soft);
  color: var(--teal);
}

body[data-view="waiting"] .tab[aria-pressed="true"] {
  border-color: var(--blue);
  background: var(--blue-soft);
  color: var(--blue-deep);
}

body[data-view="done"] .tab[aria-pressed="true"] {
  border-color: var(--green);
  background: var(--green-soft);
  color: var(--green);
}

.search-box {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding-left: 9px;
  background: var(--surface-2);
}

.search-box input {
  min-width: 0;
  border: 0;
  background: transparent;
  padding-left: 0;
}

.task-list {
  display: grid;
  gap: 9px;
  padding: 12px;
}

.task-list.journal-list {
  gap: 14px;
}

/* 四象限的重點是「四塊一起看」。原本切過去時，摘要卡與整段記事區還留在上面，
   桌機 1280 要先捲過 882px 才看得到第一塊，等於永遠看不到全貌——四象限就退化成
   四個疊在一起的清單。比照月曆的既有做法收起上方；記事仍可用展開鈕叫回來。 */
body.matrix-task-view .metrics {
  display: none;
}

body.matrix-task-view .calendar-capture-toggle {
  display: grid;
}

body.matrix-task-view:not(.calendar-capture-expanded) .capture-band {
  box-shadow: none;
}

body.matrix-task-view:not(.calendar-capture-expanded) .capture-band form {
  padding: 8px 12px;
}

body.matrix-task-view:not(.calendar-capture-expanded) .capture-heading {
  margin: 0;
}

body.matrix-task-view:not(.calendar-capture-expanded) .capture-heading .section-kicker,
body.matrix-task-view:not(.calendar-capture-expanded) .capture-main,
body.matrix-task-view:not(.calendar-capture-expanded) .capture-intelligence,
body.matrix-task-view:not(.calendar-capture-expanded) .capture-rules,
body.matrix-task-view:not(.calendar-capture-expanded) .capture-settings,
body.matrix-task-view:not(.calendar-capture-expanded) #voiceCaptureButton,
body.matrix-task-view:not(.calendar-capture-expanded) #clearInputButton {
  display: none;
}

body.matrix-task-view:not(.calendar-capture-expanded) .capture-heading h2 {
  font-size: 0.94rem;
}

.task-list.matrix-list {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.matrix-undo {
  grid-column: 1 / -1;
  min-height: 44px;
  border: 1px solid var(--green);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 12px;
  background: var(--green-soft);
  color: var(--green);
  font-size: 0.84rem;
}

.matrix-undo .text-btn {
  color: inherit;
}

.task-list.calendar-list {
  gap: 14px;
}

.calendar-toolbar {
  min-height: 42px;
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
}

.calendar-toolbar > strong {
  font-size: 1.05rem;
  text-align: center;
}

.calendar-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.calendar-today {
  min-height: 36px;
  padding-block: 0.35rem;
}

.calendar-grid {
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  overflow: hidden;
  background: var(--surface);
}

.calendar-weekday {
  min-width: 0;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 7px 4px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 600;
  text-align: center;
}

.calendar-day {
  min-width: 0;
  min-height: 112px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 5px;
  background: var(--surface);
}

.calendar-day.outside-month {
  background: var(--surface-2);
}

.calendar-day-number {
  width: 25px;
  height: 25px;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
}

.calendar-day.is-today .calendar-day-number {
  border-radius: 50%;
  background: var(--gold);
  color: #fff;
}

.calendar-day-tasks {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.calendar-task {
  min-width: 0;
  min-height: 27px;
  border: 0;
  border-left: 3px solid var(--line-strong);
  border-radius: 4px;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 5px;
  overflow: hidden;
  background: var(--surface-2);
  color: var(--ink);
  text-align: left;
}

.calendar-task span {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 0.65rem;
}

.calendar-task .calendar-repeat {
  color: var(--green);
  font-size: 0.72rem;
  font-weight: 800;
}

.edit-more-settings {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--paper-soft);
}

.edit-more-settings > summary {
  display: grid;
  gap: 4px;
  padding: 14px 16px;
  cursor: pointer;
  list-style: none;
}

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

.edit-more-settings > summary > span {
  display: flex;
  align-items: center;
  gap: 8px;
}

.edit-more-settings > summary > small {
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.edit-more-grid {
  padding: 0 14px 14px;
}

.calendar-task strong {
  min-width: 0;
  overflow: hidden;
  font-size: 0.72rem;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.calendar-task.status-doing {
  border-left-color: var(--gold);
  background: var(--gold-soft);
}

.calendar-task.status-waiting {
  border-left-color: var(--blue);
  background: var(--blue-soft);
}

.calendar-task.is-overdue {
  border-left-color: var(--warn);
  background: var(--warn-soft);
}

.calendar-undated {
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.calendar-undated > header {
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.calendar-undated > header h3,
.calendar-undated > header p {
  margin: 0;
}

.calendar-undated > header > strong {
  color: var(--muted);
}

.calendar-undated > div {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.calendar-undated-task {
  min-width: 0;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 9px;
  background: var(--surface-2);
  color: var(--ink);
  text-align: left;
}

.calendar-undated-task span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.calendar-undated-task svg {
  width: 15px;
  height: 15px;
  flex: 0 0 auto;
  color: var(--muted);
}

.matrix-quadrant {
  min-width: 0;
  border: 1px solid var(--line);
  border-top: 4px solid var(--line-strong);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface);
  transition: border-color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
}

.matrix-quadrant.is-drop-target {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(43, 122, 82, 0.16);
  transform: translateY(-2px);
}

.matrix-quadrant > header {
  min-height: 64px;
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  padding: 10px 12px;
  background: var(--surface-2);
}

.matrix-quadrant > header svg {
  width: 20px;
  height: 20px;
}

.matrix-quadrant > header h3,
.matrix-quadrant > header span {
  display: block;
}

.matrix-quadrant > header span {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 500;
}

.matrix-quadrant > header > strong {
  min-width: 27px;
  min-height: 27px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  font-size: 0.78rem;
}

.matrix-do {
  border-top-color: var(--warn);
}

.matrix-do > header {
  background: var(--warn-soft);
  color: var(--warn-deep);
}

.matrix-items {
  display: grid;
}

.matrix-task {
  min-width: 0;
  min-height: 62px;
  border-bottom: 1px solid var(--line);
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 9px 10px;
  background: var(--surface);
  transition: opacity 0.16s ease, transform 0.16s ease;
}

.matrix-task.is-dragging {
  opacity: 0.48;
  transform: scale(0.985);
}

.matrix-drag-handle {
  width: 30px;
  height: 38px;
  border: 0;
  border-radius: 7px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  background: transparent;
  color: var(--muted);
  cursor: grab;
  touch-action: none;
}

.matrix-drag-handle:active {
  cursor: grabbing;
  background: var(--surface-2);
}

.matrix-drag-handle svg {
  width: 18px;
  height: 18px;
}

.matrix-task:last-child {
  border-bottom: 0;
}

.matrix-task strong,
.matrix-task span {
  display: block;
  overflow-wrap: anywhere;
}

.matrix-task span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.76rem;
}

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

.matrix-empty {
  margin: 0;
  padding: 18px 12px;
  color: var(--muted);
  font-size: 0.82rem;
  text-align: center;
}

.journal-month {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface);
}

.journal-month-heading {
  min-height: 52px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  background: var(--surface-2);
}

.journal-month-heading h3 {
  margin: 0;
  font-size: 1rem;
}

.journal-month-heading span {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 600;
}

.journal-days {
  display: grid;
}

.journal-day {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  border-bottom: 1px solid var(--line);
}

.journal-day:last-child {
  border-bottom: 0;
}

.journal-day > time {
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 8px;
  color: var(--muted);
}

.journal-day > time strong {
  color: var(--ink);
  font-size: 1.4rem;
  line-height: 1;
}

.journal-day > time span {
  margin-top: 4px;
  font-size: 0.72rem;
  font-weight: 500;
}

.journal-day-items {
  display: grid;
}

.journal-item {
  min-width: 0;
  min-height: 58px;
  border-bottom: 1px solid var(--line);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 10px;
  padding: 9px 11px;
}

.journal-item:last-child {
  border-bottom: 0;
}

.journal-item-copy,
.journal-item-copy strong,
.journal-item-copy span {
  min-width: 0;
  display: block;
  overflow-wrap: anywhere;
}

.journal-item-copy span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.78rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.journal-actions {
  display: flex;
  gap: 5px;
}

.journal-item-meta {
  display: flex;
  align-items: center;
  gap: 5px;
}

.journal-item-meta:empty {
  display: none;
}

.journal-state {
  min-height: 25px;
  border: 1px solid var(--line);
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  padding: 0.18rem 0.5rem;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
}

.task-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  grid-template-columns: 4px minmax(0, 1fr);
  overflow: hidden;
  background: var(--surface);
  box-shadow: 0 2px 8px rgba(59, 52, 44, 0.04);
}

.task-stripe {
  background: var(--line-strong);
}

.task-content {
  min-width: 0;
  padding: 12px;
}

.task-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.task-title {
  margin-bottom: 7px;
  font-size: 1rem;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.task-note {
  margin-bottom: 9px;
  color: var(--muted);
  font-size: 0.87rem;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.meta-row {
  margin-bottom: 9px;
  gap: 5px;
}

.pill,
.source-badge {
  min-height: 25px;
  border: 1px solid var(--line);
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 0.18rem 0.5rem;
  background: rgba(255, 255, 255, 0.78);
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
}

.source-badge {
  flex: 0 0 auto;
  background: var(--surface-2);
  color: var(--muted);
}

.pill.important {
  border-color: rgba(200, 63, 54, 0.35);
  color: var(--brand-dark);
}

.pill.recurrence-pill svg {
  width: 13px;
  height: 13px;
}

.pill.google-reminder {
  border-color: var(--line);
  background: var(--surface-2);
  color: var(--muted);
}

.pill.status-doing {
  border-color: transparent;
  background: var(--gold-soft);
  color: var(--gold-deep);
}

.pill.status-waiting {
  border-color: transparent;
  background: var(--blue-soft);
  color: var(--blue-deep);
}

.pill.status-done {
  border-color: transparent;
  background: var(--green-soft);
  color: var(--green);
}

.pill.status-cancelled {
  border-color: transparent;
  background: var(--surface-2);
  color: var(--muted);
}

.field-hint {
  border-left: 3px solid var(--warn);
  padding-left: 8px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 500;
  line-height: 1.45;
}

.task-card.priority-important .task-stripe {
  background: var(--brand);
}

.task-card.is-overdue .task-stripe {
  background: var(--warn);
}

.task-card.status-doing .task-stripe {
  background: var(--gold);
}

.task-card.status-waiting .task-stripe {
  background: var(--blue);
}

.task-card.status-done .task-stripe {
  background: var(--green);
}

.task-card.status-inbox .task-stripe {
  background: var(--line-strong);
}

.task-card.status-cancelled {
  opacity: 0.66;
}

.task-card.is-overdue:not(.status-done) {
  background: var(--warn-soft);
}

/* 在逾期頁裡，整片橙底只會放大焦慮；stripe 與日期已足夠說明 */
body[data-view="overdue"] .task-card.is-overdue:not(.status-done) {
  background: var(--surface);
}

.task-actions {
  align-items: stretch;
}

.task-card[data-task-id] {
  cursor: pointer;
}

.task-actions .task-more {
  border-color: transparent;
  background: transparent;
  color: var(--muted);
  font-size: 0.78rem;
}

.task-actions .task-more svg {
  width: 15px;
  height: 15px;
}

.task-secondary {
  display: none;
  width: 100%;
  flex-wrap: wrap;
  gap: 8px;
}

.task-card.expanded .task-secondary {
  display: flex;
}

.task-actions button {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0.35rem 0.55rem;
  background: rgba(255, 255, 255, 0.82);
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
}

.task-actions button.complete {
  border-color: var(--green);
  background: var(--green);
  color: #fff;
}

/* 空狀態的句子偏長，置中會讓每一行的起點都在跳；全站一律靠左讀起來才穩。 */
.empty {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 24px 16px;
  background: var(--surface-2);
  color: var(--muted);
  text-align: left;
}

dialog {
  width: min(520px, calc(100% - 24px));
  max-height: min(780px, calc(100vh - 32px));
  max-height: min(780px, calc(100dvh - 32px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 24px 70px rgba(59, 52, 44, 0.2);
  overflow: auto;
}

dialog.wide-dialog {
  width: min(680px, calc(100% - 24px));
}

dialog::backdrop {
  background: rgba(28, 26, 23, 0.44);
  backdrop-filter: blur(3px);
}

.language-choice-dialog {
  width: min(500px, calc(100% - 24px));
}

.language-choice-inner {
  padding: 30px;
  text-align: center;
}

.language-choice-mark {
  width: 62px;
  height: 62px;
  margin-bottom: 14px;
  border-radius: 16px;
}

.language-choice-inner .section-kicker {
  margin-bottom: 7px;
}

.language-choice-inner h2 {
  margin: 0;
  line-height: 1.3;
}

.language-choice-inner h2 span {
  color: var(--muted);
  font-size: 0.78em;
  font-weight: 600;
}

.language-choice-copy,
.language-choice-note {
  color: var(--muted);
}

.language-choice-copy {
  margin: 14px 0 20px;
}

.language-choice-note {
  margin: 16px 0 0;
  font-size: 0.82rem;
}

.language-choice-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.language-choice-actions button {
  min-height: 86px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 14px;
  background: var(--surface);
  color: var(--ink);
  text-align: left;
}

.language-choice-actions button:hover,
.language-choice-actions button:focus-visible {
  border-color: var(--brand);
  background: var(--brand-soft);
}

.language-choice-actions strong,
.language-choice-actions span {
  display: block;
}

.language-choice-actions strong {
  font-size: 1.05rem;
}

.language-choice-actions span {
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.8rem;
}

.dialog-inner {
  padding: 18px;
}

.dialog-heading {
  margin-bottom: 16px;
}

.login-copy {
  margin-bottom: 14px;
  color: var(--muted);
}

.account-summary {
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--surface-2);
  font-weight: 600;
  overflow-wrap: anywhere;
}

.login-actions {
  display: grid;
}

.sticky-dialog-heading {
  position: sticky;
  z-index: 2;
  top: -18px;
  margin: -18px -18px 0;
  border-bottom: 1px solid var(--line);
  padding: 15px 18px 12px;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(10px);
}

.dialog-grid,
.setting-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 10px 0;
}

.full-field {
  grid-column: 1 / -1;
}

.check-row,
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.check-row {
  justify-content: flex-start;
  margin: 12px 0;
}

.check-row input {
  width: auto;
}

.toggle-row input {
  appearance: none;
  width: 44px;
  height: 26px;
  border: 0;
  border-radius: 999px;
  position: relative;
  flex: 0 0 44px;
  padding: 0;
  background: var(--line-strong);
  transition: background 0.16s ease;
}

.toggle-row input::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
  transition: transform 0.16s ease;
}

.toggle-row input:checked {
  background: var(--green);
}

.toggle-row input:checked::after {
  transform: translateX(18px);
}

/* ===== 設定對話框 =====
   分隔用的是「白卡浮在暖紙底上」——和主畫面的任務卡同一套語言，
   不是靠一堆分隔線。線只留在頁首、頁尾與危險區。
   間距階梯只用 4 / 8 / 12 / 16 / 24 / 32。 */

.settings-form {
  --settings-pad: 16px;
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px);
  padding: 0 var(--settings-pad) var(--settings-pad);
  background: var(--canvas);
  overflow-y: auto;
}

@media (min-width: 901px) {
  .settings-form { --settings-pad: 20px; }
}

/* --- 頁首：白底 chrome，版本號貼在標題下（封測期最常被查，不佔額外高度） --- */
.settings-form .sticky-dialog-heading {
  position: sticky;
  z-index: 2;
  top: 0;
  margin: 0 calc(var(--settings-pad) * -1) 0;
  border-bottom: 1px solid var(--line);
  padding: 14px var(--settings-pad);
  background: var(--surface);
  align-items: flex-start;
  gap: 12px;
}

.settings-form .sticky-dialog-heading h2 {
  color: var(--ink);
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.3;
}

.settings-version-kicker {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1.4;
  letter-spacing: 0;
  text-transform: none;
}

.settings-version-kicker strong {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.settings-form .sticky-dialog-heading .icon-btn.compact {
  width: 44px;
  min-height: 44px;
  flex: 0 0 44px;
}

/* --- 分組標籤：坐在暖紙底上，小而淡，只當路標 --- */
.settings-group-label {
  margin: 24px 0 8px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1.4;
  letter-spacing: 0.06em;
}

.settings-group-label:first-of-type {
  margin-top: 16px;
}

/* 設定先給全貌與目前狀態；只有使用者主動要改時才露出欄位。 */
.settings-group {
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: 0 2px 8px rgba(59, 52, 44, 0.04);
}

.settings-group > summary {
  min-height: 58px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  list-style: none;
  color: var(--ink);
  font-size: 1rem;
  font-weight: 700;
}

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

.settings-group > summary small {
  margin-left: auto;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 500;
  text-align: right;
}

.settings-group > summary::after {
  content: "";
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(45deg) translate(-2px, -2px);
  transition: transform 0.15s ease;
}

.settings-group[open] > summary {
  border-bottom: 1px solid var(--line);
}

.settings-group[open] > summary::after {
  transform: rotate(-135deg) translate(-2px, -2px);
}

.settings-group-body {
  padding: 8px;
}

.settings-group-body .settings-section {
  box-shadow: none;
}

/* --- 區塊＝一張白卡（同 .task-card 的語言） --- */
.settings-section {
  margin: 8px 0 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  display: grid;
  gap: 12px;
  align-content: start;
  background: var(--surface);
  box-shadow: 0 2px 8px rgba(59, 52, 44, 0.04);
}

.settings-group-label + .settings-section {
  margin-top: 0;
}

.settings-section > * {
  margin: 0;
}

/* 未連線時這行是空的，不要吃掉一整格 gap */
.settings-form .connection-account:empty {
  display: none;
}

/* --- 區塊標題 --- */
.settings-form .settings-title {
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  min-height: 24px;
}

.settings-form .settings-title h3 {
  min-width: 0;
  color: var(--ink);
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.settings-form .settings-title .connection-pill {
  margin-left: auto;
  flex: 0 0 auto;
  white-space: nowrap;
}

/* --- 收合列：整列 44px 可點 --- */
.settings-collapse {
  display: grid;
  gap: 12px;
}

.settings-collapse > summary {
  cursor: pointer;
  list-style: none;
}

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

.settings-collapse > summary.settings-title,
.settings-collapse[open] > summary.settings-title {
  min-height: 44px;
  margin: 0;
  padding: 0;
}

.settings-collapse > summary::after {
  content: "";
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  margin-left: auto;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(45deg) translate(-2px, -2px);
  transition: transform 0.15s ease;
}

.settings-collapse[open] > summary::after {
  transform: rotate(-135deg) translate(-2px, -2px);
}

/* --- 欄位：label 貼著控制項（4），欄位之間 12 --- */
.settings-form label {
  gap: 4px;
  color: var(--muted);
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.4;
}

.settings-form .setting-grid,
.settings-form .compact-grid {
  margin: 0;
  gap: 12px;
}

.setting-pair {
  display: grid;
  gap: 8px;
  align-content: start;
}

/* 開關列文字是控制項主體，不是說明文字 */
.settings-form .toggle-row {
  min-height: 44px;
  gap: 12px;
  color: var(--ink);
  font-size: 0.9375rem;
  font-weight: 500;
}

.settings-form .toggle-row > span {
  min-width: 0;
  overflow-wrap: anywhere;
}

/* --- 輔助說明統一一階 --- */
.settings-form .connection-account,
.settings-form .about-copy,
.settings-form .how-to-use dd,
.settings-form .how-to-use > p,
.settings-form .google-voice-flow span {
  margin: 0;
  color: var(--muted);
  font-size: 0.8125rem;
  line-height: 1.6;
}

.settings-form .how-to-use dl { margin: 0; display: grid; gap: 4px; }
.settings-form .how-to-use dt { margin: 8px 0 0; font-size: 0.875rem; font-weight: 700; }
.settings-form .how-to-use dt:first-child { margin-top: 0; }
.settings-form .how-to-use dd { margin: 0; }
.settings-form .about-line { font-size: 0.9375rem; font-weight: 700; }

/* --- 狀態 pill：真的壞了才發出聲音 --- */
.settings-form .connection-pill {
  min-height: 26px;
  padding: 0.15rem 0.6rem;
  font-size: 0.75rem;
  font-weight: 650;
  line-height: 1.3;
}

.connection-pill.attention {
  background: var(--warn-soft);
  color: var(--warn-deep);
}

/* --- 觸控目標一律 44 --- */
.settings-form .primary-btn,
.settings-form .secondary-btn,
.settings-form .file-button,
.settings-form .text-btn,
.settings-form .settings-links a {
  min-height: 44px;
}

.settings-form .settings-links a { padding: 8px 14px; }

.settings-form .about-version {
  display: flex;
  justify-content: flex-start;
}

.settings-form .about-version .text-btn {
  margin-left: 0;
  padding-inline: 0;
  font-size: 0.875rem;
}

/* --- 危險區：破壞性動作靠左、不置中，不要看起來像主要行動 --- */
.settings-form .account-danger-zone {
  margin-top: 24px;
}

.settings-form .account-danger-zone > .text-btn,
.settings-form .about-version > .text-btn {
  justify-content: flex-start;
  justify-self: start;
  padding-inline: 0;
}

/* --- 頁尾：儲存鍵釘住，不必捲過刪除帳號才能存 --- */
.settings-form .dialog-footer {
  position: sticky;
  z-index: 2;
  bottom: calc(var(--settings-pad) * -1);
  margin: 24px calc(var(--settings-pad) * -1) calc(var(--settings-pad) * -1);
  border-top: 1px solid var(--line);
  padding: 12px var(--settings-pad);
  background: var(--surface);
}

.settings-actions {
  align-items: stretch;
  margin: 0;
  gap: 8px;
}

.sync-health-card {
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 8px;
  padding: 12px;
  background: var(--surface-2);
}

.sync-health-card > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 4px 12px;
}

.sync-health-card > div span {
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.4;
}

/* 最常被看的一個字，要比它的標籤重 */
.sync-health-card > div strong {
  color: var(--ink);
  font-size: 0.9375rem;
  font-weight: 650;
  line-height: 1.3;
}

.sync-health-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.8125rem;
  line-height: 1.5;
}

.sync-health-card .error-note {
  color: var(--error);
  overflow-wrap: anywhere;
}

.sync-health-card .secondary-btn {
  justify-self: start;
}

.compact-grid {
  margin-block: 12px;
}

.google-voice-flow {
  display: flex;
  align-items: center;
  gap: 10px;
  border-left: 4px solid var(--line-strong);
  padding: 8px 0 8px 11px;
}

.google-voice-flow > div {
  display: grid;
  gap: 2px;
}

.google-voice-flow span {
  color: var(--muted);
  font-size: 0.82rem;
}

.category-rule-list {
  margin-bottom: 10px;
  display: grid;
  gap: 8px;
}

.category-rule-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  grid-template-columns: minmax(120px, 0.7fr) minmax(180px, 1.3fr) 36px;
  align-items: end;
  gap: 8px;
  padding: 9px;
  background: var(--surface-2);
}

.category-edit-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.connection-account,
.error-note {
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 0.85rem;
}

.error-note {
  margin-top: 9px;
  color: var(--error);
}

.tone-preview {
  margin-top: 10px;
  margin-bottom: 0;
  border-left: 4px solid var(--gold);
}

.dialog-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding-top: 16px;
}

.split-footer {
  justify-content: space-between;
}

.file-button {
  position: relative;
}

.file-button input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.toast {
  position: fixed;
  z-index: 100;
  right: 16px;
  bottom: calc(16px + var(--bottom-safe));
  max-width: min(380px, calc(100% - 32px));
  border-radius: 8px;
  padding: 11px 14px;
  background: #2b2723;
  color: #fff;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(14px);
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

/* 提示本身永遠不擋點擊；只有「復原」按鈕自己收得到點擊。 */
.toast.has-action .toast-undo {
  pointer-events: auto;
}

.mobile-nav {
  display: none;
}

@media (max-width: 900px) {
  .capture-controls {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .work-layout {
    grid-template-columns: 1fr;
    grid-template-areas:
      "today"
      "capture"
      "list";
  }

  .today-panel {
    position: static;
  }
}

@media (max-width: 680px) {
  body {
    padding-bottom: calc(70px + var(--bottom-safe));
  }

  .header-inner,
  .shell,
  .public-site-links {
    width: min(100% - 18px, 1180px);
  }

  .public-site-links {
    padding-bottom: calc(86px + var(--bottom-safe));
  }

  .header-inner {
    min-height: 68px;
  }

  .shell {
    padding-top: 10px;
  }

  .capture-settings-panel {
    padding: 9px;
  }

  .capture-schedule-controls {
    gap: 6px;
  }

  .brand-mark {
    width: 40px;
    height: 40px;
    flex-basis: 40px;
  }

  h1 {
    font-size: 1.5rem;
  }

  .status-copy {
    display: block;
  }

  .status-copy span {
    display: none;
  }

  .status-strip {
    min-height: 44px;
    padding: 7px 10px;
  }

  .status-strip .text-btn {
    min-height: 30px;
  }

  .metrics {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 5px;
    margin-top: 7px;
  }

  body:is(.calendar-task-view, .compact-capture-view) .metrics {
    display: none;
  }

  body:is(.calendar-task-view, .compact-capture-view) .work-layout {
    margin-top: 7px;
  }

  body:is(.calendar-task-view, .compact-capture-view) .calendar-capture-toggle {
    display: grid;
  }

  body:is(.calendar-task-view, .compact-capture-view):not(.calendar-capture-expanded) .capture-band {
    border-top-width: 3px;
    box-shadow: none;
  }

  body:is(.calendar-task-view, .compact-capture-view):not(.calendar-capture-expanded) .capture-band form {
    padding: 8px 10px;
  }

  body:is(.calendar-task-view, .compact-capture-view):not(.calendar-capture-expanded) .capture-heading {
    margin: 0;
  }

  body:is(.calendar-task-view, .compact-capture-view):not(.calendar-capture-expanded) .capture-heading .section-kicker,
  body:is(.calendar-task-view, .compact-capture-view):not(.calendar-capture-expanded) .capture-main,
  body:is(.calendar-task-view, .compact-capture-view):not(.calendar-capture-expanded) .capture-intelligence,
  body:is(.calendar-task-view, .compact-capture-view):not(.calendar-capture-expanded) .capture-rules,
  body:is(.calendar-task-view, .compact-capture-view):not(.calendar-capture-expanded) .capture-settings,
  body:is(.calendar-task-view, .compact-capture-view):not(.calendar-capture-expanded) #voiceCaptureButton,
  body:is(.calendar-task-view, .compact-capture-view):not(.calendar-capture-expanded) #clearInputButton {
    display: none;
  }

  body:is(.calendar-task-view, .compact-capture-view):not(.calendar-capture-expanded) .capture-heading h2 {
    font-size: 0.94rem;
  }

  body.compact-capture-view .today-panel {
    display: none;
  }

  #settingsButton {
    display: none;
  }

  .metric {
    min-height: 50px;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 3px;
    padding: 7px 8px;
  }

  .metric svg {
    display: none;
  }

  .metric span {
    font-size: 0.72rem;
    white-space: nowrap;
  }

  .metric strong {
    font-size: 1.08rem;
  }

  .capture-band,
  .work-layout {
    margin-top: 10px;
  }

  .work-layout {
    grid-template-areas:
      "today"
      "capture"
      "list";
  }

  .capture-band form {
    padding: 11px;
  }

  .capture-heading {
    margin-bottom: 7px;
  }

  .capture-heading h2 {
    font-size: 1.13rem;
  }

  .capture-heading .section-kicker {
    font-size: 0.7rem;
  }

  .capture-main {
    grid-template-columns: 1fr;
    gap: 7px;
  }

  #dumpInput {
    min-height: 70px;
    padding-block: 0.58rem;
    font-size: 0.92rem;
  }

  .capture-main .primary-btn {
    min-height: 44px;
  }

  .capture-intelligence {
    min-height: 26px;
    margin-top: 3px;
    font-size: 0.74rem;
  }

  .capture-settings {
    margin-top: 5px;
  }

  .today-panel {
    padding: 13px;
  }

  body.active-focus-view .status-strip,
  body.active-focus-view .metrics,
  body.active-focus-view .capture-band,
  body.active-focus-view .list-panel {
    display: none;
  }

  body.active-focus-view .work-layout {
    margin-top: 2px;
  }

  body.active-focus-view .today-panel {
    display: flex;
    flex-direction: column;
  }

  body.active-focus-view .active-focus {
    flex: 0 0 auto;
  }

  .ai-suggestion-grid {
    grid-template-columns: 1fr 1fr;
  }

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

  .custom-duration {
    grid-template-columns: 1fr;
  }

  .focus-help-choices {
    grid-template-columns: 1fr;
  }

  .ai-suggestion-reason {
    margin-left: 0;
  }

  .capture-controls,
  .dialog-grid,
  .setting-grid {
    grid-template-columns: 1fr;
  }

  .category-rule-row,
  .category-edit-row {
    grid-template-columns: 1fr;
  }

  .category-rule-row .icon-btn {
    justify-self: end;
  }

  .full-field {
    grid-column: auto;
  }

  .list-toolbar {
    grid-template-columns: 1fr;
  }

  .calendar-day {
    min-height: 86px;
    padding: 3px;
  }

  .calendar-day-number {
    width: 22px;
    height: 22px;
    font-size: 0.7rem;
  }

  .calendar-task {
    min-height: 23px;
    border-left-width: 2px;
    padding: 3px;
  }

  .calendar-task span {
    display: none;
  }

  .calendar-task .calendar-repeat {
    display: inline;
  }

  .calendar-task strong {
    font-size: 0.65rem;
  }

  .calendar-undated > div {
    grid-template-columns: 1fr;
  }

  .search-box {
    display: none;
  }

  .view-tabs .tab[data-view="today"],
  .view-tabs .tab[data-view="focus"],
  .view-tabs .tab[data-view="waiting"],
  .view-tabs .tab[data-view="done"] {
    display: none;
  }

  body.focus-landing-view .metrics,
  body.focus-landing-view .capture-band,
  body.focus-landing-view .list-panel {
    display: none;
  }

  body.focus-landing-view .work-layout {
    margin-top: 8px;
  }

  body.focus-landing-view .today-panel {
    min-height: calc(100dvh - 230px - var(--bottom-safe));
    align-content: start;
  }

  .focus-task-actions {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 42px;
  }

  .focus-more-actions[open] {
    grid-column: 1 / -1;
  }

  .focus-more-actions[open] > div {
    position: static;
    width: 100%;
    margin-top: 5px;
    grid-template-columns: 1fr 1fr;
    box-shadow: none;
  }

  .task-list.matrix-list {
    grid-template-columns: 1fr;
  }

  .language-choice-inner {
    padding: 24px 18px;
  }

  .language-choice-actions {
    grid-template-columns: 1fr;
  }

  .task-title-row {
    display: block;
  }

  .journal-day {
    grid-template-columns: 52px minmax(0, 1fr);
  }

  .journal-item {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .journal-item .source-badge {
    display: none;
  }

  .source-badge {
    margin-bottom: 7px;
  }

  .settings-actions > .primary-btn,
  .settings-actions > .secondary-btn,
  .settings-actions > .file-button {
    flex: 1 1 auto;
  }

  /* 破壞性動作（解除連結、關閉這台裝置）不該跟主行動同寬同重量 */
  .settings-form .settings-actions > .text-btn {
    flex: 1 0 100%;
    justify-content: flex-start;
    padding-inline: 0;
  }

  .settings-form .settings-links a {
    flex: 1 1 auto;
    justify-content: center;
  }

  .mobile-nav {
    position: fixed;
    z-index: 30;
    right: 0;
    bottom: 0;
    left: 0;
    min-height: calc(68px + var(--bottom-safe));
    border-top: 2px solid var(--line-strong);
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    padding: 5px 5px var(--bottom-safe);
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(14px);
    box-shadow: 0 -8px 22px rgba(59, 52, 44, 0.1);
  }

  .mobile-nav button {
    position: relative;
    min-width: 0;
    border: 0;
    border-radius: 6px;
    display: grid;
    justify-items: center;
    align-content: center;
    gap: 3px;
    background: transparent;
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 650;
  }

  .mobile-nav button svg {
    width: 21px;
    height: 21px;
  }

  .mobile-nav button.active {
    background: var(--brand-soft);
    color: var(--brand-dark);
  }

  .mobile-nav button.active::before {
    position: absolute;
    top: -7px;
    width: 30px;
    height: 4px;
    border-radius: 0 0 4px 4px;
    background: var(--brand);
    content: "";
  }

  .mobile-nav button.active svg {
    stroke-width: 2.6;
  }

  body[data-view="today"] .mobile-nav button.active {
    background: var(--gold-soft);
    color: var(--gold-deep);
  }

  body[data-view="today"] .mobile-nav button.active::before {
    background: var(--gold);
  }

  body[data-view="focus"] .mobile-nav button.active {
    background: var(--teal-soft);
    color: var(--teal);
  }

  body[data-view="focus"] .mobile-nav button.active::before {
    background: var(--teal);
  }

  body[data-view="waiting"] .mobile-nav button.active {
    background: var(--blue-soft);
    color: var(--blue-deep);
  }

  body[data-view="waiting"] .mobile-nav button.active::before {
    background: var(--blue);
  }

  body[data-view="done"] .mobile-nav button.active {
    background: var(--green-soft);
    color: var(--green);
  }

  body[data-view="done"] .mobile-nav button.active::before {
    background: var(--green);
  }

  .toast {
    bottom: calc(76px + var(--bottom-safe));
  }
}

@media (max-width: 380px) {
  .header-inner {
    gap: 8px;
  }

  .brand-lockup {
    gap: 8px;
  }

  .brand-lockup .eyebrow {
    display: none;
  }

  .brand-mark {
    width: 36px;
    height: 36px;
    flex-basis: 36px;
  }

  h1 {
    font-size: 1.32rem;
  }

  .header-actions {
    flex-wrap: nowrap;
    gap: 5px;
  }

  .header-actions .icon-btn {
    width: 38px;
    min-height: 38px;
  }

  #loginButton {
    padding-inline: 0.25rem;
    font-size: 0.78rem;
  }

  .metric-label-full {
    display: none;
  }

  .metric-label-compact {
    display: inline;
  }
}

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