/* ===================================================================
   栞びより — style.css
   Based on MyWeb.pen design tokens & DESIGN.md (MUJI design system)
   3-pane dashboard (Linear / Notion Calendar inspired)
   =================================================================== */

/* -------------------------------------------------------------------
   1. Design Tokens (extracted from MyWeb.pen variables + DESIGN.md)
   ------------------------------------------------------------------- */
:root {
  /* Colors — neutrals */
  --bg: #ffffff;
  --bg-secondary: #f5f5f5;
  --surface: #ffffff;
  --black: #000000;
  --white: #ffffff;

  --text-primary: #3c3c43;
  --text-secondary: #6d6d72;
  --text-tertiary: #76767b;
  --text-disabled: #9d9da0;
  --text-muted: #6d6d72;

  --border: #d8d8d9;
  --border-light: #ebebec;

  --gray-100: #f5f5f5;
  --gray-200: #ebebec;
  --gray-300: #d8d8d9;
  --gray-400: #c4c4c6;
  --gray-500: #9d9da0;
  --gray-600: #76767b;
  --gray-700: #6d6d72;
  --gray-800: #3c3c43;

  /* Brand & semantic */
  --muji-red: #7f0019;
  --red: #dd0c14;
  --danger: #dd0c14;
  --today-indicator: #dd0c14;
  --kinari: #f4eede;
  --beige: #e0ceaa;

  /* Section accents */
  --calendar-green: #4a9d5b;
  --schedule-teal: #2a9d8f;
  --task-purple: #7c5cbf;
  --diary-orange: #d4813b;
  --map-blue: #3b82d4;

  /* Tints (lighter shades for event backgrounds) */
  --calendar-green-tint: #ecf5ee;
  --schedule-teal-tint: #e8f6f5;
  --task-purple-tint: #f0ebf9;
  --diary-orange-tint: #faf0e6;
  --map-blue-tint: #e8f0fa;

  /* Light tones (per HANDOFF.md — for overview cards) */
  --task-light: #f0ecf8;
  --diary-light: #fbf1e8;
  --schedule-light: #e8f4f2;
  --calendar-light: #edf5ef;
  --map-blue-light: #e8eff8;

  /* Spacing */
  --space-xxxxs: 4px;
  --space-xxxs: 8px;
  --space-xxs: 12px;
  --space-xs: 16px;
  --space-s: 20px;
  --space-sm: 24px;
  --space-m: 32px;
  --space-ml: 40px;
  --space-l: 48px;
  --space-xl: 56px;
  --space-xxl: 64px;
  --space-xxxl: 80px;
  /* legacy aliases (used in inline styles) */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-7: 32px;
  --space-8: 40px;

  /* Radius */
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;

  /* Borders */
  --hairline: 0.5px;
  --hairline-color: var(--border-light);

  /* Shadows */
  --shadow-1: 0 1px 2px rgba(0,0,0,0.06);
  --shadow-2: 0 2px 8px rgba(0,0,0,0.08);
  --shadow-3: 0 8px 24px rgba(0,0,0,0.10);

  /* Typography */
  --font-sans: "Helvetica Neue", Arial, "Inter", "Noto Sans JP", "Hiragino Kaku Gothic ProN", Meiryo, sans-serif;
  --font-mincho: "Shippori Mincho", "Yu Mincho", "Hiragino Mincho ProN", serif;

  /* Layout */
  --left-pane-w: 220px;
  --right-pane-w: 320px;
  --header-h: 52px;
  --tabbar-h: 56px;

  /* Motion */
  --ease-out: cubic-bezier(0.2, 0.7, 0.3, 1);
  --t-fast: 150ms;
  --t-mid: 200ms;
  --t-slow: 250ms;
}

:root[data-theme="dark"] {
  --bg: #171717;
  --bg-secondary: #202020;
  --surface: #242424;
  --text-primary: #f2f2f2;
  --text-secondary: #c7c7c7;
  --text-tertiary: #a5a5a5;
  --text-disabled: #707070;
  --text-muted: #a5a5a5;
  --border: #454545;
  --border-light: #333333;
  --gray-100: #202020;
  --gray-200: #303030;
  --gray-300: #454545;
  --calendar-green-tint: #213126;
  --schedule-teal-tint: #17312e;
  --task-purple-tint: #2a2440;
  --diary-orange-tint: #3b2a1e;
  --map-blue-tint: #1d2c3f;
}

/* -------------------------------------------------------------------
   2. Reset + Base
   ------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
a { color: inherit; text-decoration: none; }
ul, ol { margin: 0; padding: 0; list-style: none; }
h1, h2, h3, h4, h5, h6 { margin: 0; font-weight: 700; line-height: 1.4; color: var(--text-primary); }
input, textarea, select { font: inherit; color: inherit; }
hr { margin: 0; border: 0; border-top: var(--hairline) solid var(--hairline-color); }

/* -------------------------------------------------------------------
   3. Utilities
   ------------------------------------------------------------------- */
.hidden { display: none !important; }
.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.align-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }
.gap-4 { gap: 4px; }
.gap-6 { gap: 6px; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.ml-auto { margin-left: auto; }
.mt-12 { margin-top: 12px; }
.m-tb-12 { margin: 12px 0; }
.pb-6 { padding-bottom: 6px; }
.overflow-auto { overflow: auto; }
.pos-relative { position: relative; }
.w-full { width: 100%; }
.cursor-pointer { cursor: pointer; }
.muted { color: var(--text-secondary); }

/* -------------------------------------------------------------------
   4. Loading Screen
   ------------------------------------------------------------------- */
#loading-screen {
  position: fixed; inset: 0;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  z-index: 9999;
  transition: opacity var(--t-slow) var(--ease-out);
}
#loading-screen.hidden { opacity: 0; pointer-events: none; }
.loading-content { text-align: center; }
.loading-logo {
  font-family: var(--font-mincho);
  font-size: 28px; font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 16px;
}
.loading-bar {
  width: 240px; height: 2px;
  background: var(--border-light);
  border-radius: 1px;
  overflow: hidden;
  margin: 0 auto;
}
.loading-progress {
  height: 100%; width: 30%;
  background: var(--text-primary);
  animation: loadingSlide 1.4s var(--ease-out) infinite;
}
@keyframes loadingSlide {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(400%); }
}

/* -------------------------------------------------------------------
   5. App Shell — 3-pane grid
   ------------------------------------------------------------------- */
.app-shell {
  display: grid;
  grid-template-columns: var(--left-pane-w) 1fr var(--right-pane-w);
  grid-template-areas: "left center right";
  height: 100vh;
  width: 100vw;
  background: var(--bg);
  transition: grid-template-columns var(--t-mid) var(--ease-out);
}
body[data-rp-state="closed"] .app-shell {
  grid-template-columns: var(--left-pane-w) 1fr 0;
}
body[data-rp-state="closed"] .right-pane {
  width: 0; overflow: hidden;
  border-left: 0;
}
.left-pane { grid-area: left; }
.center-pane { grid-area: center; min-width: 0; }
.right-pane { grid-area: right; }

/* -------------------------------------------------------------------
   6. Left Pane
   ------------------------------------------------------------------- */
.left-pane {
  display: flex; flex-direction: column;
  background: var(--bg);
  border-right: var(--hairline) solid var(--hairline-color);
  height: 100vh;
  overflow-y: hidden;
}
.lp-logo {
  display: flex; align-items: center; gap: 8px;
  padding: 20px 20px 16px;
}
.lp-logo-dot {
  width: 24px; height: 24px;
  border-radius: 50%;
  display: block;
  object-fit: cover;
  flex-shrink: 0;
}
.lp-logo-text {
  font-family: "Noto Sans JP", var(--font-sans);
  font-size: 16px; font-weight: 700;
  color: var(--text-primary);
}

.lp-nav {
  display: flex; flex-direction: column; gap: 2px;
  padding: 0 12px;
}
.lp-nav-label {
  font-size: 11px; font-weight: 700;
  color: var(--text-tertiary);
  padding: 0 8px 8px;
}
.lp-nav-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 13px; font-weight: 500;
  text-align: left;
  width: 100%;
  transition: background-color var(--t-fast) var(--ease-out), color var(--t-fast) var(--ease-out);
}
.lp-nav-item:hover { background: var(--bg-secondary); color: var(--text-primary); }
.lp-nav-item.active { background: var(--bg-secondary); color: var(--text-primary); }
.lp-nav-item[data-target="calendar"].active { color: var(--calendar-green); }
.lp-nav-item[data-target="schedule"].active { color: var(--schedule-teal); }
.lp-nav-item[data-target="tasks"].active    { color: var(--task-purple); }
.lp-nav-item[data-target="diary"].active    { color: var(--diary-orange); }
.lp-nav-item[data-target="map"].active      { color: var(--map-blue); }
.lp-nav-icon {
  width: 16px; height: 16px;
  flex-shrink: 0;
}
.lp-nav-text { flex: 1; }
.lp-nav-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}
.lp-nav-dot[data-dot="calendar"] { background: var(--calendar-green); }
.lp-nav-dot[data-dot="schedule"] { background: var(--schedule-teal); }
.lp-nav-dot[data-dot="tasks"]    { background: var(--task-purple); }
.lp-nav-dot[data-dot="diary"]    { background: var(--diary-orange); }
.lp-nav-dot[data-dot="map"]      { background: var(--map-blue); }

.lp-divider {
  border-top: var(--hairline) solid var(--hairline-color);
  margin: 16px 0;
}

.lp-overview, .lp-upcoming {
  padding: 0 16px;
  display: flex; flex-direction: column; gap: 12px;
}
.lp-section-label {
  font-size: 11px; font-weight: 700;
  color: var(--text-tertiary);
}
.lp-progress-row {
  display: flex; flex-direction: column; gap: 6px;
}
.lp-progress-head {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: 12px;
}
.lp-progress-label { color: var(--text-secondary); }
.lp-progress-value { color: var(--text-primary); font-weight: 600; font-variant-numeric: tabular-nums; }
.lp-progress-bar {
  height: 4px;
  background: var(--border-light);
  border-radius: 2px;
  overflow: hidden;
}
.lp-progress-fill {
  height: 100%;
  width: calc(var(--p, 0) * 100%);
  background: var(--task-purple);
  transition: width var(--t-mid) var(--ease-out);
}
.lp-progress-fill.diary { background: var(--diary-orange); }

.lp-upcoming-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex; flex-direction: column; gap: 8px;
}
.lp-upcoming-item {
  display: flex; align-items: baseline; gap: 8px;
  font-size: 12px;
  min-width: 0;
}
.lp-upcoming-date {
  color: var(--text-secondary);
  font-weight: 700;
  width: 34px;
  flex-shrink: 0;
}
.lp-upcoming-time {
  color: var(--text-tertiary);
  font-variant-numeric: tabular-nums;
  width: 38px;
  flex-shrink: 0;
}
.lp-upcoming-title {
  color: var(--text-primary);
  min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.lp-upcoming-empty {
  font-size: 12px;
  color: var(--text-disabled);
}
.lp-spacer { flex: 1; min-height: 0; }

.lp-user-row {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 16px;
  position: relative;
}
.lp-icon-btn {
  width: 28px; height: 28px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  transition: background-color var(--t-fast) var(--ease-out);
}
.lp-icon-btn:hover { background: var(--bg-secondary); color: var(--text-primary); }
.lp-icon-btn svg { width: 16px; height: 16px; }

.lp-login-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  background: var(--text-primary);
  color: var(--white);
  font-size: 12px; font-weight: 700;
  transition: opacity var(--t-fast) var(--ease-out);
}
.lp-login-btn:hover { opacity: 0.85; }
.lp-login-btn svg { width: 12px; height: 12px; }

.lp-user {
  display: flex; align-items: center; gap: 8px;
  flex: 1;
  position: relative;
}
.lp-user-avatar {
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--beige);
  object-fit: cover;
  cursor: pointer;
}
.lp-user-name {
  font-size: 13px;
  color: var(--text-primary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* User dropdown */
.user-menu {
  display: none;
  position: absolute;
  bottom: calc(100% + 4px);
  left: 0; right: 0;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-2);
  padding: 4px;
  z-index: 100;
}
.user-menu.show { display: block; }
.user-menu-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px;
  font-size: 13px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-primary);
}
.user-menu-item:hover { background: var(--bg-secondary); }
.user-menu-item svg { color: var(--text-secondary); }

/* -------------------------------------------------------------------
   7. Center Pane
   ------------------------------------------------------------------- */
.center-pane {
  display: flex; flex-direction: column;
  background: var(--bg-secondary);
  height: 100vh;
  overflow: hidden;
}
.cp-header {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 24px;
  background: var(--bg);
  border-bottom: var(--hairline) solid var(--hairline-color);
  min-height: var(--header-h);
  flex-shrink: 0;
}
.cp-header-title {
  font-size: 15px; font-weight: 700;
  color: var(--text-primary);
}
.cp-header-spacer { flex: 1; }
.cp-tabs {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.cp-tab {
  padding: 4px 12px;
  font-size: 12px; font-weight: 500;
  color: var(--text-secondary);
  background: transparent;
  border-right: 1px solid var(--border);
  transition: background-color var(--t-fast) var(--ease-out), color var(--t-fast) var(--ease-out);
}
.cp-tab:last-child { border-right: 0; }
.cp-tab:hover { background: var(--bg-secondary); }
.cp-tab.active {
  background: var(--text-primary);
  color: var(--white);
}
.cp-month-nav { display: inline-flex; align-items: center; gap: 8px; }
.cp-month-nav button {
  width: 24px; height: 24px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
}
.cp-month-nav button:hover { background: var(--bg-secondary); color: var(--text-primary); }
.cp-month-nav .cp-month-title {
  font-size: 14px; font-weight: 700; color: var(--text-primary);
  min-width: 110px; text-align: center;
}
.cp-today-btn {
  padding: 4px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 12px; font-weight: 500;
  color: var(--text-primary);
  background: var(--bg);
  transition: background-color var(--t-fast) var(--ease-out);
}
.cp-today-btn:hover { background: var(--bg-secondary); }
.cp-action-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  background: var(--text-primary);
  color: var(--white);
  font-size: 12px; font-weight: 700;
  transition: opacity var(--t-fast) var(--ease-out);
}
.cp-action-btn:hover { opacity: 0.85; }
.cp-action-btn svg { width: 12px; height: 12px; }

.cp-body {
  flex: 1;
  overflow: auto;
  position: relative;
}
.cp-section {
  padding: 24px;
  min-height: 100%;
}
.cp-section[hidden] { display: none; }
.cp-section[data-section="map"] {
  padding: 0;
  height: 100%;
}

/* -------------------------------------------------------------------
   8. Right Pane
   ------------------------------------------------------------------- */
.right-pane {
  display: flex; flex-direction: column;
  background: var(--bg);
  border-left: var(--hairline) solid var(--hairline-color);
  height: 100vh;
  overflow-y: auto;
  width: var(--right-pane-w);
  transition: width var(--t-mid) var(--ease-out);
}
.rp-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 20px;
  border-bottom: var(--hairline) solid var(--hairline-color);
  flex-shrink: 0;
}
.rp-title {
  font-size: 14px; font-weight: 700;
  color: var(--text-primary);
}
.rp-close {
  width: 28px; height: 28px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  transition: background-color var(--t-fast) var(--ease-out);
}
.rp-close:hover { background: var(--bg-secondary); color: var(--text-primary); }
.rp-close svg { width: 18px; height: 18px; }
.rp-body {
  padding: 16px 20px;
  display: flex; flex-direction: column; gap: 20px;
  flex: 1;
}
.rp-section {
  display: flex; flex-direction: column; gap: 10px;
}
.rp-section-label {
  font-size: 11px; font-weight: 700;
  color: var(--text-tertiary);
}
.rp-divider {
  border-top: var(--hairline) solid var(--hairline-color);
}
.rp-task-title {
  font-size: 14px; font-weight: 700;
  color: var(--text-primary);
}
.rp-meta-row {
  display: flex; gap: 12px; align-items: baseline;
  font-size: 12px;
}
.rp-meta-key {
  width: 64px;
  color: var(--text-tertiary);
  flex-shrink: 0;
}
.rp-meta-val {
  color: var(--text-primary);
  flex: 1;
  word-break: break-all;
}
.rp-empty {
  padding: 24px 16px;
  text-align: center;
  color: var(--text-tertiary);
  font-size: 12px;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  border: 1px dashed var(--border-light);
}
.rp-stat-row {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: 12px;
  padding: 6px 0;
}
.rp-stat-key { color: var(--text-secondary); }
.rp-stat-val { color: var(--text-primary); font-weight: 600; font-variant-numeric: tabular-nums; }

/* -------------------------------------------------------------------
   9. Unified Card Component
   ------------------------------------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 16px;
}
.card-row {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  background: var(--surface);
  border: 1px solid var(--border-light);
  transition: background-color var(--t-fast) var(--ease-out), border-color var(--t-fast) var(--ease-out);
  cursor: pointer;
}
.card-row:hover {
  background: var(--bg-secondary);
  border-color: var(--border);
}
.card-icon {
  width: 18px; height: 18px;
  flex-shrink: 0;
  margin-top: 2px;
}
.card-body {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; gap: 4px;
}
.card-title {
  font-size: 13px; font-weight: 600;
  color: var(--text-primary);
  line-height: 1.4;
}
.card-desc {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.5;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.card-meta {
  display: flex; gap: 8px; align-items: center;
  font-size: 11px;
  color: var(--text-tertiary);
}
.card-tag {
  padding: 1px 6px;
  border-radius: 3px;
  background: var(--bg-secondary);
  font-size: 10px;
  color: var(--text-secondary);
}

/* -------------------------------------------------------------------
   10. Calendar Section
   ------------------------------------------------------------------- */
.cal-grid-wrap {
  display: flex; flex-direction: column;
  background: var(--bg);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-light);
  overflow: hidden;
  height: 100%;
}
.cal-week-header {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  background: var(--bg);
  border-bottom: var(--hairline) solid var(--hairline-color);
}
.cal-week-header > div {
  padding: 8px 0;
  text-align: center;
  font-size: 11px; font-weight: 600;
  color: var(--text-tertiary);
}
.cal-week-header > div.sun { color: var(--red); }
.cal-week-header > div.sat { color: var(--map-blue); }
.cal-body {
  flex: 1;
  display: grid;
  grid-template-rows: repeat(6, 1fr);
}
.cal-week-row {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  border-bottom: var(--hairline) solid var(--hairline-color);
  min-width: 0;
}
.cal-week-row:last-child { border-bottom: 0; }
.cal-cell {
  position: relative;
  padding: 6px 8px;
  border-right: var(--hairline) solid var(--hairline-color);
  display: flex; flex-direction: column; gap: 4px;
  min-height: 88px;
  min-width: 0;
  cursor: pointer;
  transition: background-color var(--t-fast) var(--ease-out);
}
.cal-cell:last-child { border-right: 0; }
.cal-cell:hover { background: var(--bg-secondary); }
.cal-cell.outside { background: #fafafa; }
.cal-cell.outside .cal-date-num { color: var(--text-disabled); }
.cal-cell.selected {
  background: var(--bg-secondary);
  outline: 1.5px solid var(--text-primary);
  outline-offset: -1.5px;
}
.cal-date-num {
  font-size: 13px; font-weight: 500;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}
.cal-cell.today .cal-date-num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--text-primary);
  color: var(--white);
  font-weight: 700;
}
.cal-events {
  display: flex; flex-direction: column; gap: 2px;
  min-width: 0;
}
.cal-event {
  font-size: 10px;
  padding: 1px 4px;
  border-radius: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  line-height: 1.4;
  min-width: 0;
  max-width: 100%;
}
.cal-event.event { background: var(--calendar-green-tint); color: var(--calendar-green); }
.cal-event.task  { background: var(--task-purple-tint); color: var(--task-purple); }
.cal-event.diary { background: var(--diary-orange-tint); color: var(--diary-orange); }
.cal-event.map   { background: var(--map-blue-tint); color: var(--map-blue); }
.cal-event[style*="--event-color"] {
  background: var(--event-bg);
  color: var(--event-color);
}
.cal-meta-chip {
  text-align: center;
  font-weight: 700;
}

.cal-dots {
  position: absolute;
  bottom: 4px; right: 6px;
  display: flex; gap: 2px;
}
.cal-dot {
  width: 4px; height: 4px;
  border-radius: 50%;
}
.cal-dot.event { background: var(--calendar-green); }
.cal-dot.task  { background: var(--task-purple); }
.cal-dot.diary { background: var(--diary-orange); }
.cal-dot.map   { background: var(--map-blue); }

/* -------------------------------------------------------------------
   11. Schedule Section — Pencil-style vertical day view
   ------------------------------------------------------------------- */
.legacy-schedule-host { display: none !important; }

.sched-stage {
  display: flex; flex-direction: column;
  background: var(--bg);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  overflow: hidden;
  height: 100%;
}
.sched-date-strip {
  display: flex; gap: 4px;
  padding: 12px 8px;
  border-bottom: var(--hairline) solid var(--hairline-color);
  background: var(--bg);
  overflow-x: hidden;
  flex-shrink: 0;
}
.sched-date {
  display: inline-flex; flex-direction: column; align-items: center;
  flex: 1; min-width: 0; padding: 6px 4px;
  border-radius: var(--radius-sm);
  font-size: 12px; font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background-color var(--t-fast) var(--ease-out), color var(--t-fast) var(--ease-out);
}
.sched-date:hover { background: var(--bg-secondary); }
.sched-date .sched-date-dow {
  font-size: 10px;
  color: var(--text-tertiary);
}
.sched-date.active {
  background: var(--text-primary);
  color: var(--white);
}
.sched-date.active .sched-date-dow { color: var(--white); opacity: 0.85; }
.sched-date.is-today .sched-date-day {
  position: relative;
  color: var(--schedule-teal);
  font-weight: 700;
}
.sched-date.is-today .sched-date-day::after {
  content: '';
  position: absolute;
  left: 50%; bottom: -5px;
  transform: translateX(-50%);
  width: 4px; height: 4px;
  border-radius: 50%;
  background: var(--schedule-teal);
}
.sched-date.is-today.active .sched-date-day { color: var(--white); }
.sched-date.is-today.active .sched-date-day::after { background: var(--white); }

.sched-day {
  flex: 1;
  position: relative;
  display: grid;
  grid-template-columns: 56px 1fr;
  overflow-y: auto;
}
.sched-hours {
  display: flex; flex-direction: column;
  border-right: var(--hairline) solid var(--hairline-color);
  background: var(--bg);
}
.sched-hour-row {
  height: 48px;
  padding: 4px 8px 0 0;
  font-size: 10px;
  color: var(--text-tertiary);
  text-align: right;
  border-bottom: var(--hairline) solid var(--hairline-color);
  font-variant-numeric: tabular-nums;
}
.sched-events {
  position: relative;
  background: var(--bg);
  background-image: linear-gradient(to bottom, var(--border-light) 1px, transparent 1px);
  background-size: 100% 48px;
}
.sched-event {
  position: absolute;
  left: 8px; right: 8px;
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-size: 12px; font-weight: 500;
  color: var(--white);
  background: var(--schedule-teal);
  border-left: 3px solid rgba(0,0,0,0.18);
  box-shadow: var(--shadow-1);
  cursor: pointer;
  overflow: hidden;
  transition: opacity var(--t-fast) var(--ease-out);
}
.sched-event:hover { opacity: 0.9; }
.sched-event.event-color-1  { background: #a4bdfc; color: var(--text-primary); }
.sched-event.event-color-2  { background: #7ae619; color: var(--text-primary); }
.sched-event.event-color-3  { background: #dbadff; color: var(--text-primary); }
.sched-event.event-color-4  { background: #ff887c; color: var(--white); }
.sched-event.event-color-5  { background: #fbd75b; color: var(--text-primary); }
.sched-event.event-color-6  { background: #ffb878; color: var(--text-primary); }
.sched-event.event-color-7  { background: #46d6db; color: var(--text-primary); }
.sched-event.event-color-8  { background: #e1e1e1; color: var(--text-primary); }
.sched-event.event-color-9  { background: #5484ed; color: var(--white); }
.sched-event.event-color-10 { background: var(--calendar-green); color: var(--white); }
.sched-event.event-color-11 { background: var(--red); color: var(--white); }
.sched-event-time {
  font-size: 10px; opacity: 0.92;
  font-variant-numeric: tabular-nums;
  margin-bottom: 2px;
}
.sched-now-line {
  position: absolute;
  left: 0; right: 0;
  height: 1.5px;
  background: var(--red);
  z-index: 2;
  pointer-events: none;
}
.sched-now-line::before {
  content: '';
  position: absolute;
  left: -4px; top: -3.5px;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--red);
}
.sched-countdown-banner {
  position: sticky;
  top: 8px;
  z-index: 3;
  margin: 8px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  background: var(--schedule-teal-tint);
  color: var(--schedule-teal);
  border: 1px solid color-mix(in srgb, var(--schedule-teal) 25%, transparent);
  font-size: 12px;
  font-weight: 700;
  width: fit-content;
}
.sched-travel-block {
  position: absolute;
  left: 12px;
  right: 12px;
  border-radius: var(--radius-sm);
  background: repeating-linear-gradient(135deg, var(--gray-200), var(--gray-200) 6px, var(--gray-100) 6px, var(--gray-100) 12px);
  color: var(--text-tertiary);
  border: 1px dashed var(--border);
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  padding: 0 8px;
}

body.task-density-compact .task-list li {
  padding-top: 4px;
  padding-bottom: 4px;
  min-height: 32px;
}

body.diary-grid-layout .diary-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}
body.diary-grid-layout .diary-item {
  margin: 0;
  height: 100%;
}
body[data-diary-font-size="small"] #diary-text,
body[data-diary-font-size="small"] .diary-content { font-size: 13px; }
body[data-diary-font-size="medium"] #diary-text,
body[data-diary-font-size="medium"] .diary-content { font-size: 15px; }
body[data-diary-font-size="large"] #diary-text,
body[data-diary-font-size="large"] .diary-content { font-size: 17px; }

/* Legacy preserve */
.wrap-today { background: transparent; }
.wrap-today .wrap {
  background: var(--bg);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 16px;
}
.wrap-today .header { font-size: 14px; }
.wrap-today .brand.schedule-brand {
  font-weight: 700;
  font-size: 14px;
  color: var(--text-primary);
}
.controls .compact-date {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px 6px;
  font-size: 13px;
  background: var(--bg);
  color: var(--text-primary);
}
.compact-date:focus {
  outline: 0;
  border-color: var(--text-primary);
}
.date-input-wrapper {
  display: inline-flex; align-items: center; gap: 6px;
}
.spin-inner {
  display: inline-flex; align-items: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  overflow: hidden;
}
.spin-inner .compact-date { border: 0; padding: 4px; }
.btn-spinner-inline {
  width: 20px; height: 22px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 9px;
  color: var(--text-secondary);
  background: var(--bg);
  border-left: 1px solid var(--border);
  transition: background-color var(--t-fast) var(--ease-out);
}
.btn-spinner-inline:hover { background: var(--bg-secondary); }

.timeline-outer {
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--bg);
  margin-top: 12px;
}
.time-header {
  border-bottom: var(--hairline) solid var(--hairline-color);
  background: var(--bg-secondary);
  padding-bottom: 6px;
}
.time-header .hour {
  flex: 0 0 auto;
  min-width: 60px;
  font-size: 11px;
  color: var(--text-tertiary);
  text-align: center;
}
.timeline-body {
  position: relative;
  min-height: 360px;
}
.timeline-grid { position: relative; min-height: 360px; }
.timeline-row {
  position: relative;
  height: 48px;
  border-bottom: var(--hairline) solid var(--hairline-color);
}
.timeline-row .today-event {
  position: absolute;
  top: 4px; height: 40px;
  background: var(--schedule-teal-tint);
  color: var(--schedule-teal);
  border-left: 3px solid var(--schedule-teal);
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  font-size: 11px;
  overflow: hidden;
  white-space: nowrap; text-overflow: ellipsis;
}

/* -------------------------------------------------------------------
   12. Tasks Section
   ------------------------------------------------------------------- */
.task-tabs {
  display: inline-flex;
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  padding: 2px;
  margin-bottom: 16px;
}
.task-tab {
  padding: 6px 14px;
  font-size: 13px; font-weight: 500;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  transition: background-color var(--t-fast) var(--ease-out), color var(--t-fast) var(--ease-out);
}
.task-tab:hover { color: var(--text-primary); }
.task-tab.active {
  background: var(--bg);
  color: var(--task-purple);
  box-shadow: var(--shadow-1);
}

.task-tab-title {
  font-size: 14px; font-weight: 700;
  color: var(--text-primary);
  margin: 0 0 12px;
}

.task-list-wrap {
  background: var(--bg);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 8px;
  margin-bottom: 16px;
}
.task-list { display: flex; flex-direction: column; gap: 4px; }
.task-list li {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg);
  transition: background-color var(--t-fast) var(--ease-out);
}
.task-list li:hover { background: var(--bg-secondary); }
.task-list input[type="checkbox"] {
  appearance: none;
  width: 16px; height: 16px;
  border: 1.5px solid var(--border);
  border-radius: 3px;
  background: var(--bg);
  position: relative;
  cursor: pointer;
  flex-shrink: 0;
  transition: border-color var(--t-fast) var(--ease-out), background-color var(--t-fast) var(--ease-out);
}
.task-list input[type="checkbox"]:hover { border-color: var(--task-purple); }
.task-list input[type="checkbox"]:checked {
  background: var(--task-purple);
  border-color: var(--task-purple);
}
.task-list input[type="checkbox"]:checked::after {
  content: ""; position: absolute;
  left: 4px; top: 1px;
  width: 4px; height: 8px;
  border: solid var(--white);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
.task-list li.completed .task-text {
  text-decoration: line-through;
  color: var(--text-disabled);
}
.task-text {
  flex: 1;
  font-size: 13px;
  color: var(--text-primary);
}
.task-due {
  font-size: 11px;
  color: var(--text-tertiary);
  padding: 2px 6px;
  border-radius: 3px;
  background: var(--bg-secondary);
}
.task-due.today { background: #e8f0fa; color: var(--map-blue); }
.task-due.overdue { background: #fbe8ea; color: var(--red); }
.task-drag-handle {
  color: var(--text-disabled);
  cursor: grab;
  font-size: 16px;
  padding: 0 4px 0 0;
  user-select: none;
  flex-shrink: 0;
}
.task-drag-handle:active { cursor: grabbing; }
.task-list li.task-dragging { opacity: 0.35; }
.task-drag-placeholder {
  height: 44px;
  border: 2px dashed var(--task-purple);
  border-radius: 8px;
  background: rgba(124, 92, 191, 0.08);
  list-style: none;
  margin: 0;
  flex-shrink: 0;
  pointer-events: auto;
}
.task-due-editable { cursor: pointer; }
.task-due-editable:hover {
  background: var(--bg-tertiary, var(--bg-secondary));
  text-decoration: underline;
}
.task-due.no-due {
  color: var(--text-disabled);
  background: transparent;
}
.task-due-input {
  font-size: 11px;
  border: 1px solid var(--task-purple);
  border-radius: 4px;
  padding: 1px 4px;
  background: var(--bg);
  color: var(--text-primary);
  outline: none;
}
.task-due-clear {
  font-size: 12px;
  line-height: 1;
  padding: 1px 5px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: 4px;
  color: var(--text-secondary);
  cursor: pointer;
}
.task-due-clear:hover { background: #fbe8ea; color: var(--red); border-color: var(--red); }

.task-empty { padding: 24px; text-align: center; }
.task-empty-title {
  font-size: 14px; font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 4px;
}
.task-empty-hint {
  font-size: 12px;
  color: var(--text-secondary);
  margin: 0;
}
.task-add-row {
  display: flex; align-items: center; gap: 8px;
  flex-wrap: wrap;
}
.task-add-field { flex: 1; margin-bottom: 0 !important; min-width: 200px; }

/* -------------------------------------------------------------------
   13. Diary Section
   ------------------------------------------------------------------- */
.diary-timeline {
  display: flex; flex-direction: column; gap: 24px;
  max-width: 720px;
}
.diary-composer-date {
  font-size: 13px; font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
}
.diary-composer textarea {
  min-height: 100px;
  width: 100%;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 10px;
  font: inherit;
  resize: vertical;
}
.diary-past-label {
  font-size: 11px; font-weight: 700;
  color: var(--text-tertiary);
}
.diary-list { display: flex; flex-direction: column; gap: 12px; }
.diary-list li,
.diary-entry {
  background: var(--bg);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex; flex-direction: column; gap: 8px;
}
.diary-entry-date {
  font-size: 12px; font-weight: 600;
  color: var(--diary-orange);
}
.diary-entry-content {
  font-size: 14px; line-height: 1.7;
  color: var(--text-primary);
  white-space: pre-wrap;
}

.diary-panel { animation: fadeIn var(--t-fast) var(--ease-out); }
.diary-panel[hidden] { display: none !important; }

.diary-photo-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}
.diary-photo-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.diary-photo-thumb {
  position: relative;
  width: 64px; height: 64px;
}
.diary-photo-thumb img {
  width: 100%; height: 100%;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-light);
}
.diary-photo-remove {
  position: absolute;
  top: -6px; right: -6px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--bg);
  border: 1px solid var(--border-light);
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
}
.diary-item-photos {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}
.diary-item-photos img {
  width: 84px; height: 84px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-light);
}

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

/* -------------------------------------------------------------------
   14. Map Section
   ------------------------------------------------------------------- */
.map-stage {
  position: relative;
  width: 100%;
  height: 100%;
  background: var(--bg-secondary);
  overflow: hidden;
}
.map-header {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 24px;
  background: var(--bg);
  border-bottom: var(--hairline) solid var(--hairline-color);
  height: 48px;
  position: relative;
  z-index: 5;
}
.map-search {
  display: flex; align-items: center; gap: 8px;
  flex: 1;
  max-width: 360px;
  position: relative;
}
.map-search input {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-size: 13px;
  background: var(--bg);
}
.map-search input:focus { outline: 0; border-color: var(--text-primary); }
#search-results-dropdown {
  position: absolute;
  top: 100%; left: 0; right: 0;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  max-height: 300px; overflow-y: auto;
  z-index: 1000;
  margin-top: 4px;
  box-shadow: var(--shadow-2);
}
#search-results-dropdown ul { padding: 0; margin: 0; }
#search-results-dropdown li {
  padding: 8px 12px;
  font-size: 13px;
  cursor: pointer;
  border-bottom: var(--hairline) solid var(--hairline-color);
}
#search-results-dropdown li:hover { background: var(--bg-secondary); }
#search-results-dropdown li:last-child { border-bottom: 0; }

.map-filters { display: flex; gap: 8px; }
.filter-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--bg-secondary);
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
}
.filter-chip input[type="checkbox"] {
  appearance: none;
  width: 12px; height: 12px;
  border: 1.5px solid var(--border);
  border-radius: 2px;
  position: relative;
  cursor: pointer;
}
.filter-chip input[type="checkbox"]:checked {
  background: var(--text-primary);
  border-color: var(--text-primary);
}
.filter-chip input[type="checkbox"]:checked::after {
  content: ""; position: absolute;
  left: 2px; top: -1px;
  width: 3px; height: 7px;
  border: solid var(--white);
  border-width: 0 1.5px 1.5px 0;
  transform: rotate(45deg);
}

#map-and-detail {
  position: absolute;
  top: 48px; left: 0; right: 0; bottom: 0;
}
#map {
  width: 100%; height: 100%;
  background: var(--bg-secondary);
}
/* Floating map detail panel is suppressed; details are routed to right pane / bottom sheet */
#building-detail {
  display: none !important;
}

/* Image grid inside right pane / bottom sheet (used for map place details) */
.rp-body .map-detail-image-grid,
.sheet-body .map-detail-image-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
  margin-top: 12px;
  width: 100%;
}
.rp-body .map-detail-image-item,
.sheet-body .map-detail-image-item {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-light);
  cursor: zoom-in;
  display: block;
}
.map-directions-link {
  color: var(--text-primary);
  text-decoration: underline;
  text-decoration-color: var(--text-tertiary);
  text-underline-offset: 3px;
}
.map-directions-link:hover { text-decoration-color: currentColor; }
/* Prevent overall right pane from horizontal scroll */
.rp-body, .sheet-body { overflow-x: hidden; }
.rp-body img, .sheet-body img { max-width: 100%; height: auto; }

.map-fab {
  position: absolute;
  right: 24px; bottom: 24px;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 12px 18px;
  border-radius: 999px;
  background: var(--text-primary);
  color: var(--white);
  font-size: 13px; font-weight: 700;
  box-shadow: var(--shadow-3);
  z-index: 10;
  transition: transform var(--t-fast) var(--ease-out);
}
.map-fab:hover { transform: translateY(-1px); }
.map-fab svg { width: 16px; height: 16px; }

/* -------------------------------------------------------------------
   15. Form controls (legacy class names retained for JS compat)
   ------------------------------------------------------------------- */
.input_text {
  position: relative;
  margin-bottom: 16px;
}
.input_text label { display: block; position: relative; }
.input_text input,
.input_text textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 12px 6px;
  font-size: 14px;
  background: var(--bg);
  color: var(--text-primary);
  transition: border-color var(--t-fast) var(--ease-out);
}
.input_text input:focus,
.input_text textarea:focus {
  outline: 0;
  border-color: var(--text-primary);
}
.input_text textarea { min-height: 90px; resize: vertical; }
.input_text span {
  position: absolute;
  left: 12px; top: 14px;
  font-size: 14px;
  color: var(--text-tertiary);
  pointer-events: none;
  transition: top var(--t-fast) var(--ease-out), font-size var(--t-fast) var(--ease-out), color var(--t-fast) var(--ease-out);
  background: var(--bg);
  padding: 0 4px;
}
.input_text input:focus + span,
.input_text input:not(:placeholder-shown) + span,
.input_text textarea:focus + span,
.input_text textarea:not(:placeholder-shown) + span {
  top: -7px;
  font-size: 11px;
  color: var(--text-primary);
}

select {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-size: 13px;
  background: var(--bg);
  color: var(--text-primary);
}
select:focus { outline: 0; border-color: var(--text-primary); }

input[type="date"],
input[type="datetime-local"] {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 8px;
  font-size: 13px;
  background: var(--bg);
  color: var(--text-primary);
}
input[type="date"]:focus,
input[type="datetime-local"]:focus { outline: 0; border-color: var(--text-primary); }

.form-row { margin-bottom: 16px; }

/* Color chips */
.color-chip {
  width: 24px; height: 24px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid transparent;
  transition: transform var(--t-fast) var(--ease-out), border-color var(--t-fast) var(--ease-out);
}
.color-chip:hover { transform: scale(1.1); }
.color-chip.active {
  border-color: var(--text-primary);
  transform: scale(1.05);
}

/* File dropzone */
.file-dropzone {
  position: relative;
  border: 1.5px dashed var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  text-align: center;
  cursor: pointer;
  transition: border-color var(--t-fast) var(--ease-out), background-color var(--t-fast) var(--ease-out);
}
.file-dropzone:hover,
.file-dropzone.dragover {
  border-color: var(--text-primary);
  background: var(--bg-secondary);
}
.file-dropzone .file-input {
  position: absolute; inset: 0;
  opacity: 0;
  cursor: pointer;
}
.file-drop-hint {
  font-size: 13px;
  color: var(--text-secondary);
}
.upload-preview {
  display: flex; flex-wrap: wrap; gap: 8px;
  margin-top: 12px;
  justify-content: center;
}
.upload-preview img {
  width: 64px; height: 64px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-light);
}

.place-autocomplete-container {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px;
  background: var(--bg);
}

/* -------------------------------------------------------------------
   16. Buttons
   ------------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 500;
  cursor: pointer;
  transition: background-color var(--t-fast) var(--ease-out), opacity var(--t-fast) var(--ease-out);
  background: var(--bg);
  color: var(--text-primary);
  border: 1px solid var(--border);
}
.btn:hover { background: var(--bg-secondary); }
.btn:active { transform: translateY(1px); }
.btn.sm { padding: 4px 12px; font-size: 12px; }
.btn-primary {
  background: var(--text-primary);
  color: var(--white);
  border-color: var(--text-primary);
  font-weight: 700;
}
.btn-primary:hover { opacity: 0.85; background: var(--text-primary); }
.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-secondary);
}
.btn-ghost:hover { background: var(--bg-secondary); color: var(--text-primary); }
.btn.outline-btn {
  background: transparent;
  color: var(--text-primary);
  border: 1px solid var(--border);
}
.btn.outline-btn.btn-primary {
  border-color: var(--text-primary);
}
.btn .arrow-circle { display: none; }

/* -------------------------------------------------------------------
   17. Modals (existing markup, restyled)
   ------------------------------------------------------------------- */
.modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.4);
  display: none;
  align-items: center; justify-content: center;
  z-index: 1000;
  padding: 16px;
}
.modal[aria-hidden="false"],
.modal.is-open,
.modal.open { display: flex; }
.modal-content {
  background: var(--bg);
  border-radius: var(--radius-lg);
  padding: 24px;
  width: 100%;
  max-width: 520px;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  position: relative;
  box-shadow: var(--shadow-3);
}
.modal-content::before { content: none; }
.modal-content h2,
.modal-content h3 { font-size: 16px; margin: 0 0 12px; }
.modal .close {
  font-size: 24px;
  color: var(--text-secondary);
  cursor: pointer;
  line-height: 1;
  padding: 4px;
}
.modal .close:hover { color: var(--text-primary); }
.modal-meta { font-size: 13px; color: var(--text-secondary); margin: 4px 0; }
.modal-body { font-size: 14px; color: var(--text-primary); margin: 12px 0; white-space: pre-wrap; }
.modal-footer {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--border-light);
  display: flex;
}
.modal-header-actions { padding-bottom: 8px; }

#slider-modal .modal-content {
  max-width: 95vw;
  max-height: 95vh;
}
/* Slider modal — disable internal scroll so the page never gains a scrollbar */
#slider-modal,
#slider-modal .modal-content,
#slider-modal .slider-stage {
  overflow: hidden !important;
}
#slider-modal .slider-dot.active {
  background: #fff !important;
  transform: scale(1.4);
}
#slider-modal .slider-prev:hover,
#slider-modal .slider-next:hover {
  background: rgba(0,0,0,0.75) !important;
}
.slider-stage {
  width: 90vw; height: 80vh;
  display: flex; align-items: center; justify-content: center;
  position: relative;
}
.slider-stage img {
  max-width: 100%; max-height: 100%;
  object-fit: contain;
}
.slider-close {
  position: absolute;
  top: 16px; right: 16px;
  font-size: 32px;
  color: var(--white);
  z-index: 10;
}
.slider-close:hover { opacity: 0.8; }

/* -------------------------------------------------------------------
   18. Mobile bottom tabbar + sheet
   ------------------------------------------------------------------- */
.mobile-tabbar {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--tabbar-h);
  background: var(--bg);
  border-top: var(--hairline) solid var(--hairline-color);
  z-index: 50;
}
.m-tab {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px;
  font-size: 10px;
  color: var(--text-tertiary);
  transition: color var(--t-fast) var(--ease-out);
}
.m-tab svg { width: 20px; height: 20px; }
.m-tab.active { color: var(--text-primary); }
.m-tab[data-target="calendar"].active { color: var(--calendar-green); }
.m-tab[data-target="schedule"].active { color: var(--schedule-teal); }
.m-tab[data-target="tasks"].active    { color: var(--task-purple); }
.m-tab[data-target="diary"].active    { color: var(--diary-orange); }
.m-tab[data-target="map"].active      { color: var(--map-blue); }

.bottom-sheet {
  display: none;
  position: fixed;
  left: 0; right: 0; bottom: 0;
  background: var(--bg);
  border-radius: 12px 12px 0 0;
  box-shadow: 0 -2px 12px rgba(0,0,0,0.12);
  z-index: 60;
  max-height: 80vh;
  overflow-y: auto;
  transform: translateY(100%);
  transition: transform var(--t-slow) var(--ease-out);
  padding-bottom: var(--tabbar-h);
}
.bottom-sheet[data-state="open"] {
  display: block;
  transform: translateY(0);
}
.sheet-handle {
  height: 24px;
  display: flex; align-items: center; justify-content: center;
  cursor: grab;
}
.sheet-bar {
  width: 32px; height: 4px;
  border-radius: 2px;
  background: var(--border);
}
.sheet-header {
  padding: 4px 16px 8px;
  font-size: 15px; font-weight: 700;
  color: var(--text-primary);
}
.sheet-body {
  padding: 0 16px 16px;
  display: flex; flex-direction: column; gap: 12px;
}
.bottom-sheet-backdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.2);
  z-index: 55;
}
.bottom-sheet-backdrop.show { display: block; }

/* -------------------------------------------------------------------
   18.5. Mobile Pencil-style nav header, subtabs, drawer, home section
   ------------------------------------------------------------------- */
.mobile-nav { display: none; }
.mobile-subtabs { display: none; }
.mobile-login-btn { display: none; }
.mobile-drawer { display: none; }
.mobile-drawer-scrim { display: none; }

/* Home section is hidden on desktop (it's a mobile-only dashboard) */
@media (min-width: 1025px) {
  #home-section { display: none !important; }
}

/* Home section styling (active on mobile) */
.home-stage {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.home-overview-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.home-overview-card {
  border-radius: var(--radius-md);
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: relative;
}
.home-overview-card.task-light { background: var(--task-light); }
.home-overview-card.diary-light { background: var(--diary-light); }
.home-overview-card.schedule-light { background: var(--schedule-light); }
.home-overview-card.calendar-light { background: var(--calendar-light); }
.home-overview-card.map-blue-light { background: var(--map-blue-light); }
.home-overview-icon {
  width: 24px; height: 24px;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--text-primary);
}
.home-overview-card.task-light .home-overview-icon { color: var(--task-purple); }
.home-overview-card.diary-light .home-overview-icon { color: var(--diary-orange); }
.home-overview-label {
  font-size: 11px; font-weight: 700;
  color: var(--text-secondary);
}
.home-overview-value {
  font-size: 22px; font-weight: 700;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}
.home-section-block {
  background: var(--bg);
  border-radius: var(--radius-md);
  padding: 12px;
  border: 0.5px solid var(--border-light);
}
.home-section-label {
  font-size: 12px; font-weight: 700;
  color: var(--text-tertiary);
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.home-list {
  list-style: none; margin: 0; padding: 0;
  display: flex; flex-direction: column; gap: 8px;
}
.home-list li {
  display: flex; gap: 10px; align-items: center;
  font-size: 13px;
  color: var(--text-primary);
}
.home-list li.home-empty {
  color: var(--text-disabled);
  font-size: 12px;
}
.home-list .home-time {
  color: var(--text-tertiary);
  font-variant-numeric: tabular-nums;
  width: 50px; flex-shrink: 0;
  font-size: 12px;
}
.home-list .home-title-text {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.home-diary-cta {
  display: flex; justify-content: center;
}

@media (max-width: 1024px) {
  /* ===== Pencil-style mobile nav header (52px, fixed top) ===== */
  .mobile-nav {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 16px;
    height: 52px;
    background: var(--bg);
    border-bottom: 0.5px solid var(--border-light);
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: 65;
  }
  .mn-icon-btn {
    width: 32px; height: 32px;
    display: inline-flex; align-items: center; justify-content: center;
    background: transparent; border: 0;
    color: var(--text-primary);
    cursor: pointer;
    flex-shrink: 0;
  }
  .mn-icon-btn svg { width: 22px; height: 22px; }
  .mn-title {
    flex: 1;
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .mn-add-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    background: var(--text-primary);
    color: var(--white);
    border: 0;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    flex-shrink: 0;
  }
  .mn-add-btn[hidden] { display: none; }
  .mn-add-btn svg { width: 12px; height: 12px; }

  /* Sub-tabs row (Tasks: Today/Upcoming/Inbox; Diary: タイムライン/...) — fixed below mobile-nav */
  .mobile-subtabs {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 0 16px;
    height: 40px;
    background: var(--bg);
    border-bottom: 0.5px solid var(--border-light);
    overflow-x: auto;
    scrollbar-width: none;
    position: fixed;
    top: 52px; left: 0; right: 0;
    z-index: 64;
  }
  .mobile-subtabs::-webkit-scrollbar { display: none; }
  .mobile-subtabs[hidden] { display: none; }
  .mst-tab {
    background: transparent; border: 0;
    font-size: 13px;
    color: var(--text-tertiary);
    cursor: pointer;
    white-space: nowrap;
    padding: 4px 0;
    flex-shrink: 0;
  }
  .mst-tab.active {
    color: var(--text-primary);
    font-weight: 700;
  }

  /* Mobile login: floating bottom-right button (only when logged out) */
  .mobile-login-btn:not(.hidden) {
    display: inline-flex;
    align-items: center; justify-content: center;
    position: fixed;
    bottom: calc(var(--tabbar-h) + 12px);
    right: 12px;
    width: 44px; height: 44px;
    border-radius: 50%;
    background: var(--text-primary);
    color: var(--white);
    border: 0;
    box-shadow: var(--shadow-2);
    z-index: 65;
    cursor: pointer;
  }
  .mobile-login-btn svg { width: 18px; height: 18px; }

  /* Drawer */
  .mobile-drawer {
    display: block;
    position: fixed;
    top: 0; left: 0;
    width: 280px;
    height: 100vh;
    background: var(--bg);
    box-shadow: var(--shadow-3);
    z-index: 80;
    transform: translateX(-100%);
    transition: transform var(--t-slow) var(--ease-out);
    overflow-y: auto;
    padding: 16px;
  }
  .mobile-drawer[data-state="open"] {
    transform: translateX(0);
  }
  .mobile-drawer[hidden] { display: none; }
  .mobile-drawer-scrim {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 75;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--t-mid) var(--ease-out);
  }
  .mobile-drawer-scrim[data-state="open"] {
    opacity: 1;
    pointer-events: auto;
  }
  .mobile-drawer-scrim[hidden] { display: none; }

  .md-user {
    display: flex; align-items: center;
    gap: 12px;
    padding: 8px 4px;
  }
  .md-avatar {
    width: 40px; height: 40px;
    border-radius: 50%;
    object-fit: cover;
  }
  .md-user-name {
    font-size: 14px; font-weight: 700;
    color: var(--text-primary);
  }
  .md-divider {
    border: none;
    border-top: 0.5px solid var(--border-light);
    margin: 12px 0;
  }
  .md-widgets {
    display: flex; flex-direction: column; gap: 4px;
  }
  .md-widget {
    display: flex; gap: 12px; align-items: flex-start;
    padding: 8px 4px;
  }
  .md-widget-icon {
    width: 20px; height: 20px;
    color: var(--text-secondary);
    flex-shrink: 0;
    margin-top: 2px;
  }
  .md-widget-body { flex: 1; min-width: 0; }
  .md-widget-label {
    font-size: 11px; color: var(--text-tertiary); font-weight: 700;
  }
  .md-widget-value {
    font-size: 15px; font-weight: 700; color: var(--text-primary);
    margin-top: 2px;
  }
  .md-widget-upcoming {
    list-style: none; margin: 4px 0 0; padding: 0;
    display: flex; flex-direction: column; gap: 4px;
  }
  .md-widget-upcoming li {
    font-size: 12px; color: var(--text-primary);
    display: flex; gap: 6px;
  }
  .md-widget-upcoming li .md-time {
    color: var(--text-tertiary);
    width: 44px; flex-shrink: 0;
    font-variant-numeric: tabular-nums;
  }
  .md-widget-upcoming li .md-date {
    color: var(--text-secondary);
    font-weight: 700;
    width: 32px; flex-shrink: 0;
  }
  .md-widget-upcoming li.md-empty {
    color: var(--text-disabled);
  }
  .md-actions {
    display: flex; flex-direction: column; gap: 2px;
  }
  .md-action {
    display: flex; gap: 12px; align-items: center;
    padding: 12px 4px;
    font-size: 14px; color: var(--text-primary);
    background: transparent; border: 0;
    text-align: left; cursor: pointer;
    border-radius: var(--radius-sm);
  }
  .md-action:hover { background: var(--bg-secondary); }
  .md-action svg { width: 18px; height: 18px; color: var(--text-secondary); }

  /* Mobile: keep cp-header for in-section controls (month nav, view switch, map filter)
     but hide the redundant title and primary action button — Pencil mobile-nav owns those. */
  .cp-header {
    padding: 6px 12px;
    gap: 6px;
    min-height: auto;
    flex-wrap: wrap;
  }
  .cp-header-title { display: none; }
  .cp-action-btn { display: none; }
  .cp-tabs { font-size: 11px; }
  .cp-month-nav { font-size: 13px; }
  /* Calendar / map sections: cp-header below mobile-nav */
  body[data-section="schedule"] .cp-header,
  body[data-section="tasks"] .cp-header,
  body[data-section="diary"] .cp-header,
  body[data-section="home"] .cp-header,
  body[data-section="settings"] .cp-header {
    /* Sections without secondary controls — hide cp-header entirely */
    display: none;
  }
}

/* -------------------------------------------------------------------
   19. Responsive — Mobile breakpoint (<= 1024px)
   ------------------------------------------------------------------- */
@media (max-width: 1024px) {
  body[data-rp-state="closed"] .app-shell,
  body[data-rp-state="open"] .app-shell {
    grid-template-columns: 1fr;
    grid-template-areas: "center";
  }
  .left-pane,
  .right-pane {
    display: none;
  }
  .center-pane {
    height: calc(100vh - var(--tabbar-h) - 52px);
    margin-top: 52px;
  }
  /* When sub-tabs are visible (Tasks/Diary), reserve their height too */
  body[data-section="tasks"] .center-pane,
  body[data-section="diary"] .center-pane {
    height: calc(100vh - var(--tabbar-h) - 52px - 40px);
    margin-top: calc(52px + 40px);
  }
  .mobile-tabbar { display: flex; }
}

@media (max-width: 1024px) {
  /* Hide in-section sub-tab strips on mobile — replaced by .mobile-subtabs fixed bar */
  .task-tabs { display: none !important; }
  .task-tab-title { display: none; }
}

@media (max-width: 767px) {
  .cp-section { padding: 16px; }
  .cal-cell { min-height: 64px; padding: 4px 6px; }
  .cal-date-num { font-size: 12px; }
  .cal-events { display: none; }
}

/* -------------------------------------------------------------------
   20. Misc compat / animations
   ------------------------------------------------------------------- */
.section { /* legacy noop */ }
.fade-in-up { animation: fadeInUp var(--t-slow) var(--ease-out); }
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* === Weekend emphasis === */
body.emphasize-weekend .cal-cell.sat .cal-date-num { color: var(--map-blue); }
body.emphasize-weekend .cal-cell.sun .cal-date-num { color: var(--red); }

/* === Map thumbnail toggle === */
body[data-map-thumbnails="off"] .map-detail-image-grid { display: none; }
