/* Warm Journal Theme
   Fonts are loaded from index.html via <link> so they don't block rendering
   (and so the app still paints instantly when offline). */

:root {
  --bg-paper: #fdfbf7;
  --bg-paper-dark: #f0ebe4;
  --ink-primary: #4a403a;
  --ink-secondary: #8c7b75;
  --accent-gold: #cfaa6e;
  --accent-highlight: #e6b45c;
  --accent-soft-red: #dfaaaaaa;

  /* Tag Colors */
  --tag-school: #e3f2fd;
  --tag-school-text: #1565c0;
  --tag-work: #f3e5f5;
  --tag-work-text: #7b1fa2;
  --tag-love: #ffebee;
  --tag-love-text: #c62828;
  --tag-life: #e8f5e9;
  --tag-life-text: #2e7d32;
  --tag-travel: #fff3e0;
  --tag-travel-text: #ef6c00;
  --tag-other: #f5f5f5;
  --tag-other-text: #616161;

  --cell-lived: #ece5db;
  --shadow-soft: 0 4px 20px rgba(74, 64, 58, 0.08);
  /* Chinese fallbacks matter: the Google fonts carry no CJK glyphs, and offline
     there are no webfonts at all. */
  --font-heading: 'Cormorant Garamond', 'Noto Serif TC', 'PingFang TC', 'Microsoft JhengHei', serif;
  --font-body: 'Lato', 'PingFang TC', 'Microsoft JhengHei', 'Noto Sans TC', -apple-system, sans-serif;
  --line-color: #dcd3c9;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  background-color: var(--bg-paper);
  color: var(--ink-primary);
  font-family: var(--font-body);
  transition: background-color 0.3s ease;
  overflow-x: hidden;
}

.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-width: 600px;
  margin: 0 auto;
  border-left: 1px solid rgba(0, 0, 0, 0.05);
  border-right: 1px solid rgba(0, 0, 0, 0.05);
  background: white;
  box-shadow: 0 0 50px rgba(0, 0, 0, 0.03);
  position: relative;
  overflow: hidden;
  /* Clips the full-screen views (search list / flow / life grid) */
}

/* --- Header & Progress --- */
header {
  padding: 20px 24px 10px;
  background-color: var(--bg-paper);
  border-bottom: 1px dashed var(--line-color);
  z-index: 10;
  position: relative;
}

/* Header Buttons */
.icon-btn {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--ink-secondary);
  padding: 4px;
}

.icon-btn:hover {
  color: var(--ink-primary);
}

.settings-btn {
  display: none;
}

h1 {
  font-family: var(--font-heading);
  font-size: 2rem;
  margin: 0;
  font-weight: 700;
  letter-spacing: -0.02em;
}

/* Main Search Bar */
.search-container-main {
  padding: 10px 24px 0;
  background-color: var(--bg-paper);
}

.search-input-main {
  width: 100%;
  padding: 10px 16px;
  border: 1px solid var(--line-color);
  border-radius: 20px;
  background: white;
  font-size: 0.95rem;
  transition: all 0.2s;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.02);
}

.search-input-main:focus {
  border-color: var(--accent-gold);
  box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.1);
  outline: none;
}

/* Filter List Items */
.filter-row {
  display: flex;
  align-items: center;
  margin-bottom: 10px;
  padding: 8px;
  border-radius: 8px;
  background: white;
  border: 1px solid #eee;
  width: 100%;
  transition: all 0.2s;
}

.filter-row.is-dragging {
  opacity: 0.6;
  border: 1px dashed var(--accent-gold);
  box-shadow: none;
}

/* Suppress the hover lift while reordering, or rows jump under the pointer */
.filter-list-container.is-reordering .filter-row:hover {
  transform: none;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.03);
}

/* Only this claims the touch gesture; the list itself stays scrollable */
.tag-drag-handle {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  margin-right: 4px;
  border-radius: 6px;
  color: var(--ink-secondary);
  opacity: 0.55;
  cursor: grab;
  touch-action: none;
  transition: opacity 0.15s, background 0.15s;
}

.tag-drag-handle:hover {
  opacity: 1;
  background: rgba(0, 0, 0, 0.05);
}

.tag-drag-handle:active {
  cursor: grabbing;
}

.tag-drag-handle:focus-visible {
  outline: 2px solid var(--accent-gold);
  outline-offset: -2px;
  opacity: 1;
}

[data-theme="dark"] .tag-drag-handle:hover {
  background: rgba(255, 255, 255, 0.08);
}

.filter-tag-chip {
  flex: 1;
  padding: 6px 12px;
  border-radius: 4px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  margin-right: 10px;
  user-select: none;
}

.tag-actions-group {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: flex-end;
  min-width: 120px; /* Standardize space for actions */
}

.btn-order-arrow {
  width: 36px;
  height: 36px;
  background: #ffffff;
  border: 1px solid #e8e8e8;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #555;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  padding: 0;
  box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}

.btn-order-arrow:hover {
  background: #fdfdfd;
  border-color: #999;
  color: #111;
  box-shadow: 0 2px 5px rgba(0,0,0,0.08);
}

.btn-order-arrow:active {
  background: #f5f5f5;
  transform: translateY(1px);
}


.btn-delete-tag-icon {
  background: none;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  color: #ff3b30; /* Keep Red Trash Can */
  opacity: 0.8;
  transition: all 0.2s ease;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
}


.btn-delete-tag-icon:hover {
  opacity: 1;
  transform: scale(1.1);
}





.btn-delete-tag-icon {
  background: none;
  border: none;
  font-size: 1.1rem;
  cursor: pointer;
  opacity: 0.4;
  transition: opacity 0.2s;
  padding: 4px;
}

.btn-delete-tag-icon:hover {
  opacity: 1;
}

.subtitle {
  font-size: 0.9rem;
  color: var(--ink-secondary);
  font-style: italic;
  margin-top: 4px;
}

/* Timeline Area */
.timeline-list-container {
  flex: 1;
  overflow-y: auto;
  position: relative;
  scroll-behavior: smooth;
  padding: 24px 0 80px;
}

/* Vertical Line - Hidden per user request */
.timeline-line {
  display: none;
  position: absolute;
  top: 0;
  bottom: 0;
  left: 32px;
  width: 2px;
  background-color: var(--line-color);
  z-index: 0;
}

/* Event Items */
.event-item {
  position: relative;
  padding: 0 24px 32px 60px;
  opacity: 0;
  transform: translateY(10px);
  animation: fadeIn 0.5s forwards;
}

@keyframes fadeIn {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.event-marker {
  position: absolute;
  left: 27px;
  top: 4px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background-color: var(--bg-paper);
  border: 2px solid var(--accent-gold);
  z-index: 2;
  transition: background-color 0.2s;
}

.event-item:hover .event-marker {
  background-color: var(--accent-gold);
}

.event-date-group {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}

.event-year-month {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--ink-primary);
}

.event-age {
  font-size: 0.75rem;
  color: var(--ink-secondary);
  background-color: var(--bg-paper-dark);
  padding: 2px 6px;
  border-radius: 4px;
}

.event-card {
  background-color: white;
  border-radius: 8px;
  padding: 16px;
  box-shadow: var(--shadow-soft);
  border: 1px solid rgba(0, 0, 0, 0.02);
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
  overflow: hidden;
}

.event-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent-gold);
  box-shadow: 0 6px 24px rgba(74, 64, 58, 0.12);
}

.event-title {
  font-size: 1rem;
  font-weight: 600;
  margin: 0 0 4px 0;
}

.event-desc {
  font-size: 0.9rem;
  color: var(--ink-secondary);
  line-height: 1.5;
  white-space: pre-wrap;
}

/* Tags */
.event-tags {
  margin-top: 8px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.tag {
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 12px;
  font-weight: 600;
  background-color: var(--tag-other);
  color: var(--tag-other-text);
}

.tag[data-type="academic"] {
  background-color: var(--tag-school);
  color: var(--tag-school-text);
}

.tag[data-type="work"] {
  background-color: var(--tag-work);
  color: var(--tag-work-text);
}

.tag[data-type="love"] {
  background-color: var(--tag-love);
  color: var(--tag-love-text);
}

.tag[data-type="life"] {
  background-color: var(--tag-life);
  color: var(--tag-life-text);
}

.tag[data-type="travel"] {
  background-color: var(--tag-travel);
  color: var(--tag-travel-text);
}

/* FAB */
.fab {
  position: fixed;
  bottom: 30px;
  right: 30px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background-color: var(--ink-primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  cursor: pointer;
  border: none;
  transition: transform 0.2s;
  z-index: 20;
}

.fab:hover {
  transform: scale(1.1);
}

@media (min-width: 620px) {
  .fab {
    right: calc(50% - 270px);
  }
}

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(74, 64, 58, 0.4);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  background: var(--bg-paper);
  padding: 24px;
  border-radius: 12px;
  width: 90%;
  max-width: 400px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
  max-height: 90vh;
  overflow-y: auto;
}

.modal-header {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  margin-bottom: 20px;
  display: flex;
  justify-content: space-between;
}

/* Forms */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  margin-bottom: 4px;
  color: var(--ink-secondary);
  font-size: 0.9rem;
}

.form-input,
input[type="text"],
input[type="date"],
select,
textarea {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--line-color);
  border-radius: 8px;
  font-family: inherit;
  font-size: 1rem;
  background: white;
}

.search-section .form-input {
  flex: 1;
}

.hybrid-date-wrapper {
  display: flex;
  position: relative;
  align-items: center;
  width: 100%;
}

.hybrid-date-wrapper input[type="text"] {
  flex: 1;
  padding-right: 45px;
}

.picker-container {
  position: absolute;
  right: 5px;
  width: 35px;
  height: 35px;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.picker-container span {
  font-size: 1.2rem;
  pointer-events: none;
}

.picker-container input[type="date"] {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  pointer-events: auto;
}

.checkbox-group {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}

.checkbox-group input {
  width: auto;
}

.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 24px;
}

.btn-primary {
  flex: 2;
  background-color: var(--ink-primary);
  color: white;
  border: none;
  padding: 14px;
  border-radius: 8px;
  font-weight: 700;
  cursor: pointer;
}

.btn-delete {
  flex: 1;
  background-color: transparent;
  color: #c62828;
  border: 1px solid #ffcdd2;
  padding: 14px;
  border-radius: 8px;
  font-weight: 700;
  cursor: pointer;
}

/* Full Screen List View */
.full-screen-list-view {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: var(--bg-paper);
  z-index: 200;
  display: flex;
  flex-direction: column;
  transform: translateY(100%);
  transition: transform 0.3s ease-in-out;
}

.full-screen-list-view.open {
  transform: translateY(0);
}

.list-view-header {
  padding: 16px;
  border-bottom: 2px solid var(--line-color);
  background-color: white;
  display: flex;
  align-items: center;
  font-family: var(--font-heading);
  font-size: 1.2rem;
  font-weight: 700;
  flex-shrink: 0;
}

.btn-icon {
  background: none;
  border: none;
  font-size: 1.5rem;
  margin-right: 16px;
  cursor: pointer;
  color: var(--ink-primary);
}

.list-view-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

.list-view-item {
  margin-bottom: 24px;
  padding-bottom: 24px;
  border-bottom: 1px dotted var(--line-color);
  cursor: pointer;
}

.list-item-date {
  font-weight: 700;
  color: var(--accent-highlight);
  margin-bottom: 4px;
}

.list-item-age {
  font-weight: normal;
  color: var(--ink-secondary);
  font-size: 0.9em;
}

.list-item-title {
  font-size: 1.2rem;
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--ink-primary);
}

.list-item-desc {
  color: var(--ink-secondary);
  line-height: 1.5;
}

/* Tag Management Rows */
.filter-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: white;
  border-radius: 12px;
  margin-bottom: 12px;
  box-shadow: 0 4px 10px rgba(0,0,0,0.03);
  border: 1px solid #f2f2f2;
  transition: transform 0.2s;
}

.filter-row:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 15px rgba(0,0,0,0.05);
}

.btn-icon-small {
  background: none;
  border: 1px solid #ddd;
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 0.9rem;
  cursor: pointer;
}

.btn-icon-small:hover {
  background: #f0f0f0;
}

/* Settings Modal Buttons Layout */
.data-backup-row {
  display: flex;
  gap: 10px;
  margin-bottom: 10px;
}

.data-backup-row .btn-primary,
.data-backup-row .btn-secondary {
  flex: 1;
  margin: 0;
}

.btn-danger-block {
  width: 100%;
  background-color: transparent;
  color: #c62828;
  border: 1px solid #ffcdd2;
  padding: 12px;
  border-radius: 8px;
  font-weight: 700;
  cursor: pointer;
  margin-top: 5px;
  transition: all 0.2s;
}

.btn-danger-block:hover {
  background-color: #c62828;
  color: white;
}

/* Dark Mode Overrides */
:root[data-theme="dark"] {
  --bg-paper: #1c1c1c;
  --bg-paper-dark: #121212;
  --ink-primary: #e0e0e0;
  --ink-secondary: #aaa;
  --line-color: #333;
  --cell-lived: #3a3a3a;
  --shadow-soft: 0 4px 20px rgba(0, 0, 0, 0.5);

  --tag-school: #1a365d;
  --tag-school-text: #90cdf4;
  --tag-work: #44337a;
  --tag-work-text: #d6bcfa;
  --tag-love: #742a2a;
  --tag-love-text: #feb2b2;
  --tag-life: #22543d;
  --tag-life-text: #9ae6b4;
  --tag-travel: #7b341e;
  --tag-travel-text: #fbd38d;
  --tag-other: #2d3748;
  --tag-other-text: #e2e8f0;
}

[data-theme="dark"] .timeline-line {
  background-color: var(--line-color);
}

[data-theme="dark"] .event-card {
  background: #2a2a2a;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.3);
  border: 1px solid #333;
}

[data-theme="dark"] .modal-content {
  background: #2a2a2a;
  color: var(--ink-primary);
  border: 1px solid #444;
}

[data-theme="dark"] .form-input,
[data-theme="dark"] input[type="text"],
[data-theme="dark"] input[type="date"],
[data-theme="dark"] input[type="number"],
[data-theme="dark"] input[type="color"],
[data-theme="dark"] select,
[data-theme="dark"] textarea {
  background: #222;
  color: #e0e0e0;
  border: 1px solid #444;
}

[data-theme="dark"] .form-input:focus,
[data-theme="dark"] input[type="text"]:focus,
[data-theme="dark"] input[type="date"]:focus,
[data-theme="dark"] input[type="number"]:focus,
[data-theme="dark"] select:focus,
[data-theme="dark"] textarea:focus {
  border-color: var(--accent-highlight);
}

[data-theme="dark"] .filter-row {
  background: #2a2a2a;
  border-color: #444;
}

[data-theme="dark"] .list-view-header {
  background: #2a2a2a;
  border-bottom: 2px solid #444;
}

[data-theme="dark"] .full-screen-list-view {
  background: var(--bg-paper) !important;
}

[data-theme="dark"] .search-bar {
  background: #2a2a2a;
  border: 1px solid #444;
  color: #e0e0e0;
}

[data-theme="dark"] .app-container {
  background: var(--bg-paper);
  border-color: rgba(255, 255, 255, 0.05);
}

[data-theme="dark"] .search-input-main {
  background: #2a2a2a;
  border-color: #444;
  color: #e0e0e0;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.2);
}

[data-theme="dark"] .search-input-main:focus {
  border-color: var(--accent-highlight);
  box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.1);
}

[data-theme="dark"] .year-header,
[data-theme="dark"] .timeline-year-header {
  background: var(--bg-paper);
  color: #ccc;
}

[data-theme="dark"] .empty-state {
  color: #aaa !important;
}

[data-theme="dark"] .btn-icon-small {
  border-color: #444;
  color: var(--ink-secondary);
}

[data-theme="dark"] .btn-icon-small:hover {
  background: #333;
}

[data-theme="dark"] .btn-secondary {
  background: #333;
  color: #ccc;
  border-color: #444;
}

/* =========================================
   v2 ADDITIONS
   ========================================= */

/* --- Layout: room for the bottom tab bar, and a viewport unit that survives
       the mobile browser toolbar sliding in and out --- */
.app-container {
  height: 100vh;
  height: 100dvh;
}

.timeline-list-container {
  padding-bottom: 140px;
  scroll-behavior: auto;
  /* keep the year header readable under the sticky search field */
  scroll-padding-top: 8px;
}

/* --- Bottom tab bar --- */
.tab-bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  background: var(--bg-paper);
  border-top: 1px solid var(--line-color);
  padding-bottom: env(safe-area-inset-bottom, 0);
  z-index: 30;
}

.tab-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-height: 56px;
  padding: 8px 4px;
  background: none;
  border: none;
  font-family: inherit;
  font-size: 0.7rem;
  color: var(--ink-secondary);
  cursor: pointer;
  transition: color 0.15s;
}

.tab-btn span {
  font-size: 1.25rem;
  line-height: 1.1;
  filter: grayscale(1);
  opacity: 0.55;
  transition: filter 0.15s, opacity 0.15s;
}

.tab-btn.active {
  color: var(--ink-primary);
  font-weight: 700;
}

.tab-btn.active span {
  filter: none;
  opacity: 1;
}

/* FAB clears the tab bar */
.fab {
  bottom: 76px;
  z-index: 25;
}

/* --- Year headers (previously had no styling at all) --- */
.timeline-year-header {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 10px 24px 8px;
  margin-bottom: 8px;
}

.timeline-year-header .year-number {
  font-family: var(--font-heading);
  font-size: 1.9rem;
  font-weight: 700;
  line-height: 1;
  color: var(--ink-primary);
  /* Cormorant defaults to old-style figures, which turns "2021" into "2O2I" */
  font-variant-numeric: lining-nums;
}

.event-year-month,
.timeline-gap-row .gap-range,
.capsule-title,

.timeline-year-header .year-age {
  font-size: 0.8rem;
  color: var(--ink-secondary);
  background: var(--bg-paper-dark);
  padding: 2px 7px;
  border-radius: 10px;
}

.timeline-year-header.is-empty {
  padding-top: 6px;
  padding-bottom: 6px;
  margin-bottom: 0;
}

.timeline-year-header.is-empty .year-number {
  font-size: 1.15rem;
  opacity: 0.45;
}

.timeline-year-header.is-empty .year-age {
  opacity: 0.5;
}

.year-add-btn {
  margin-left: auto;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px dashed var(--line-color);
  background: none;
  color: var(--ink-secondary);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s, border-color 0.2s;
}

.timeline-year-header:hover .year-add-btn,
.year-add-btn:focus-visible {
  opacity: 1;
}

.year-add-btn:hover {
  border-color: var(--accent-gold);
  color: var(--accent-gold);
}

/* Touch devices have no hover, so keep the affordance permanently visible */
@media (hover: none) {
  .year-add-btn { opacity: 0.6; }
}

/* --- Collapsed run of years with nothing in them --- */
.timeline-gap-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 4px 24px 12px;
  padding: 10px 14px;
  border: 1px dashed var(--line-color);
  border-radius: 10px;
  background: transparent;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.timeline-gap-row:hover {
  border-color: var(--accent-gold);
  background: rgba(207, 170, 110, 0.06);
}

.timeline-gap-row .gap-range {
  font-family: var(--font-heading);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--ink-secondary);
}

.timeline-gap-row .gap-note {
  font-size: 0.78rem;
  color: var(--ink-secondary);
  opacity: 0.8;
}

.timeline-gap-row.is-expanded {
  border-style: solid;
  opacity: 0.7;
  margin-bottom: 4px;
}

.timeline-gap-row .gap-expand {
  margin-left: auto;
  font-size: 0.75rem;
  color: var(--accent-gold);
  font-weight: 700;
  white-space: nowrap;
}

/* --- Event card additions --- */
.event-date-sep {
  color: var(--ink-secondary);
  opacity: 0.5;
}

.event-card mark {
  background: rgba(230, 180, 92, 0.35);
  color: inherit;
  border-radius: 3px;
  padding: 0 2px;
}

/* --- "Back to today" --- */
.btn-today {
  position: absolute;
  left: 50%;
  bottom: 76px;
  transform: translate(-50%, 12px);
  padding: 8px 18px;
  border-radius: 20px;
  border: 1px solid var(--line-color);
  background: var(--bg-paper);
  color: var(--ink-primary);
  font-family: inherit;
  font-size: 0.82rem;
  box-shadow: var(--shadow-soft);
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  z-index: 22;
}

.btn-today.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, 0);
}

/* --- Search --- */
.search-container-main {
  position: relative;
  padding-bottom: 10px;
}

.search-input-main {
  padding-right: 40px;
  min-height: 44px;
}

.btn-clear-search {
  position: absolute;
  right: 34px;
  top: 50%;
  transform: translateY(-60%);
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 50%;
  background: var(--bg-paper-dark);
  color: var(--ink-secondary);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
}

/* --- Hints --- */
.view-hint,
.hint-text {
  font-size: 0.78rem;
  line-height: 1.6;
  color: var(--ink-secondary);
  margin: 0 0 12px;
}

.view-hint {
  padding: 10px 16px 0;
}

.battery-hint {
  font-size: 0.68rem;
  color: var(--ink-secondary);
  opacity: 0.65;
  text-align: center;
  margin-top: 2px;
}

.label-hint {
  font-size: 0.75rem;
  opacity: 0.7;
  margin-left: 4px;
}

/* --- Form: quick date chips, draft notice --- */
.date-chips {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.date-chip {
  padding: 7px 14px;
  min-height: 36px;
  border-radius: 18px;
  border: 1px solid var(--line-color);
  background: transparent;
  color: var(--ink-secondary);
  font-family: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.15s;
}

.date-chip.active {
  border-color: var(--accent-gold);
  background: rgba(207, 170, 110, 0.14);
  color: var(--ink-primary);
  font-weight: 700;
}

.checkbox-group {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}

.checkbox-group input[type="checkbox"] {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.checkbox-group label {
  margin: 0;
  font-size: 0.85rem;
  cursor: pointer;
}

.draft-notice {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(207, 170, 110, 0.14);
  border: 1px solid var(--accent-gold);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 16px;
  font-size: 0.8rem;
  color: var(--ink-primary);
}

.draft-notice button {
  margin-left: auto;
  border: none;
  background: none;
  color: var(--accent-gold);
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

/* Give every tappable control a comfortable target */
input[type="text"],
input[type="number"],
select,
.btn-primary,
.btn-secondary {
  min-height: 44px;
}

.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

.form-actions .btn-primary {
  flex: 1;
}

/* --- Tag manager: inline edit + delete --- */
.btn-small {
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--line-color);
  background: var(--ink-primary);
  color: var(--bg-paper);
  font-family: inherit;
  font-size: 0.82rem;
  cursor: pointer;
  white-space: nowrap;
}

.btn-small.ghost {
  background: transparent;
  color: var(--ink-secondary);
}

.btn-small.danger {
  background: #c62828;
  border-color: #c62828;
  color: #fff;
}

.form-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.filter-row {
  flex-wrap: wrap;
}

.tag-edit-form,
.tag-delete-form {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  width: 100%;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--line-color);
  font-size: 0.8rem;
  color: var(--ink-secondary);
}

.tag-edit-form .tag-edit-name { flex: 1; min-width: 100px; }
.tag-edit-form input[type="color"] { width: 44px; padding: 2px; }
.tag-delete-form select { flex: 1; min-width: 90px; }

.tag-actions-group {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-left: auto;
}

.btn-order-arrow {
  background: none;
  border: none;
  color: var(--ink-secondary);
  cursor: pointer;
  padding: 6px;
  display: flex;
  align-items: center;
  border-radius: 6px;
}

.btn-order-arrow:hover {
  background: var(--bg-paper-dark);
  color: var(--ink-primary);
}

/* --- Header action button --- */
.header-action {
  border: 1px solid var(--line-color);
  background: transparent;
  color: var(--ink-primary);
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.85rem;
  padding: 6px 12px;
  min-height: 36px;
  cursor: pointer;
}

.header-action {
  margin-left: auto;
}

.list-view-header .btn-icon {
  margin-right: 10px;
}







.grid-age-label {
  width: 22px;
  flex-shrink: 0;
  font-size: 0.62rem;
  color: var(--ink-secondary);
  text-align: right;
  padding-right: 4px;
}


/* Themed via a variable rather than a [data-theme] override: an override would
   out-specify .in-span below and swallow the period washes in dark mode. */

/* A period passing through this month: a wash, not a mark */

/* "You are here" — declared after .in-span so it always wins the background */

/* Something actually happened this month */





/* --- Time capsule --- */
.time-capsule-content {
  text-align: center;
  padding: 40px 20px 28px;
  position: relative;
}

.capsule-close {
  position: absolute;
  top: 12px;
  right: 18px;
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  color: var(--ink-secondary);
}

.capsule-eyebrow {
  color: var(--accent-gold);
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 2px;
  margin-bottom: 10px;
}

.capsule-title {
  margin: 0 0 20px;
  font-family: var(--font-heading);
  font-size: 1.7rem;
}

/* The capsule reuses the standard event card, minus the timeline gutter */
.capsule-card-host .event-item {
  padding: 0;
  text-align: left;
  animation: none;
  opacity: 1;
  transform: none;
}

.capsule-card-host .event-marker { display: none; }

.capsule-next {
  margin-top: 26px;
  border-radius: 20px;
  padding: 12px 24px;
}

.version-info {
  text-align: center;
  margin-top: 30px;
  color: var(--ink-secondary);
  opacity: 0.7;
  font-size: 0.75rem;
}

/* --- Dark mode for the v2 pieces --- */
[data-theme="dark"] .tab-bar,
[data-theme="dark"] .btn-today,


/* --ink-primary flips to near-white in dark mode, so a white glyph on it vanishes */
[data-theme="dark"] .fab {
  color: #1c1c1c;
}

[data-theme="dark"] .btn-clear-search {
  background: #333;
  color: #ccc;
}

[data-theme="dark"] .btn-small {
  background: #d9cfc2;
  color: #1c1c1c;
  border-color: #444;
}

[data-theme="dark"] .btn-small.ghost {
  background: transparent;
  color: #bbb;
}

[data-theme="dark"] .event-card mark {
  background: rgba(230, 180, 92, 0.3);
  color: #ffe6b8;
}

[data-theme="dark"] .btn-secondary:hover {
  background: #444;
}
/* === 人生目標 =========================================================== */

/* Five tabs now — tighten so 375px phones don't wrap the labels */
.tab-btn { padding: 8px 2px; font-size: 0.66rem; }
.tab-btn span { font-size: 1.15rem; }

.goals-summary {
  padding: 12px 18px 0;
  font-size: 0.8rem;
  color: var(--ink-secondary);
}

.gs-num {
  font-size: 1.05rem;
  color: var(--ink-primary);
  font-variant-numeric: lining-nums;
}

.goals-content {
  flex: 1;
  overflow-y: auto;
  padding: 4px 14px calc(80px + env(safe-area-inset-bottom));
}

.goal-group-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin: 22px 2px 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--line-color);
}

.gg-label {
  font-family: var(--font-heading);
  font-size: 1.05rem;
  color: var(--ink-primary);
  font-variant-numeric: lining-nums;
}

.gg-remaining {
  font-size: 0.72rem;
  color: var(--ink-secondary);
}

.goal-group-head.is-done .gg-label { opacity: 0.6; }

.goal-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 11px 12px;
  margin-bottom: 8px;
  border-left: 3px solid var(--rail);
  border-radius: 6px;
  background: var(--bg-paper-dark);
}

.goal-row.is-done { opacity: 0.55; }
.goal-row.is-overdue { border-left-color: #c0392b; }

.goal-check {
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--rail);
  font-size: 1.1rem;
  cursor: pointer;
  transition: background 0.15s;
}

.goal-check:hover { background: rgba(0, 0, 0, 0.06); }

.goal-main { flex: 1; min-width: 0; cursor: default; }

.goal-title {
  font-size: 0.95rem;
  color: var(--ink-primary);
  margin-bottom: 3px;
}

.goal-row.is-done .goal-title { text-decoration: line-through; }

.goal-meta {
  font-size: 0.72rem;
  color: var(--ink-secondary);
}

.goal-tag {
  display: inline-block;
  margin-right: 6px;
  padding: 1px 7px;
  border-radius: 9px;
  border: 1px solid var(--rail);
  color: var(--rail);
  font-size: 0.66rem;
}

.goal-desc {
  margin-top: 5px;
  font-size: 0.78rem;
  line-height: 1.55;
  color: var(--ink-secondary);
  opacity: 0.9;
}

.goal-edit {
  flex-shrink: 0;
  border: none;
  background: none;
  font-size: 0.85rem;
  cursor: pointer;
  opacity: 0.5;
}

.goal-edit:hover { opacity: 1; }

.goal-deadline-preview {
  margin: -6px 0 16px;
  font-size: 0.76rem;
  color: var(--accent-gold);
  font-variant-numeric: lining-nums;
}

/* --- Timeline tail: what is still ahead --- */
.timeline-upcoming-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin: 32px 0 12px;
  padding: 10px 4px 6px;
  border-top: 1px dashed var(--line-color);
  border-bottom: 1px solid var(--line-color);
  font-family: var(--font-heading);
  font-size: 1.15rem;
  color: var(--ink-primary);
}

.timeline-upcoming-head small {
  font-family: var(--font-body);
  font-size: 0.7rem;
  color: var(--ink-secondary);
}

.upcoming-row {
  padding: 10px 12px;
  margin-bottom: 8px;
  border-left: 3px dashed var(--rail);
  border-radius: 6px;
  background: var(--bg-paper-dark);
  cursor: pointer;
  opacity: 0.85;
  transition: opacity 0.15s;
}

.upcoming-row:hover { opacity: 1; }
.upcoming-row.is-overdue { border-left-color: #c0392b; }

.up-title {
  font-size: 0.9rem;
  color: var(--ink-primary);
}

.up-meta {
  margin-top: 3px;
  font-size: 0.7rem;
  color: var(--ink-secondary);
  font-variant-numeric: lining-nums;
}

/* Quiet, secondary escape hatch — present but never competing with the list */
.btn-link-quiet {
  width: 100%;
  margin-top: 16px;
  padding: 8px;
  border: none;
  background: none;
  font-family: inherit;
  font-size: 0.76rem;
  color: var(--ink-secondary);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
  opacity: 0.7;
}

.btn-link-quiet:hover { opacity: 1; }

/* === 主畫面提示橫幅 ==================================================== */

/* Anniversary — an invitation, so it reads warm rather than urgent */
.anniversary-banner {
  display: flex;
  align-items: baseline;
  gap: 8px;
  width: calc(100% - 32px);
  margin: 0 16px 10px;
  padding: 10px 12px;
  border: none;
  border-left: 3px solid var(--accent-gold);
  border-radius: 6px;
  background: color-mix(in srgb, var(--accent-gold) 10%, var(--bg-paper));
  font-family: inherit;
  text-align: left;
  cursor: pointer;
}

.ab-when {
  flex-shrink: 0;
  font-family: var(--font-heading);
  font-size: 0.9rem;
  color: var(--accent-gold);
  font-variant-numeric: lining-nums;
}

.ab-title {
  flex: 1;
  min-width: 0;
  font-size: 0.82rem;
  color: var(--ink-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ab-go {
  flex-shrink: 0;
  font-size: 0.74rem;
  color: var(--ink-secondary);
}

@supports not (background: color-mix(in srgb, red 8%, transparent)) {
  .anniversary-banner { background: var(--bg-paper-dark); }
}
