:root {
  color-scheme: light dark;
  --bg: #fffaf7;
  --surface: #ffffff;
  --surface-2: #fff1eb;
  --text: #2d2526;
  --muted: #766a6c;
  --line: #eadedb;
  --brand: #b84d62;
  --brand-strong: #91364a;
  --brand-soft: #ffe2e7;
  --good: #217a5b;
  --good-soft: #dff5eb;
  --warn: #956211;
  --warn-soft: #fff1c7;
  --danger: #ae2f3d;
  --danger-soft: #ffe1e5;
  --shadow: 0 12px 36px rgb(88 48 56 / 14%);
  --radius: 22px;
  --dock-space: calc(94px + env(safe-area-inset-bottom));
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #171314;
    --surface: #211b1d;
    --surface-2: #2b2023;
    --text: #f9eef0;
    --muted: #bcaeb1;
    --line: #413438;
    --brand: #f18ba0;
    --brand-strong: #ffb0c0;
    --brand-soft: #482932;
    --good: #73d5ae;
    --good-soft: #1d3c31;
    --warn: #f2c36f;
    --warn-soft: #40351d;
    --danger: #ff9ba5;
    --danger-soft: #47252a;
    --shadow: 0 14px 42px rgb(0 0 0 / 34%);
  }
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body { margin: 0; min-width: 320px; min-height: 100dvh; background: var(--bg); color: var(--text); }
button, input, select, textarea { font: inherit; color: inherit; }
button, select, input[type="checkbox"] { cursor: pointer; }
button, input, select, textarea { min-height: 44px; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }
[hidden] { display: none !important; }

.shell { width: min(100%, 680px); min-height: 100dvh; margin: 0 auto; padding: env(safe-area-inset-top) 16px var(--dock-space); }
.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 0 12px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(18px); }
.topbar h1 { margin: 0; font-size: clamp(1.45rem, 5vw, 1.85rem); letter-spacing: -.04em; }
.top-actions { display: flex; gap: 8px; }
.eyebrow { margin: 0 0 4px; color: var(--brand); font-size: .75rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.subtle { color: var(--muted); }
.stack { display: grid; gap: 12px; }
.section { margin-top: 24px; }
.section-head { display: flex; justify-content: space-between; align-items: end; gap: 12px; margin-bottom: 10px; }
.section-head h2 { margin: 0; font-size: 1.08rem; }
.section-head p { margin: 0; font-size: .82rem; color: var(--muted); }

.card { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: 0 2px 12px rgb(88 48 56 / 5%); padding: 16px; }
.hero { overflow: hidden; position: relative; padding: 22px; border: 0; background: linear-gradient(135deg, #9c354c, #d86f7f); color: white; box-shadow: var(--shadow); }
.hero::after { content: "♡"; position: absolute; right: 16px; bottom: -26px; color: rgb(255 255 255 / 17%); font-size: 8rem; }
.hero .eyebrow { color: #ffe1e6; }
.hero strong { display: block; margin: 7px 0; font-size: clamp(2.2rem, 12vw, 4rem); letter-spacing: -.06em; }
.hero p { margin: 0; color: #fff2f4; }
.empty { padding: 24px 18px; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: var(--radius); }
.empty strong { display: block; color: var(--text); margin-bottom: 5px; }
.notice { padding: 12px 14px; border-radius: 16px; background: var(--warn-soft); color: var(--warn); font-size: .9rem; }
.notice.error { background: var(--danger-soft); color: var(--danger); }
.notice.offline { position: sticky; top: 76px; z-index: 9; }

.button, .icon-button, .status-button { border: 0; border-radius: 14px; background: var(--brand); color: white; font-weight: 750; padding: 10px 15px; }
.button.secondary, .icon-button { background: var(--surface-2); color: var(--text); }
.button.ghost { background: transparent; border: 1px solid var(--line); color: var(--text); }
.button.danger { background: var(--danger); }
.button:disabled, .status-button:disabled { opacity: .48; cursor: not-allowed; }
.icon-button { width: 44px; padding: 0; display: grid; place-items: center; }
.full { width: 100%; }
.button-row { display: flex; flex-wrap: wrap; gap: 8px; }
.quick-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; }
.quick-grid button { min-height: 72px; display: grid; place-items: center; gap: 3px; }

.dock { position: fixed; z-index: 30; left: 50%; bottom: max(10px, env(safe-area-inset-bottom)); transform: translateX(-50%); width: min(calc(100% - 20px), 650px); display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; padding: 7px; border: 1px solid var(--line); border-radius: 24px; background: color-mix(in srgb, var(--surface) 91%, transparent); box-shadow: var(--shadow); backdrop-filter: blur(20px); }
.dock button { min-width: 0; min-height: 54px; border: 0; border-radius: 18px; background: transparent; color: var(--muted); padding: 6px 2px; font-size: .68rem; font-weight: 700; }
.dock button span { display: block; font-size: 1.25rem; line-height: 1.1; margin-bottom: 2px; }
.dock button[aria-current="page"] { color: var(--brand-strong); background: var(--brand-soft); }

.filters { display: flex; gap: 8px; padding: 3px 0 10px; overflow-x: auto; scrollbar-width: none; }
.filters::-webkit-scrollbar { display: none; }
.chip { white-space: nowrap; min-height: 44px; padding: 8px 13px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--muted); font-weight: 700; }
.load-status { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; font-size: .9rem; }
.load-status[role="status"] { color: var(--muted); padding: 8px 0; }
.checklist-group + .checklist-group { margin-top: 10px; }
.chip.active { color: var(--brand-strong); border-color: var(--brand); background: var(--brand-soft); }
.search-row { display: grid; grid-template-columns: 1fr minmax(110px, .4fr); gap: 8px; margin-bottom: 12px; }

.record { display: grid; gap: 10px; }
.record.muted { opacity: .62; }
.record.muted .record-title { text-decoration: line-through; }
.record-head { display: flex; justify-content: space-between; align-items: start; gap: 10px; }
.record-title { margin: 0; font-size: 1rem; line-height: 1.35; }
.record-meta { display: flex; flex-wrap: wrap; gap: 5px 10px; color: var(--muted); font-size: .82rem; }
.record-description { margin: 0; color: var(--muted); white-space: pre-wrap; overflow-wrap: anywhere; }
.pill { display: inline-flex; align-items: center; min-height: 28px; border-radius: 999px; padding: 4px 9px; background: var(--surface-2); color: var(--muted); font-size: .75rem; font-weight: 800; }
.pill.high, .pill.overdue { color: var(--danger); background: var(--danger-soft); }
.pill.good { color: var(--good); background: var(--good-soft); }
.status-button { min-height: 44px; background: var(--brand-soft); color: var(--brand-strong); }
.record-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.record-actions .button { flex: 1; }
.link { color: var(--brand-strong); overflow-wrap: anywhere; }
.item-control { display: grid; gap: 12px; }
.item-control-main { display: flex; align-items: center; gap: 12px; }
.item-control-main p { margin: 3px 0 0; font-size: .82rem; }
.item-swatch { flex: 0 0 auto; width: 36px; height: 36px; border-radius: 12px; background: var(--item-color); box-shadow: inset 0 0 0 1px rgb(0 0 0 / 9%); }

.calendar-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.calendar-bar h2 { margin: 0; font-size: 1.12rem; }
.calendar { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; }
.weekday { min-height: 30px; display: grid; place-items: center; color: var(--muted); font-size: .76rem; }
.day { position: relative; aspect-ratio: 1; min-height: 44px; border: 0; border-radius: 14px; background: transparent; }
.day.outside { color: color-mix(in srgb, var(--muted) 45%, transparent); }
.day.today { outline: 2px solid var(--brand); }
.day.selected { color: white; background: var(--brand); }
.dots { position: absolute; left: 50%; bottom: 5px; transform: translateX(-50%); display: flex; gap: 2px; }
.dot { width: 4px; height: 4px; border-radius: 50%; background: var(--brand); }
.day.selected .dot { background: white; }

.sheet-backdrop { position: fixed; z-index: 50; inset: 0; display: flex; align-items: end; justify-content: center; background: rgb(24 15 18 / 50%); }
.sheet { width: min(100%, 680px); max-height: min(92dvh, 900px); display: flex; flex-direction: column; padding: 0 16px calc(16px + env(safe-area-inset-bottom)); border-radius: 28px 28px 0 0; background: var(--surface); box-shadow: var(--shadow); animation: rise .2s ease-out; }
.sheet-handle { width: 42px; height: 5px; margin: 9px auto 3px; border-radius: 99px; background: var(--line); }
.sheet-header { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0; }
.sheet-header h2 { margin: 0; }
.sheet-body { overflow-y: auto; overscroll-behavior: contain; padding: 4px 1px 12px; }
@keyframes rise { from { transform: translateY(30px); opacity: .7; } }

.form { display: grid; gap: 14px; }
.field { display: grid; gap: 6px; }
.field > span { font-size: .84rem; font-weight: 750; }
.field input, .field select, .field textarea { width: 100%; border: 1px solid var(--line); border-radius: 14px; background: var(--bg); padding: 10px 12px; }
.field textarea { min-height: 92px; resize: vertical; }
.field small { color: var(--muted); }
.field.inline { display: flex; align-items: center; gap: 10px; }
.field.inline input { width: 24px; min-height: 24px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-error { color: var(--danger); min-height: 1.2em; margin: 0; font-size: .85rem; }
.segmented { display: grid; gap: 7px; }
.segmented button { border: 1px solid var(--line); border-radius: 14px; background: var(--bg); text-align: left; padding: 10px 12px; }
.segmented button.active { background: var(--brand-soft); border-color: var(--brand); color: var(--brand-strong); }

.auth { min-height: 100dvh; display: grid; place-items: center; padding: max(28px, env(safe-area-inset-top)) 20px max(28px, env(safe-area-inset-bottom)); }
.auth-card { width: min(100%, 420px); }
.auth-mark { width: 70px; height: 70px; display: grid; place-items: center; margin-bottom: 24px; border-radius: 24px; background: var(--brand-soft); color: var(--brand); font-size: 2.2rem; }
.auth h1 { font-size: 2rem; margin: 0 0 8px; }
.auth p { color: var(--muted); }
.user-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 20px; }
.user-card { min-height: 120px; padding: 14px; border: 1px solid var(--line); border-radius: 20px; background: var(--surface); text-align: left; }
.user-card strong { display: block; margin-top: 18px; }

.toast-region { position: fixed; z-index: 100; left: 50%; bottom: calc(var(--dock-space) + 10px); transform: translateX(-50%); width: min(calc(100% - 32px), 430px); pointer-events: none; }
.toast { margin-top: 8px; padding: 12px 14px; border-radius: 14px; background: var(--text); color: var(--bg); box-shadow: var(--shadow); }
.loading { min-height: 60dvh; display: grid; place-items: center; color: var(--muted); }

@media (max-width: 390px) {
  .search-row, .form-grid { grid-template-columns: 1fr; }
  .quick-grid button { font-size: .85rem; }
}

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