/* MyUpkeep — professional soft-home UI */

:root {
  --bg: #f3efe8;
  --bg-deep: #ebe4d8;
  --surface: #fffcf7;
  --surface-2: #f8f3eb;
  --text: #1c1915;
  --text-2: #5c5348;
  --text-3: #8a7f72;
  --line: rgba(28, 25, 21, 0.08);
  --line-strong: rgba(28, 25, 21, 0.14);
  --shadow-sm: 0 1px 2px rgba(28, 25, 21, 0.04);
  --shadow: 0 4px 16px rgba(28, 25, 21, 0.06), 0 1px 3px rgba(28, 25, 21, 0.04);
  --shadow-lg: 0 16px 40px rgba(28, 25, 21, 0.12);
  --accent: #b07a3a;
  --accent-2: #c9924f;
  --accent-ink: #fffaf3;
  --accent-soft: rgba(176, 122, 58, 0.14);
  --accent-ring: rgba(176, 122, 58, 0.35);
  --danger: #c23b2e;
  --danger-soft: rgba(194, 59, 46, 0.1);
  --success: #2f7d4a;
  --success-soft: rgba(47, 125, 74, 0.12);
  --radius-xs: 10px;
  --radius-sm: 14px;
  --radius: 18px;
  --radius-lg: 24px;
  --pad: 20px;
  --tabbar-h: 68px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --font: "Plus Jakarta Sans", "SF Pro Text", system-ui, -apple-system, sans-serif;
  --display: "Fraunces", "New York", Georgia, serif;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --cat-home: #3b82f6;
  --cat-vehicle: #16a34a;
  --cat-finance: #9333ea;
  --cat-health: #0d9488;
  --cat-license: #ea580c;
  --cat-personal: #78716c;
  --cat-other: #94a3b8;
}

html[data-theme="dark"] {
  --bg: #14110e;
  --bg-deep: #0f0d0b;
  --surface: #1f1a15;
  --surface-2: #2a231c;
  --text: #f6f0e7;
  --text-2: #c2b6a6;
  --text-3: #8f8375;
  --line: rgba(246, 240, 231, 0.08);
  --line-strong: rgba(246, 240, 231, 0.14);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.25);
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 20px 48px rgba(0, 0, 0, 0.45);
  --accent: #d4a15c;
  --accent-2: #e0b575;
  --accent-ink: #1a140e;
  --accent-soft: rgba(212, 161, 92, 0.16);
  --accent-ring: rgba(212, 161, 92, 0.4);
  --danger: #f07167;
  --danger-soft: rgba(240, 113, 103, 0.14);
  --success: #5dbe7e;
  --success-soft: rgba(93, 190, 126, 0.14);
}

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

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(201, 146, 79, 0.12), transparent 55%),
    radial-gradient(900px 500px at 100% 0%, rgba(176, 122, 58, 0.08), transparent 50%),
    var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
  letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}

html[data-theme="dark"] body {
  background:
    radial-gradient(1000px 500px at 0% 0%, rgba(212, 161, 92, 0.08), transparent 50%),
    var(--bg);
}

body {
  max-width: 430px;
  margin: 0 auto;
}

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

button {
  cursor: pointer;
  border: none;
  background: none;
}

.app {
  min-height: 100dvh;
  padding: calc(10px + var(--safe-t)) var(--pad) calc(var(--tabbar-h) + var(--safe-b) + 18px);
  display: flex;
  flex-direction: column;
}

/* ---------- Header ---------- */
.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 22px;
}

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

.brand-mark {
  width: 46px;
  height: 46px;
  border-radius: 15px;
  background: linear-gradient(145deg, #e8c99a 0%, var(--accent) 55%, #8f5f28 100%);
  color: #1c140c;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

.brand-mark svg {
  width: 24px;
  height: 24px;
}

.brand-title {
  margin: 0;
  font-family: var(--display);
  font-size: 1.4rem;
  font-weight: 650;
  letter-spacing: -0.03em;
  line-height: 1.15;
}

.brand-sub {
  margin: 3px 0 0;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-3);
  letter-spacing: 0;
}

/* ---------- Views ---------- */
.main {
  flex: 1;
  min-height: 0;
}

.view {
  display: none;
  animation: rise 0.28s var(--ease);
}

.view.active {
  display: block;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.view-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.view-head > .btn,
.view-head > .nav-cluster {
  margin-top: 4px;
  flex-shrink: 0;
}

.view-head h2 {
  margin: 0;
  font-family: var(--display);
  font-size: 1.65rem;
  font-weight: 650;
  letter-spacing: -0.03em;
  line-height: 1.15;
}

.view-kicker {
  margin: 0 0 4px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-3);
}

.range-label {
  margin: -4px 0 14px;
  color: var(--text-2);
  font-size: 0.9rem;
  font-weight: 550;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 18px;
  border-radius: 999px;
  font-weight: 650;
  font-size: 0.95rem;
  letter-spacing: -0.01em;
  transition: transform 0.15s var(--ease), background 0.15s ease, box-shadow 0.15s ease;
}

.btn:active {
  transform: scale(0.975);
}

.btn svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.btn-primary {
  background: linear-gradient(180deg, var(--accent-2), var(--accent));
  color: var(--accent-ink);
  box-shadow: 0 6px 16px rgba(176, 122, 58, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

html[data-theme="dark"] .btn-primary {
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow-sm);
}

.btn-ghost {
  background: transparent;
  color: var(--text-2);
}

.btn-danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.btn-sm {
  min-height: 38px;
  padding: 0 14px;
  font-size: 0.86rem;
}

.btn-block {
  width: 100%;
}

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  color: var(--text-2);
  box-shadow: var(--shadow-sm);
  transition: background 0.15s ease, transform 0.15s var(--ease);
}

.icon-btn:active {
  transform: scale(0.96);
  background: var(--surface-2);
}

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

.chip-btn {
  min-height: 36px;
  padding: 0 14px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line);
  font-weight: 650;
  font-size: 0.82rem;
  color: var(--text-2);
  box-shadow: var(--shadow-sm);
}

.nav-cluster {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ---------- Cards & layout ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}

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

.stack.compact {
  gap: 6px;
}

.muted {
  color: var(--text-2);
}

.small {
  font-size: 0.85rem;
}

.footer-note {
  margin: 20px 8px 0;
  font-size: 0.78rem;
  color: var(--text-3);
  text-align: center;
  line-height: 1.5;
}

/* ---------- Home hero + stats ---------- */
.home-hero {
  margin-bottom: 16px;
}

.home-hero h2 {
  margin: 0;
  font-family: var(--display);
  font-size: 1.75rem;
  font-weight: 650;
  letter-spacing: -0.03em;
  line-height: 1.15;
}

.home-hero p {
  margin: 6px 0 0;
  color: var(--text-2);
  font-size: 0.92rem;
  font-weight: 500;
}

.summary-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 18px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 10px;
  box-shadow: var(--shadow-sm);
  text-align: center;
}

.stat-card .n {
  display: block;
  font-family: var(--display);
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.stat-card .l {
  display: block;
  margin-top: 4px;
  font-size: 0.68rem;
  font-weight: 650;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--text-3);
}

.stat-card.overdue {
  background: var(--danger-soft);
  border-color: transparent;
}

.stat-card.overdue .n {
  color: var(--danger);
}

.stat-card.soon {
  background: var(--accent-soft);
  border-color: transparent;
}

.stat-card.soon .n {
  color: var(--accent);
}

.section-label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 18px 0 10px;
  font-size: 0.72rem;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-3);
}

.section-label:first-child {
  margin-top: 2px;
}

.section-label.danger {
  color: var(--danger);
}

.section-label::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

/* ---------- Task cards ---------- */
.task-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
  text-align: left;
  width: 100%;
  transition: transform 0.15s var(--ease), box-shadow 0.15s ease;
  position: relative;
  overflow: hidden;
}

.task-card::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--stripe, var(--cat-other));
  border-radius: 4px 0 0 4px;
}

.task-card:active {
  transform: scale(0.99);
}

.task-card.overdue {
  background: linear-gradient(90deg, var(--danger-soft), var(--surface) 42%);
  border-color: rgba(194, 59, 46, 0.18);
}

.task-check {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1.5px solid var(--line-strong);
  background: var(--surface-2);
  display: grid;
  place-items: center;
  color: var(--text-3);
  flex-shrink: 0;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.task-check:active,
.task-check:hover {
  border-color: var(--success);
  color: var(--success);
  background: var(--success-soft);
}

.task-check svg {
  width: 16px;
  height: 16px;
}

.task-body {
  min-width: 0;
  padding-left: 2px;
}

.task-title {
  margin: 0;
  font-weight: 650;
  font-size: 0.98rem;
  letter-spacing: -0.015em;
  word-break: break-word;
  line-height: 1.3;
}

.task-card.overdue .task-title {
  color: var(--danger);
}

.task-meta {
  margin: 6px 0 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.cat-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #fff;
  line-height: 1.2;
}

.cat-chip::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.85);
}

.due-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-2);
}

.due-badge.overdue {
  color: var(--danger);
}

.due-badge.soon {
  color: var(--accent);
}

.task-chevron {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: var(--text-3);
  flex-shrink: 0;
}

.task-chevron svg {
  width: 16px;
  height: 16px;
}

/* ---------- Empty ---------- */
.empty {
  text-align: center;
  padding: 40px 22px;
  color: var(--text-2);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.empty-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 14px;
  border-radius: 18px;
  background: var(--accent-soft);
  color: var(--accent);
  display: grid;
  place-items: center;
}

.empty-icon svg {
  width: 26px;
  height: 26px;
}

.empty strong {
  display: block;
  color: var(--text);
  margin-bottom: 6px;
  font-family: var(--display);
  font-size: 1.15rem;
  font-weight: 650;
  letter-spacing: -0.02em;
}

.empty span {
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--text-3);
}

/* ---------- Filters ---------- */
.filter-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 0 12px;
  margin-bottom: 4px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

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

.filter-chip {
  flex: 0 0 auto;
  min-height: 34px;
  padding: 0 13px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: 0.8rem;
  font-weight: 650;
  color: var(--text-2);
  box-shadow: var(--shadow-sm);
  transition: background 0.15s ease, color 0.15s ease;
}

.filter-chip.active {
  background: var(--text);
  color: var(--bg);
  border-color: transparent;
  box-shadow: none;
}

/* ---------- Week ---------- */
.week-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.week-day {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow-sm);
}

.week-day.is-today {
  border-color: var(--accent-ring);
  box-shadow: 0 0 0 3px var(--accent-soft), var(--shadow-sm);
}

.week-day-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 4px;
  gap: 10px;
}

.week-day-head strong {
  font-weight: 700;
  font-size: 0.98rem;
  letter-spacing: -0.02em;
}

.week-day-head span {
  font-size: 0.78rem;
  font-weight: 550;
  color: var(--text-3);
}

.today-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.68rem;
  font-weight: 750;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.day-task {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 4px;
  border-top: 1px solid var(--line);
  font-size: 0.92rem;
  font-weight: 550;
  width: 100%;
  text-align: left;
  color: var(--text);
  transition: background 0.12s ease;
  border-radius: 8px;
  margin: 0 -4px;
  padding-left: 8px;
  padding-right: 8px;
}

.day-task:first-of-type {
  border-top: none;
  margin-top: 4px;
}

.day-task:active {
  background: var(--surface-2);
}

.day-task .dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--dot, #999) 18%, transparent);
}

.day-task .title {
  flex: 1;
  min-width: 0;
  letter-spacing: -0.01em;
}

.day-task.overdue .title {
  color: var(--danger);
  font-weight: 650;
}

.day-empty {
  font-size: 0.84rem;
  color: var(--text-3);
  padding: 8px 0 2px;
  font-weight: 500;
}

/* ---------- Month ---------- */
.month-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 12px 10px 14px;
  box-shadow: var(--shadow);
  margin-bottom: 14px;
}

.month-dow {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  margin-bottom: 6px;
  text-align: center;
  font-size: 0.68rem;
  font-weight: 750;
  color: var(--text-3);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.month-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 3px;
}

.month-cell {
  aspect-ratio: 1;
  border-radius: 12px;
  border: 1px solid transparent;
  background: transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-size: 0.84rem;
  font-weight: 650;
  padding: 2px;
  min-height: 42px;
  color: var(--text);
  transition: background 0.12s ease;
}

.month-cell.muted {
  opacity: 0.28;
}

.month-cell.today .day-num {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-ink);
  display: grid;
  place-items: center;
  font-size: 0.8rem;
}

.month-cell.selected:not(.today) {
  background: var(--accent-soft);
}

.month-cell.selected.today {
  box-shadow: 0 0 0 2px var(--accent-ring);
}

.month-cell.has-overdue .day-num {
  color: var(--danger);
}

.month-cell.today.has-overdue .day-num {
  color: var(--accent-ink);
  background: var(--danger);
}

.month-cell .dots {
  display: flex;
  gap: 2px;
  flex-wrap: wrap;
  justify-content: center;
  max-width: 100%;
  min-height: 5px;
}

.month-cell .dots i {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  display: block;
}

.day-detail {
  padding: 16px;
}

.day-detail h3 {
  margin: 0 0 12px;
  font-size: 0.95rem;
  font-family: var(--display);
  font-weight: 650;
  letter-spacing: -0.02em;
}

/* ---------- Vault ---------- */
.vault-gate {
  text-align: center;
  padding: 36px 22px 28px;
  position: relative;
  overflow: hidden;
}

.vault-gate::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 0%, var(--accent-soft), transparent 55%);
  pointer-events: none;
}

.vault-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 14px;
  border-radius: 20px;
  background: linear-gradient(145deg, var(--surface-2), var(--surface));
  border: 1px solid var(--line);
  color: var(--accent);
  display: grid;
  place-items: center;
  position: relative;
  box-shadow: var(--shadow);
}

.vault-icon svg {
  width: 28px;
  height: 28px;
}

.vault-gate h3 {
  margin: 0 0 8px;
  font-family: var(--display);
  font-size: 1.35rem;
  font-weight: 650;
  letter-spacing: -0.02em;
  position: relative;
}

.vault-gate .muted {
  position: relative;
  max-width: 280px;
  margin: 0 auto;
  line-height: 1.5;
  font-size: 0.9rem;
}

.pin-row {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin: 22px 0 14px;
  position: relative;
}

.pin-digit {
  width: 52px;
  height: 60px;
  border-radius: 16px;
  border: 1.5px solid var(--line-strong);
  background: var(--bg);
  text-align: center;
  font-size: 1.45rem;
  font-weight: 700;
  letter-spacing: 0;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.04);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.pin-digit:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.error-text {
  color: var(--danger);
  font-size: 0.88rem;
  font-weight: 600;
  margin: 0 0 12px;
  position: relative;
}

.vault-card {
  text-align: left;
  width: 100%;
  transition: transform 0.15s var(--ease);
  padding: 16px;
}

.vault-card:active {
  transform: scale(0.99);
}

.vault-card .type-label {
  font-size: 0.68rem;
  font-weight: 750;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--accent);
  margin: 0 0 6px;
}

.vault-card h3 {
  margin: 0 0 12px;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.vault-fields {
  display: grid;
  gap: 0;
}

.vault-fields .field {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.88rem;
  padding: 9px 0;
  border-top: 1px solid var(--line);
}

.vault-fields .field:first-child {
  border-top: none;
  padding-top: 0;
}

.vault-fields .k {
  color: var(--text-3);
  font-weight: 550;
}

.vault-fields .v {
  font-weight: 650;
  text-align: right;
  word-break: break-all;
  letter-spacing: -0.01em;
}

/* ---------- Settings ---------- */
.settings-card {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 6px 4px;
  overflow: hidden;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 12px;
  border-radius: var(--radius-sm);
  transition: background 0.12s ease;
}

.settings-row:active {
  background: var(--surface-2);
}

.settings-row + .settings-row {
  border-top: 1px solid var(--line);
  border-radius: 0;
}

.settings-row:last-child {
  border-radius: 0 0 var(--radius) var(--radius);
}

.settings-row:first-child {
  border-radius: var(--radius) var(--radius) 0 0;
}

.settings-row strong {
  display: block;
  font-size: 0.94rem;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.settings-row p {
  margin: 3px 0 0;
  color: var(--text-3);
}

.file-label {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}

/* ---------- Tab bar ---------- */
.tabbar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  width: min(430px, 100%);
  height: calc(var(--tabbar-h) + var(--safe-b));
  padding: 6px 8px calc(6px + var(--safe-b));
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 2px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(20px);
  -webkit-backdrop-filter: saturate(1.4) blur(20px);
  border-top: 1px solid var(--line);
  z-index: 40;
  box-shadow: 0 -8px 24px rgba(28, 25, 21, 0.04);
}

.tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-size: 0.62rem;
  font-weight: 650;
  color: var(--text-3);
  border-radius: 14px;
  min-height: 52px;
  padding: 6px 2px;
  letter-spacing: 0;
  transition: color 0.15s ease, background 0.15s ease;
}

.tab svg {
  width: 20px;
  height: 20px;
  opacity: 0.75;
}

.tab.active {
  color: var(--accent);
  background: var(--accent-soft);
}

.tab.active svg {
  opacity: 1;
}

/* ---------- Overlay / sheet ---------- */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(16, 12, 8, 0.48);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fade 0.2s ease;
}

.overlay[hidden] {
  display: none !important;
}

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

.sheet {
  width: min(430px, 100%);
  max-height: min(92dvh, 900px);
  background: var(--surface);
  border-radius: 28px 28px 0 0;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  padding-bottom: calc(14px + var(--safe-b));
  animation: sheetUp 0.28s var(--ease);
  border: 1px solid var(--line);
  border-bottom: none;
}

@keyframes sheetUp {
  from {
    transform: translateY(28px);
    opacity: 0.7;
  }
  to {
    transform: none;
    opacity: 1;
  }
}

.sheet-handle {
  width: 36px;
  height: 4px;
  border-radius: 999px;
  background: var(--line-strong);
  margin: 10px auto 0;
}

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px 10px;
  gap: 12px;
}

.sheet-head h2 {
  margin: 0;
  font-family: var(--display);
  font-size: 1.25rem;
  font-weight: 650;
  letter-spacing: -0.02em;
}

.sheet-body {
  padding: 4px 18px 18px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* ---------- Forms ---------- */
.form-stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.field-group label {
  display: block;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-3);
  margin-bottom: 7px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.field-group input,
.field-group select,
.field-group textarea {
  width: 100%;
  min-height: 48px;
  border-radius: 14px;
  border: 1.5px solid var(--line);
  background: var(--bg);
  padding: 12px 14px;
  font-weight: 500;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field-group textarea {
  min-height: 96px;
  resize: vertical;
  line-height: 1.45;
}

.field-group input:focus,
.field-group select:focus,
.field-group textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
  background: var(--surface);
}

.form-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 6px;
}

.form-actions.row {
  flex-direction: row;
}

.form-actions.row .btn {
  flex: 1;
}

.detail-block {
  margin-bottom: 16px;
}

.detail-block h3 {
  margin: 0 0 10px;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-3);
  font-weight: 750;
}

.detail-title {
  margin: 10px 0 0;
  font-size: 1.05rem;
  font-weight: 650;
  line-height: 1.4;
}

.history-item {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 8px;
}

.history-item .hi-top {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-weight: 650;
  font-size: 0.92rem;
}

.history-item .hi-note {
  margin: 5px 0 0;
  font-size: 0.86rem;
  color: var(--text-2);
  line-height: 1.4;
}

.linkish {
  color: var(--accent);
  font-weight: 700;
  font-size: 0.82rem;
  min-height: 32px;
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  transform: translateX(-50%) translateY(8px);
  bottom: calc(var(--tabbar-h) + var(--safe-b) + 14px);
  z-index: 200;
  background: var(--text);
  color: var(--bg);
  padding: 12px 20px;
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 650;
  box-shadow: var(--shadow-lg);
  max-width: min(380px, calc(100% - 32px));
  text-align: center;
  animation: toastIn 0.25s var(--ease);
  letter-spacing: -0.01em;
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

.toast[hidden] {
  display: none !important;
}

/* ---------- Utility ---------- */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.hint-line {
  margin: 6px 0 0;
  font-size: 0.8rem;
  color: var(--text-3);
  line-height: 1.4;
}
