/* ==========================================================================
   Nirmit Private Cockpit PWA — Compact, Mobile-First, ADHD-Calm Design
   Exact Piru Frosted Stationery × Rose Pine Plum design language
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=EB+Garamond:ital,wght@0,400;0,500;0,600;1,400;1,500&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,400;1,400&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Geist+Mono:wght@400;500&display=swap');

:root {
  --max-w: 940px;
  --font-serif: 'EB Garamond', Georgia, serif;
  --font-italic: 'Cormorant Garamond', Georgia, serif;
  --font-mono: 'Geist Mono', ui-monospace, SFMono-Regular, monospace;

  --paper-bg: #faf4f8;
  --surface-card: rgba(254, 250, 253, 0.80);
  --surface-card-solid: #fefafd;
  --surface-tint: rgba(244, 231, 243, 0.72);
  --surface-blush: rgba(245, 224, 243, 0.76);
  --surface-header: rgba(235, 211, 234, 0.80);
  --surface-header-blush: rgba(233, 199, 230, 0.82);
  --surface-footer: rgba(242, 226, 241, 0.74);
  --glass-highlight: rgba(255, 255, 255, 0.88);

  --border-plum: #9c7598;
  --border-soft: #dcc7da;
  --border-hairline: #ece0eb;
  --shadow-plum: rgba(182, 139, 178, 0.36);
  --shadow-soft: rgba(203, 169, 200, 0.30);

  --rp-muted: #9a86a2;
  --rp-subtle: #756180;
  --rp-text: #32223c;
  --rp-love: #b45372;
  --rp-rose: #a85b7c;
  --rp-iris: #7c5894;
  --rp-slate: #5c6a94;
  --rp-warm: #a66253;
  --rp-berry: #9b4875;

  /* Consistent Typography Scale */
  --fs-xs: 0.66rem;
  --fs-sm: 0.78rem;
  --fs-base: 1rem;
  --fs-md: 1.15rem;
  --fs-lg: 1.55rem;

  /* Strictly 3 Priority Colors (for task text) */
  --prio-high: #b45372;
  --prio-med: #b06722;
  --prio-low: #6d4f8a;

  /* Symmetrical Toolbar Control Height */
  --ctrl-h: 32px;
}

*, *::before, *::after {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden;
}

body {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 16.5px;
  line-height: 1.5;
  color: var(--rp-text);
  background-color: var(--paper-bg);
  background-image:
    radial-gradient(ellipse 84% 44% at 50% 0%, rgba(235, 200, 232, 0.30), transparent 72%),
    linear-gradient(180deg, #fbf6fa 0%, #f8f0f6 55%, #f5ecf4 100%);
  background-attachment: fixed;
  overflow-x: hidden;
  width: 100%;
}

h1, h2, h3, h4 {
  font-family: var(--font-serif);
  font-weight: 600;
  margin: 0;
  color: var(--rp-text);
}

.page-title {
  font-size: var(--fs-lg);
  margin: 0 0 12px;
  font-weight: 600;
}

/* Sharp Square Native Checkboxes (Zero Rounded Checkboxes Anywhere) */
input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 15px;
  height: 15px;
  border: 1.5px solid var(--border-plum);
  border-radius: 0;
  background: var(--surface-card-solid);
  cursor: pointer;
  display: inline-grid;
  place-content: center;
  margin: 0;
  flex-shrink: 0;
}

input[type="checkbox"]:checked {
  background: var(--rp-love);
  border-color: var(--rp-love);
}

input[type="checkbox"]:checked::after {
  content: "";
  width: 4px;
  height: 8px;
  border: solid #fff;
  border-width: 0 1.7px 1.7px 0;
  transform: rotate(45deg) translate(-0.5px, -0.5px);
}

a {
  color: var(--rp-text);
  text-decoration: none;
  border-bottom: 1.5px solid var(--rp-love);
  transition: background-color 0.14s ease, color 0.14s ease;
}

a:hover {
  background: var(--rp-love);
  color: #fff;
}

/* ==========================================================================
   Shell & Header
   ========================================================================== */

.app-shell {
  width: 100%;
  max-width: var(--max-w);
  margin: 0 auto;
  padding: calc(16px + env(safe-area-inset-top, 0px)) 18px 48px;
}

.top-header {
  border-bottom: 1px dotted var(--border-plum);
  padding-bottom: 11px;
  margin-bottom: 14px;
}

.top-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand-wrap {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}

.brand-link {
  font-size: 1.4em;
  font-weight: 600;
  letter-spacing: -0.015em;
  border-bottom: none;
}

.brand-link:hover {
  background: none;
  color: var(--rp-love);
}

.brand-tag {
  font-family: var(--font-mono);
  font-size: 0.66rem;
  color: var(--rp-muted);
  white-space: nowrap;
  letter-spacing: 0.02em;
}

.desktop-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font-mono);
  font-size: 0.72rem;
}

.desktop-nav a {
  color: var(--rp-subtle);
  padding: 4px 9px;
  border: 1px solid transparent;
  border-bottom-width: 1px;
  transition: all 0.14s ease;
}

.desktop-nav a:hover {
  background: var(--surface-card);
  border-color: var(--border-plum);
  color: var(--rp-text);
  box-shadow: inset 0 1px 0 var(--glass-highlight), 2px 2px 0 var(--shadow-soft);
}

.desktop-nav a.is-active {
  background: var(--surface-header);
  border-color: var(--border-plum);
  color: var(--rp-text);
  box-shadow: inset 0 1px 0 var(--glass-highlight), 2px 2px 0 var(--shadow-plum);
}

.mobile-settings-btn {
  display: none;
}

.mobile-nav {
  display: none;
}

/* ==========================================================================
   Consistent Thick Arrows (exact match to blog)
   ========================================================================== */

.arrow-icon {
  width: 10px;
  height: 10px;
  flex-shrink: 0;
  display: inline-block;
  color: var(--rp-love);
}

.hdr-link {
  appearance: none;
  background: none;
  border: none;
  border-bottom: 1px solid transparent;
  padding: 0 0 1px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font-mono);
  font-size: 0.66rem;
  letter-spacing: 0.03em;
  text-transform: lowercase;
  color: var(--rp-subtle);
  transition: color 0.14s ease, border-color 0.14s ease;
}

.hdr-link:hover {
  background: none;
  color: var(--rp-love);
  border-bottom-color: var(--rp-love);
}

/* ==========================================================================
   Alerts Strip
   ========================================================================== */

.alerts-strip {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
}

.alerts-strip:empty {
  display: none;
  margin-bottom: 0;
}

.alert-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding: 8px 12px;
  background: var(--surface-blush);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-plum);
  border-left: 3px solid var(--rp-love);
  box-shadow: inset 0 1px 0 var(--glass-highlight), 2px 2px 0 var(--shadow-soft);
  font-family: var(--font-mono);
  font-size: 0.69rem;
  line-height: 1.45;
}

.alert-bar--info {
  background: var(--surface-card);
  border-left-color: var(--rp-iris);
}

/* ==========================================================================
   Piru Frosted Boxes (Compact & Crisp)
   ========================================================================== */

.pbox {
  background: var(--surface-card);
  backdrop-filter: blur(14px) saturate(125%);
  -webkit-backdrop-filter: blur(14px) saturate(125%);
  border: 1px solid var(--border-plum);
  box-shadow: inset 0 1px 0 var(--glass-highlight), 3px 3px 0 var(--shadow-plum);
  display: flex;
  flex-direction: column;
  min-width: 0;
  width: 100%;
  overflow: visible;
}

.pbox--blush {
  background: var(--surface-blush);
}

.pbox-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 11px;
  background: var(--surface-header);
  border-bottom: 1px solid var(--border-plum);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.65);
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--rp-text);
  min-width: 0;
}

.pbox--blush .pbox-header {
  background: var(--surface-header-blush);
}

.pbox-header--dotted {
  background: var(--surface-tint);
  border-bottom: 1px dotted var(--border-plum);
}

.pbox-title {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-weight: 500;
  min-width: 0;
  white-space: nowrap;
}

.pbox-pip {
  width: 7px;
  height: 7px;
  border: 1.5px solid var(--rp-love);
  border-radius: 0;
  background: var(--surface-card-solid);
  flex-shrink: 0;
}

.pbox-pip--sq {
  border-radius: 0;
  border-color: var(--rp-iris);
  background: var(--rp-iris);
  width: 7px;
  height: 7px;
}

.pbox-body {
  padding: 10px 12px;
  min-width: 0;
}

.pbox-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 5px 11px;
  background: var(--surface-footer);
  border-top: 1px solid var(--border-hairline);
  font-family: var(--font-mono);
  font-size: 0.64rem;
  color: var(--rp-muted);
}

.section-label {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 18px 0 10px;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--rp-subtle);
}

.section-label:first-child { margin-top: 0; }
.section-num { color: var(--rp-love); font-weight: 500; }
.section-rule {
  flex: 1;
  height: 1px;
  background: repeating-linear-gradient(to right, var(--border-soft) 0 4px, transparent 4px 8px);
}

/* ==========================================================================
   Buttons, Inputs & Custom Piru Select Picker (No OS Arrows!)
   ========================================================================== */

.btn {
  appearance: none;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.03em;
  padding: 6px 11px;
  background: var(--surface-card-solid);
  color: var(--rp-text);
  border: 1px solid var(--border-plum);
  box-shadow: inset 0 1px 0 var(--glass-highlight), 2px 2px 0 var(--shadow-soft);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  white-space: nowrap;
  transition: transform 0.1s ease, background-color 0.14s ease;
}

.btn:hover {
  background: var(--surface-blush);
  transform: translate(-1px, -1px);
  box-shadow: inset 0 1px 0 var(--glass-highlight), 3px 3px 0 var(--shadow-plum);
}

.btn--primary {
  background: var(--rp-love);
  border-color: #8f3a55;
  color: #fff;
  box-shadow: 2px 2px 0 var(--shadow-plum);
}

.btn--primary:hover { background: #9f4461; color: #fff; }
.btn--sm { font-size: 0.65rem; padding: 4px 8px; }
.btn--ghost { background: transparent; border-color: var(--border-soft); box-shadow: none; color: var(--rp-subtle); }
.btn--ghost:hover { background: var(--surface-tint); border-color: var(--border-plum); color: var(--rp-text); transform: none; box-shadow: none; }
.btn--danger { color: #a6344c; border-color: #c77b8c; }
.btn--danger:hover { background: #b45372; color: #fff; border-color: #8f3a55; }
.btn--full { width: 100%; }

.field-input,
.field-textarea,
.field-select {
  width: 100%;
  font-family: var(--font-serif);
  font-size: var(--fs-base);
  padding: 7px 10px;
  color: var(--rp-text);
  background: var(--surface-card-solid);
  border: 1px solid var(--border-plum);
  outline: none;
  border-radius: 0;
}

.field-input--mono,
.field-select {
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
}

.search-input {
  width: 100%;
  height: var(--ctrl-h);
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  padding: 0 10px;
  color: var(--rp-text);
  background: var(--surface-card);
  border: 1px solid var(--border-plum);
  box-shadow: inset 0 1px 0 var(--glass-highlight), 2px 2px 0 var(--shadow-soft);
  outline: none;
  border-radius: 0;
}

.search-input:focus {
  border-color: var(--rp-love);
}

.toolbar-time-input {
  height: var(--ctrl-h);
  width: 112px;
  font-family: var(--font-mono);
  font-size: 0.69rem;
  padding: 0 7px;
  color: var(--rp-text);
  background: var(--surface-card-solid);
  border: 1px solid var(--border-plum);
  box-shadow: inset 0 1px 0 var(--glass-highlight), 2px 2px 0 var(--shadow-soft);
  outline: none;
  border-radius: 0;
}

.toolbar-time-input:focus {
  border-color: var(--rp-love);
}

/* Global anti-zoom on iOS / iPadOS touch devices for ALL inputs */
@media (max-width: 1024px), (pointer: coarse) {
  :root {
    --ctrl-h: 36px;
  }

  input[type="text"],
  input[type="search"],
  input[type="password"],
  input[type="number"],
  input[type="date"],
  input[type="time"],
  textarea,
  select,
  .search-input,
  .td-title-input {
    font-size: 16px !important;
  }

  .toolbar-time-input {
    width: 126px;
  }
}

/* Custom crisp chevron on native form selects inside modals (never OS arrow) */
.field-select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 28px;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='11' height='11' viewBox='0 0 12 12' fill='none' stroke='%23b45372' stroke-width='2.1' stroke-linecap='square'%3E%3Cpath d='M2.5 4.2L6 7.8L9.5 4.2'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 9px center;
}

.field-textarea { resize: vertical; min-height: 60px; line-height: 1.48; }
.field-input:focus, .field-textarea:focus, .field-select:focus { border-color: var(--rp-love); box-shadow: 2px 2px 0 var(--shadow-soft); }
.field-label { display: block; font-family: var(--font-mono); font-size: 0.64rem; letter-spacing: 0.05em; text-transform: uppercase; color: var(--rp-subtle); margin-bottom: 4px; }
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 9px; }
.field-group { margin-bottom: 10px; }

/* Custom Piru Frosted Dropdown Picker (.pselect) */
.pselect {
  position: relative;
  display: inline-block;
  min-width: 146px;
}

.pselect-trigger {
  appearance: none;
  width: 100%;
  height: var(--ctrl-h);
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 0.69rem;
  padding: 0 9px;
  color: var(--rp-text);
  background: var(--surface-card-solid);
  border: 1px solid var(--border-plum);
  box-shadow: inset 0 1px 0 var(--glass-highlight), 2px 2px 0 var(--shadow-soft);
  cursor: pointer;
}

.pselect-trigger:hover, .pselect.is-open .pselect-trigger {
  background: var(--surface-blush);
  border-color: var(--rp-love);
}

.pselect-chevron {
  width: 10.5px;
  height: 10.5px;
  flex-shrink: 0;
  color: var(--rp-love);
  transition: transform 0.15s ease;
}

.pselect.is-open .pselect-chevron { transform: rotate(180deg); }

.pselect-menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  min-width: 100%;
  max-height: 220px;
  overflow-y: auto;
  background: rgba(254, 250, 253, 0.97);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-plum);
  box-shadow: 3px 3px 0 var(--shadow-plum);
  z-index: 80;
  padding: 3px 0;
}

.pselect-menu[hidden] { display: none; }

.pselect-option {
  appearance: none;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 10px;
  background: transparent;
  border: none;
  font-family: var(--font-mono);
  font-size: 0.69rem;
  color: var(--rp-text);
  text-align: left;
  cursor: pointer;
  white-space: nowrap;
}

.pselect-option:hover { background: var(--surface-blush); }
.pselect-option.is-selected { background: var(--surface-header); font-weight: 500; }

/* ==========================================================================
   Compact ADHD-First Home Dashboard Grid
   ========================================================================== */

.dash-stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.dash-two {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
  gap: 14px;
  align-items: stretch;
}

.dash-two > .pbox {
  height: 100%;
}

.dash-two > .pbox > .pbox-body,
.dash-two > .pbox > form.pbox-body {
  flex: 1 1 auto;
}

.dash-col {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}

/* ==========================================================================
   Calendar-Strip Planner (Single Clean View — No Competing Boxes or Lines!)
   ========================================================================== */

/* Compact Calendar Strip (Shortened so Tasks Dominate the Focus Box) */
.cal-strip {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 5px 8px;
  background: var(--surface-tint);
  border-bottom: 1px dotted var(--border-soft);
}

.cal-nav-btn {
  appearance: none;
  background: var(--surface-card-solid);
  border: 1px solid var(--border-soft);
  color: var(--rp-muted);
  font-family: var(--font-mono);
  font-size: 0.68rem;
  width: 22px;
  height: 26px;
  flex-shrink: 0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.cal-nav-btn:hover { border-color: var(--border-plum); color: var(--rp-text); }

.cal-days {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 3px;
  flex: 1;
  min-width: 0;
}

.cal-day-btn {
  appearance: none;
  background: var(--surface-card-solid);
  border: 1px solid var(--border-soft);
  height: 26px;
  padding: 0 2px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-family: var(--font-mono);
  color: var(--rp-muted);
  min-width: 0;
  position: relative;
  transition: all 0.12s ease;
}

.cal-day-btn:hover { border-color: var(--border-plum); color: var(--rp-text); }
.cal-day-btn.is-today { border-color: var(--rp-love); color: var(--rp-subtle); }
.cal-day-btn.is-selected {
  background: var(--surface-header-blush);
  border-color: var(--rp-love);
  color: var(--rp-text);
  box-shadow: 1.5px 1.5px 0 var(--shadow-soft);
}

.cal-day-wd { font-size: 0.56rem; text-transform: uppercase; opacity: 0.78; }
.cal-day-num { font-size: 0.67rem; font-weight: 500; line-height: 1; }
.cal-day-dot {
  position: absolute;
  top: 2.5px;
  right: 2.5px;
  width: 4px;
  height: 4px;
  border-radius: 0;
  background: var(--rp-love);
  opacity: 0;
}
.cal-day-dot.has-items { opacity: 1; }

.cal-someday-btn {
  appearance: none;
  background: var(--surface-card-solid);
  border: 1px dashed var(--border-soft);
  padding: 0 7px;
  height: 26px;
  flex-shrink: 0;
  font-family: var(--font-mono);
  font-size: 0.62rem;
  color: var(--rp-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.cal-someday-btn.is-selected {
  background: var(--surface-header);
  border-style: solid;
  border-color: var(--border-plum);
  color: var(--rp-text);
}

/* Bounded Todo List (Infinite Tasks Scroll Cleanly Inside Box) */
.todo-list {
  padding: 2px 12px 4px;
  max-height: 235px;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: var(--shadow-plum) var(--surface-tint);
}

.todo-item {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 7px 2px;
  border-bottom: 1px solid var(--border-hairline);
}

.todo-item:last-child { border-bottom: none; }

.todo-item[data-priority="high"] .todo-title { color: var(--prio-high); }
.todo-item[data-priority="medium"] .todo-title { color: var(--prio-med); }
.todo-item[data-priority="low"] .todo-title { color: var(--prio-low); }

/* Strict Sharp Square Checkbox (Matches Theme!) */
.todo-check {
  appearance: none;
  width: 15px;
  height: 15px;
  margin-top: 3px;
  border: 1.5px solid var(--border-plum);
  border-radius: 0;
  background: var(--surface-card-solid);
  cursor: pointer;
  flex-shrink: 0;
  position: relative;
}

.todo-check.is-done { background: var(--rp-love); border-color: var(--rp-love); }
.todo-check.is-done::after {
  content: "";
  position: absolute;
  left: 4px; top: 1px;
  width: 4px; height: 7.5px;
  border: solid #fff;
  border-width: 0 1.6px 1.6px 0;
  transform: rotate(45deg);
}

/* True Tweek Weekly Planner Grid (#planner page) */
.tweek-week-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  align-items: start;
}

.tweek-weekend-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.tweek-col {
  background: var(--surface-card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-soft);
  box-shadow: inset 0 1px 0 var(--glass-highlight), 2px 2px 0 var(--shadow-soft);
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.tweek-col.is-today {
  border-color: var(--rp-love);
  box-shadow: inset 0 1px 0 var(--glass-highlight), 3px 3px 0 var(--shadow-plum);
}

.tweek-col-head {
  padding: 7px 10px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-hairline);
  background: var(--surface-tint);
}

.tweek-col.is-today .tweek-col-head {
  background: var(--surface-header-blush);
  border-bottom-color: var(--rp-love);
}

.tweek-col-name { font-family: var(--font-serif); font-size: 1.02em; font-weight: 600; }
.tweek-col-date { font-family: var(--font-mono); font-size: 0.62rem; color: var(--rp-muted); }

.tweek-col-list {
  padding: 2px 9px 4px;
  min-height: 112px;
  max-height: 230px;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: var(--shadow-plum) var(--surface-tint);
}

.tweek-col--weekend .tweek-col-list {
  min-height: 68px;
  max-height: 120px;
}

.tweek-bottom-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 3fr;
  gap: 10px;
  margin-top: 10px;
  align-items: start;
}

.tweek-someday-list {
  padding: 2px 9px 4px;
  min-height: 112px;
  max-height: 230px;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: var(--shadow-plum) var(--surface-tint);
}

.todo-content { flex: 1; min-width: 0; cursor: pointer; }
.todo-title { font-size: 0.96em; line-height: 1.35; overflow-wrap: anywhere; display: block; }
.todo-item.is-done .todo-title { text-decoration: line-through; color: var(--rp-muted); }
.todo-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 2px; font-family: var(--font-mono); font-size: 0.62rem; color: var(--rp-muted); }

.quick-add-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border-top: 1px dotted var(--border-soft);
  background: rgba(254, 250, 253, 0.52);
}

.quick-add-bar input {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  font-family: var(--font-serif);
  font-size: 0.94em;
  color: var(--rp-text);
  outline: none;
}

.quick-add-bar input::placeholder { color: var(--rp-muted); font-style: italic; }

/* ==========================================================================
   Compact Habit Tracker 21 Grid + Heatmap
   ========================================================================== */

.habit-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.habit-table thead tr {
  background-image: repeating-linear-gradient(
    to right,
    var(--border-soft) 0 2px,
    transparent 2px 5px
  );
  background-position: bottom left;
  background-size: 100% 1px;
  background-repeat: no-repeat;
}

.habit-table th {
  font-family: var(--font-mono);
  font-size: 0.61rem;
  font-weight: 500;
  color: var(--rp-muted);
  text-align: center;
  padding: 2px 1px 7px;
  border-bottom: none;
  width: 28px;
}

.habit-table th:first-child {
  text-align: left;
  width: auto;
}

.habit-table th.is-today { color: var(--rp-love); font-weight: 600; }
.habit-day-num { display: block; font-size: 0.56rem; opacity: 0.78; }

.habit-table td {
  padding: 5px 1px;
  text-align: center;
  border-bottom: 1px solid var(--border-hairline);
  vertical-align: middle;
}

.habit-table tr:last-child td { border-bottom: none; }

.habit-name-cell {
  text-align: left !important;
  padding-right: 6px !important;
  overflow: hidden;
}

.habit-name-btn {
  appearance: none;
  background: none;
  border: none;
  padding: 0;
  width: 100%;
  font-family: var(--font-serif);
  font-size: 0.95em;
  font-weight: 500;
  color: var(--rp-text);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  text-align: left;
}

.habit-name-btn span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.habit-name-btn:hover { color: var(--rp-love); }
.habit-dot { width: 7px; height: 7px; flex-shrink: 0; display: inline-block; }

.habit-check {
  appearance: none;
  width: 20px;
  height: 20px;
  margin: 0 auto;
  border: 1.5px solid var(--border-plum);
  border-radius: 0;
  background: var(--surface-card-solid);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  position: relative;
  vertical-align: middle;
}

.habit-check.is-done {
  border-color: var(--rp-text);
  box-shadow: 1.5px 1.5px 0 var(--shadow-soft);
}

.habit-check.is-done::after {
  content: "";
  width: 5px;
  height: 9px;
  border: solid #fff;
  border-width: 0 1.8px 1.8px 0;
  transform: rotate(45deg) translate(-0.5px, -0.5px);
}
.habit-check.is-future { opacity: 0.28; cursor: not-allowed; }

/* Improved Habits Global Overview & Heatmap Frame */
.habits-overview-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.overview-stat {
  padding: 10px 12px;
  background: var(--surface-card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-plum);
  box-shadow: inset 0 1px 0 var(--glass-highlight), 2px 2px 0 var(--shadow-soft);
}

.overview-stat-label {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--rp-muted);
}

.overview-stat-val {
  font-family: var(--font-serif);
  font-size: 1.45em;
  font-weight: 600;
  color: var(--rp-text);
  line-height: 1.2;
  margin-top: 2px;
}

.heatmap-frame {
  display: flex;
  align-items: flex-start;
  gap: 7px;
}

.heatmap-wd-col {
  display: grid;
  grid-template-rows: repeat(7, 12px);
  gap: 3px;
  padding-top: 16px;
  font-family: var(--font-mono);
  font-size: 0.54rem;
  color: var(--rp-muted);
  line-height: 12px;
  flex-shrink: 0;
}

.heatmap-scroll {
  overflow-x: auto;
  flex: 1;
  min-width: 0;
  padding-bottom: 4px;
}

.heatmap-months {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 12px;
  gap: 3px;
  height: 14px;
  margin-bottom: 2px;
  font-family: var(--font-mono);
  font-size: 0.56rem;
  color: var(--rp-muted);
  width: max-content;
}

.heatmap-grid { display: grid; grid-template-rows: repeat(7, 12px); grid-auto-flow: column; grid-auto-columns: 12px; gap: 3px; width: max-content; }
.hm-cell { width: 12px; height: 12px; border: 1px solid var(--border-hairline); background: var(--surface-card-solid); cursor: pointer; padding: 0; display: block; }
.hm-cell:hover { border-color: var(--rp-text); }
.hm-cell.is-today { outline: 1.5px solid var(--rp-love); outline-offset: 0.5px; }
.habit-stats-row { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 9px; font-family: var(--font-mono); font-size: 0.67rem; color: var(--rp-subtle); }

/* ==========================================================================
   Compact Smart Meds Box + Visual Charts
   ========================================================================== */

.med-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 0;
  border-bottom: 1px solid var(--border-hairline);
}

.med-row:last-child { border-bottom: none; }
.med-row-info { min-width: 0; flex: 1; }
.med-row-name { font-weight: 600; font-size: 0.96em; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.med-row-meta { font-family: var(--font-mono); font-size: 0.64rem; color: var(--rp-muted); margin-top: 1px; }

.med-calm-empty {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding: 4px 0;
  font-size: 0.94em;
  color: var(--rp-subtle);
}

.chart-svg {
  width: 100%;
  height: auto;
  display: block;
  overflow: visible;
}

.intake-readout {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 5px 9px;
  margin-top: 6px;
  background: var(--surface-tint);
  border: 1px dashed var(--border-soft);
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--rp-subtle);
}

.intake-readout strong { color: var(--rp-text); font-weight: 500; }

.pill-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.pill-tab {
  appearance: none;
  font-family: var(--font-mono);
  font-size: 0.64rem;
  padding: 3px 8px;
  background: var(--surface-tint);
  color: var(--rp-subtle);
  border: 1px solid var(--border-soft);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.pill-tab.is-active {
  background: var(--surface-card-solid);
  border-color: var(--border-plum);
  color: var(--rp-text);
  box-shadow: 2px 2px 0 var(--shadow-soft);
}

/* ==========================================================================
   Vocabulary FSRS Cards
   ========================================================================== */

.vocab-compact-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.flashcard {
  padding: 20px 18px;
  background: var(--surface-card);
  border: 1px solid var(--border-plum);
  box-shadow: inset 0 1px 0 var(--glass-highlight), 4px 4px 0 var(--shadow-plum);
  max-width: 620px;
  margin: 0 auto;
}

.flashcard-word { font-size: 1.9em; font-weight: 600; line-height: 1.2; }
.flashcard-pos { font-family: var(--font-italic); font-style: italic; font-size: 1.05em; color: var(--rp-love); margin-left: 7px; }
.flashcard-divider { border: none; border-top: 1px dotted var(--border-plum); margin: 14px 0; }
.flashcard-def { font-size: 1.02em; line-height: 1.55; margin: 0 0 12px; }
.flashcard-examples { margin: 0 0 12px; padding-left: 18px; color: var(--rp-subtle); }
.flashcard-examples li { margin-bottom: 5px; }
.synonym-pills { display: flex; flex-wrap: wrap; gap: 5px; }
.syn-pill { font-family: var(--font-mono); font-size: 0.64rem; padding: 2px 7px; background: var(--surface-tint); border: 1px solid var(--border-soft); color: var(--rp-subtle); }

.fsrs-ratings { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; margin-top: 16px; }
.fsrs-btn { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 4px; }
.fsrs-interval { font-size: 0.6rem; color: var(--rp-muted); }

.list-row-item { padding: 10px 12px; border-bottom: 1px solid var(--border-hairline); }
.list-row-item:last-child { border-bottom: none; }
.list-row-top { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; flex-wrap: wrap; }

/* ==========================================================================
   Badges, Tables, Auth, Modals, Toasts
   ========================================================================== */

.badge { font-family: var(--font-mono); font-size: 0.59rem; padding: 1px 5px; border: 1px solid var(--border-soft); background: var(--surface-tint); color: var(--rp-subtle); text-transform: uppercase; }
.badge--pub { border-color: var(--rp-love); color: var(--rp-love); }
.badge--done { background: var(--rp-love); border-color: var(--rp-love); color: #fff; }
.muted { color: var(--rp-muted); font-family: var(--font-mono); font-size: 0.68rem; }

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.toolbar .btn--sm {
  height: var(--ctrl-h);
  padding: 0 10px;
}

.habits-toolbar {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

.habits-toolbar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.habits-toolbar-row .btn--sm {
  height: var(--ctrl-h);
  padding: 0 10px;
}

.habits-toolbar-sub {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.data-table-wrap { width: 100%; overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th, .data-table td { padding: 7px 10px; border-bottom: 1px solid var(--border-hairline); text-align: left; font-size: 0.86em; white-space: nowrap; }
.data-table td.col-wrap { white-space: normal; overflow-wrap: break-word; }
.data-table th { font-family: var(--font-mono); font-size: 0.65rem; text-transform: uppercase; color: var(--rp-subtle); background: var(--surface-tint); }

/* Curated 10-Color Swatch Picker (Harmonized Piru / Rose Pine Palette) */
.color-swatches {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 7px;
  max-width: 240px;
}

.color-swatch {
  appearance: none;
  height: 26px;
  border: 1.5px solid rgba(50, 34, 60, 0.22);
  border-radius: 0;
  cursor: pointer;
  padding: 0;
  position: relative;
  transition: transform 0.1s ease;
}

.color-swatch:hover {
  transform: translate(-1px, -1px);
  border-color: var(--rp-text);
}

.color-swatch.is-selected {
  border: 2px solid var(--rp-text);
  box-shadow: inset 0 0 0 2px #fff, 2px 2px 0 var(--shadow-plum);
}

/* Compact Med Editor Top Row & Linked Substance Autofill */
.med-edit-top {
  display: grid;
  grid-template-columns: minmax(0, 1.8fr) minmax(0, 0.75fr) minmax(0, 0.6fr);
  gap: 8px;
  align-items: end;
  margin-bottom: 10px;
}

.med-name-wrap {
  position: relative;
}

.med-suggest-list {
  position: absolute;
  top: calc(100% + 2px);
  left: 0;
  right: 0;
  background: rgba(254, 250, 253, 0.98);
  border: 1px solid var(--border-plum);
  box-shadow: 3px 3px 0 var(--shadow-plum);
  z-index: 90;
  max-height: 168px;
  overflow-y: auto;
}

.med-suggest-item {
  appearance: none;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 9px;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border-hairline);
  text-align: left;
  cursor: pointer;
  font-family: var(--font-serif);
  font-size: 0.92em;
  color: var(--rp-text);
}

.med-suggest-item:last-child { border-bottom: none; }
.med-suggest-item:hover { background: var(--surface-blush); }

.med-linked-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 5px 9px;
  margin-bottom: 10px;
  background: var(--surface-blush);
  border: 1px dashed var(--rp-love);
  font-family: var(--font-mono);
  font-size: 0.64rem;
  color: var(--rp-text);
}

.med-row.is-paused {
  opacity: 0.56;
}

/* Piru-Style Meds Insights (Stacked Levels, Modeled Active, Patterns, Cumulative, Co-Active) */
.piru-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}

.active-med-item {
  padding: 10px 0;
  border-bottom: 1px solid var(--border-hairline);
}

.active-med-item:first-child { padding-top: 2px; }
.active-med-item:last-child { border-bottom: none; padding-bottom: 2px; }

.active-med-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.active-med-sub {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 2px;
  font-family: var(--font-mono);
  font-size: 0.64rem;
  color: var(--rp-muted);
}

.active-med-bar {
  height: 4px;
  width: 100%;
  background: var(--border-hairline);
  margin-top: 7px;
  overflow: hidden;
}

.active-med-bar-fill {
  height: 100%;
  transition: width 0.25s ease;
}

.active-med-doses {
  margin-top: 7px;
  padding-top: 6px;
  border-top: 1px dotted var(--border-soft);
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.active-med-dose-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 0.63rem;
  color: var(--rp-subtle);
}

.cumul-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-hairline);
}

.cumul-row:last-child { border-bottom: none; }
.cumul-spark { width: 112px; height: 28px; flex-shrink: 0; display: block; }

.coactive-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 0;
  border-bottom: 1px solid var(--border-hairline);
}

.coactive-row:last-child { border-bottom: none; }

.auth-gate { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 18px; }
.auth-gate[hidden] { display: none; }
.auth-card { width: 100%; max-width: 380px; }
.auth-body { padding: 20px; display: flex; flex-direction: column; gap: 11px; }
.auth-sub { margin: 0; font-size: 0.92em; color: var(--rp-subtle); }
.form-error { font-family: var(--font-mono); font-size: 0.7rem; color: #a6344c; }

body.is-modal-open {
  position: fixed;
  left: 0;
  right: 0;
  width: 100%;
  overflow: hidden;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(250, 244, 248, 0.22);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: max(10vh, 52px) 14px 18px;
  overflow-y: auto;
  overscroll-behavior: contain;
  z-index: 120;
}
.modal-backdrop[hidden] { display: none; }

.modal-box {
  width: 100%;
  max-width: 440px;
  max-height: calc(100dvh - 44px);
  background: var(--surface-card-solid);
  box-shadow: 4px 4px 0 var(--shadow-plum);
  overflow-y: auto;
  overflow-x: hidden;
}

.modal-box .pbox-body {
  overflow-x: hidden;
}

/* Todoist-style Compact Task Composer Modal */
.td-title-input {
  width: 100%;
  border: none;
  border-bottom: 1px dotted var(--border-soft);
  background: transparent;
  font-family: var(--font-serif);
  font-size: 1.18em;
  font-weight: 500;
  color: var(--rp-text);
  padding: 4px 0 8px;
  margin-bottom: 10px;
  outline: none;
}

.td-title-input:focus {
  border-bottom-color: var(--rp-love);
}

.td-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.td-chip {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  font-family: var(--font-mono);
  font-size: 0.67rem;
  color: var(--rp-subtle);
  background: var(--surface-tint);
  border: 1px solid var(--border-soft);
  cursor: pointer;
  max-width: 100%;
  transition: border-color 0.12s ease, background-color 0.12s ease;
}

.td-chip:hover {
  border-color: var(--border-plum);
  color: var(--rp-text);
}

.td-chip.is-set {
  background: var(--surface-card-solid);
  border-color: var(--border-plum);
  color: var(--rp-text);
}

.td-drawer {
  padding: 9px 10px;
  margin-bottom: 10px;
  background: var(--surface-tint);
  border: 1px dotted var(--border-plum);
}

.td-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--border-hairline);
  margin-top: 6px;
}

.toast-root { position: fixed; right: 16px; bottom: 20px; display: flex; flex-direction: column; gap: 6px; z-index: 200; pointer-events: none; }
.toast { padding: 8px 13px; font-family: var(--font-mono); font-size: 0.7rem; background: var(--rp-text); color: #faf4f8; border: 1px solid var(--border-plum); box-shadow: 3px 3px 0 var(--shadow-plum); }

/* ==========================================================================
   Mobile Responsive (Tested for 360px–430px iPhone Screens)
   ========================================================================== */

@media (max-width: 780px) {
  body { font-size: 16px; }

  .app-shell {
    padding: calc(12px + env(safe-area-inset-top, 0px)) 12px calc(72px + env(safe-area-inset-bottom, 0px));
  }

  .dash-two,
  .piru-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .brand-link {
    font-size: 1.18em;
  }

  .cumul-spark {
    width: 88px;
  }

  .desktop-nav { display: none; }

  .mobile-settings-btn {
    display: inline-flex;
    align-items: center;
    font-family: var(--font-mono);
    font-size: 0.68rem;
    padding: 4px 9px;
    border: 1px solid var(--border-plum);
    background: var(--surface-card);
    color: var(--rp-subtle);
    box-shadow: 2px 2px 0 var(--shadow-soft);
  }

  .mobile-settings-btn:hover {
    background: var(--surface-blush);
    color: var(--rp-text);
  }

  .mobile-settings-btn.is-active {
    background: var(--surface-header);
    color: var(--rp-text);
  }

  .mobile-nav {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    background: rgba(250, 244, 248, 0.94);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-top: 1px solid var(--border-plum);
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom, 0px));
    gap: 3px;
    z-index: 60;
  }

  .mobile-nav a {
    font-family: var(--font-mono);
    font-size: 0.63rem;
    text-align: center;
    padding: 7px 2px;
    color: var(--rp-subtle);
    border: 1px solid transparent;
  }

  .mobile-nav a:hover {
    background: var(--surface-tint);
    color: var(--rp-text);
  }

  .mobile-nav a.is-active {
    background: var(--surface-header);
    border-color: var(--border-plum);
    color: var(--rp-text);
  }

  /* Prevent iOS Safari auto-zoom on every text/search/date/time input */
  input[type="text"],
  input[type="search"],
  input[type="password"],
  input[type="number"],
  input[type="date"],
  input[type="time"],
  textarea,
  select {
    font-size: 16px !important;
  }

  .habits-overview-grid {
    gap: 7px;
  }

  .overview-stat {
    padding: 8px 9px;
  }

  .overview-stat-val {
    font-size: 1.25em;
  }

  .cal-strip {
    flex-wrap: wrap;
    padding: 5px 6px;
    gap: 4px;
  }

  .cal-day-btn {
    flex-direction: column;
    height: 30px;
    gap: 0;
  }

  .cal-someday-btn {
    width: 100%;
    height: 24px;
    justify-content: center;
  }

  .tweek-week-grid,
  .tweek-bottom-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .tweek-col-list {
    min-height: 54px;
    max-height: 200px;
  }

  .habit-table th { width: 24px; font-size: 0.57rem; }
  .habit-check { width: 18px; height: 18px; font-size: 0.62rem; }
  .habit-name-btn { font-size: 0.9em; }

  .data-table th,
  .data-table td {
    padding: 6px 6px;
    font-size: 0.74rem;
  }

  .fsrs-ratings { grid-template-columns: repeat(2, 1fr); }

  .modal-backdrop {
    padding: 20px 12px 16px;
  }

  .toast-root { bottom: 72px; left: 12px; right: 12px; }
}
