/* ===== 디자인 토큰 (색상·간격) — 테마는 여기만 바꾸면 전체에 반영됩니다 ===== */
:root {
  --accent: #2f6fde;
  --accent-soft: color-mix(in srgb, var(--accent) 12%, transparent);
  --bg: #f7f7f5;
  --surface: #ffffff;
  --surface-2: #f2f2f0;
  --border: #e5e5e2;
  --text: #1f1f1d;
  --text-2: #62625e;
  --text-3: #9a9a95;
  --danger: #d23b3b;
  --danger-soft: #fdeceb;
  --warn: #b86e00;
  --warn-soft: #fff3df;
  --ok: #1e8e5a;
  --ok-soft: #e4f4eb;
  --c-work: #2f6fde;
  --c-study: #1e8e5a;
  --c-personal: #d9822b;
  --c-finance: #7c5cd6;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 14px rgba(0,0,0,.05);
  --font: "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", system-ui, -apple-system, sans-serif;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #161616;
  --surface: #1f1f1f;
  --surface-2: #2a2a2a;
  --border: #333331;
  --text: #ececea;
  --text-2: #a8a8a3;
  --text-3: #74746f;
  --danger: #f26b6b;
  --danger-soft: #3a2222;
  --warn: #f0a640;
  --warn-soft: #3a2e1a;
  --ok: #4cc28a;
  --ok-soft: #1d3328;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 14px rgba(0,0,0,.25);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
svg.i { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ===== 앱 골격 ===== */
.proto-banner {
  background: var(--warn-soft); color: var(--warn);
  font-size: 12px; text-align: center; padding: 6px 12px;
  border-bottom: 1px solid var(--border);
}
.app { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: calc(100vh - 31px); }
.sidebar {
  background: var(--surface); border-right: 1px solid var(--border);
  padding: 14px 10px; position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 2px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 10px 16px; font-weight: 700; font-size: 15px; }
.brand-mark { width: 28px; height: 28px; border-radius: 8px; background: var(--accent); color: #fff; display: grid; place-items: center; font-size: 13px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius-sm);
  color: var(--text-2); cursor: pointer; transition: background .15s;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav-item .count { margin-left: auto; font-size: 11px; background: var(--danger); color: #fff; border-radius: 10px; padding: 0 6px; }
.nav-sep { height: 1px; background: var(--border); margin: 10px 6px; }
.nav-stage { margin-left: auto; font-size: 10px; color: var(--text-3); }

.main { min-width: 0; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 24px; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--border);
}
.topbar h1 { font-size: 17px; margin: 0; font-weight: 700; white-space: nowrap; }
.topbar .search { margin-left: auto; position: relative; width: min(320px, 40vw); }
.topbar .search input { width: 100%; padding: 7px 10px 7px 32px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.topbar .search svg { position: absolute; left: 9px; top: 9px; width: 16px; height: 16px; color: var(--text-3); }
.icon-btn {
  position: relative; width: 34px; height: 34px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); display: grid; place-items: center; cursor: pointer; color: var(--text-2);
}
.icon-btn:hover { color: var(--text); }
.icon-btn .dot { position: absolute; top: -4px; right: -4px; min-width: 16px; height: 16px; border-radius: 8px; background: var(--danger); color: #fff; font-size: 10px; display: grid; place-items: center; padding: 0 4px; }
.view { padding: 22px 24px 40px; max-width: 1400px; }

.bottomnav { display: none; }
.drawer-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 50; }
.drawer { position: fixed; left: 0; right: 0; bottom: 0; background: var(--surface); border-radius: 16px 16px 0 0; padding: 12px 12px 24px; z-index: 51; max-height: 75vh; overflow-y: auto; }
.drawer .grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.drawer .nav-item { flex-direction: column; gap: 4px; font-size: 12px; text-align: center; padding: 12px 4px; }

/* ===== 공통 부품 ===== */
.page-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head h2 { margin: 0; font-size: 22px; }
.page-head .sub { color: var(--text-2); }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface); cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.07); }
.btn.danger { color: var(--danger); }
.btn.sm { padding: 4px 8px; font-size: 12px; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-h { display: flex; align-items: center; gap: 8px; padding: 14px 16px 6px; }
.card-h h3 { margin: 0; font-size: 14px; font-weight: 700; }
.card-h .more { margin-left: auto; font-size: 12px; color: var(--text-3); cursor: pointer; }
.card-b { padding: 6px 16px 14px; }
.empty { color: var(--text-3); padding: 14px 0; text-align: center; font-size: 13px; }

.chip {
  display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600; border: 1px solid transparent; white-space: nowrap;
}
.stage { font-size: 11px; padding: 1px 8px; border-radius: 999px; font-weight: 600; white-space: nowrap; }
.stage.design { background: var(--surface-2); color: var(--text-2); border: 1px dashed var(--text-3); }
.stage.proto { background: var(--warn-soft); color: var(--warn); }
.stage.live { background: var(--accent-soft); color: var(--accent); }
.stage.tested { background: var(--ok-soft); color: var(--ok); }
.stage.bug { background: var(--danger-soft); color: var(--danger); }
.stage.none { background: transparent; color: var(--text-3); border: 1px solid var(--border); }

.imp { display: inline-grid; place-items: center; width: 18px; font-size: 14px; }
.imp.critical { color: var(--danger); }
.imp.important { color: var(--warn); }
.imp.normal { color: var(--text-3); }
.dday { font-size: 12px; font-weight: 700; white-space: nowrap; }
.dday.over { color: var(--danger); }
.dday.soon { color: var(--warn); }
.dday.far { color: var(--text-3); font-weight: 500; }
.dot-c { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; }
.muted { color: var(--text-2); }
.faint { color: var(--text-3); font-size: 12px; }

.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 8px; padding: 7px 0; border-bottom: 1px solid var(--border); }
.list li:last-child { border-bottom: 0; }
.list li .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list li.critical { box-shadow: inset 3px 0 0 var(--danger); padding-left: 8px; }
.clickable { cursor: pointer; }
.clickable:hover { color: var(--accent); }
input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }

.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 12px; color: var(--text-2); font-weight: 600; }
.field input, .field select, .field textarea, .input {
  padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface);
}
.field textarea { min-height: 80px; resize: vertical; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid .full { grid-column: 1 / -1; }
.note { font-size: 12px; color: var(--text-2); background: var(--surface-2); padding: 8px 10px; border-radius: 8px; }
.note.warn { background: var(--warn-soft); color: var(--warn); }

/* 모달·토스트 */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 100; display: grid; place-items: center; padding: 16px; animation: fade .12s; }
.modal { background: var(--surface); border-radius: 14px; width: min(560px, 100%); max-height: 90vh; overflow-y: auto; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.modal.wide { width: min(760px, 100%); }
.modal-h { display: flex; align-items: center; padding: 16px 18px 8px; gap: 8px; }
.modal-h h3 { margin: 0; font-size: 16px; }
.modal-h .icon-btn { margin-left: auto; border: 0; }
.modal-b { padding: 8px 18px 4px; }
.modal-f { display: flex; gap: 8px; padding: 14px 18px 18px; justify-content: flex-end; flex-wrap: wrap; }
.modal-f .left { margin-right: auto; }
.toast-wrap { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { background: #2a2a28; color: #fff; padding: 10px 14px; border-radius: 10px; display: flex; gap: 12px; align-items: center; box-shadow: var(--shadow); animation: up .15s; font-size: 13px; }
.toast button { background: none; border: 0; color: #8fb6ff; font-weight: 700; cursor: pointer; }
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { opacity: 0; transform: translateY(6px); } }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; }
.tab { padding: 9px 12px; cursor: pointer; color: var(--text-2); border-bottom: 2px solid transparent; white-space: nowrap; }
.tab.active { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--surface); }
.seg button { border: 0; background: none; padding: 6px 12px; cursor: pointer; color: var(--text-2); }
.seg button.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

/* ===== 홈 대시보드 ===== */
.dash-head .date { font-size: 24px; font-weight: 700; }
.dash-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 16px; align-items: start; }
.dash-grid .span2 { grid-column: span 2; }
.dash-grid.editing .card { outline: 2px dashed var(--accent); outline-offset: 2px; }
.card-tools { margin-left: auto; display: flex; gap: 4px; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; padding: 14px 16px; }
.stat { padding: 10px 12px; border-radius: 8px; background: var(--surface-2); cursor: pointer; }
.stat .n { font-size: 22px; font-weight: 700; }
.stat .l { font-size: 12px; color: var(--text-2); }
.stat.red .n { color: var(--danger); }
.stat.amber .n { color: var(--warn); }
.money { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 10px; }
.money .l { font-size: 12px; color: var(--text-2); }
.money .n { font-weight: 700; font-size: 16px; }
.bar { height: 8px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.bar > div { height: 100%; background: var(--accent); border-radius: 4px; }
.week-days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.week-day { background: var(--surface-2); border-radius: 8px; padding: 6px; min-height: 90px; cursor: pointer; }
.week-day.today { outline: 2px solid var(--accent); }
.week-day .d { font-size: 12px; color: var(--text-2); margin-bottom: 4px; }
.week-day .e { font-size: 11px; padding: 1px 5px; border-radius: 4px; margin-bottom: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #fff; }
.hidden-cards { margin-top: 18px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.ai-quick { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

/* ===== 업무 관리 ===== */
.work-layout { display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: 18px; }
.cat-list { display: flex; flex-direction: column; gap: 2px; position: sticky; top: 70px; align-self: start; }
.cat-item { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-radius: 8px; cursor: pointer; color: var(--text-2); }
.cat-item:hover { background: var(--surface-2); }
.cat-item.active { background: var(--surface); box-shadow: var(--shadow); color: var(--text); font-weight: 600; }
.cat-item .n { margin-left: auto; font-size: 12px; color: var(--text-3); }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.toolbar .input { min-width: 0; }
.ptable { overflow: hidden; }
.prow { display: grid; grid-template-columns: 24px minmax(0, 2.4fr) 1.2fr 90px 80px 90px 1.1fr; gap: 10px; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--border); }
.prow:last-child { border-bottom: 0; }
.prow.head { font-size: 12px; color: var(--text-3); font-weight: 600; padding-top: 8px; padding-bottom: 8px; background: var(--surface-2); }
.prow:not(.head):hover { background: var(--surface-2); cursor: pointer; }
.prow .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prow .cell-sub { font-size: 12px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prow.crit { box-shadow: inset 3px 0 0 var(--danger); }
.progress { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-2); }
.progress .bar { flex: 1; height: 6px; }
.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(230px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 8px; }
.kcol { background: var(--surface-2); border-radius: var(--radius); padding: 10px; min-height: 200px; }
.kcol.drop { outline: 2px dashed var(--accent); }
.kcol h4 { margin: 0 0 8px; font-size: 13px; display: flex; gap: 6px; align-items: center; }
.kcard { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 10px; margin-bottom: 8px; cursor: grab; }
.kcard.crit { border-left: 3px solid var(--danger); }
.kcard .t { font-weight: 600; margin-bottom: 4px; }

.pd-head { display: flex; gap: 10px; align-items: flex-start; flex-wrap: wrap; margin-bottom: 14px; }
.pd-head h2 { margin: 0; font-size: 22px; }
.crumb { font-size: 12px; color: var(--text-3); margin-bottom: 6px; }
.info-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1px; background: var(--border); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; margin-bottom: 18px; }
.info-grid > div { background: var(--surface); padding: 10px 12px; }
.info-grid .l { font-size: 11.5px; color: var(--text-3); }
.info-grid select { border: 0; background: transparent; padding: 0; font-weight: 600; cursor: pointer; }
.dropzone { border: 2px dashed var(--border); border-radius: var(--radius); padding: 30px; text-align: center; color: var(--text-3); }
.prompt-box { width: 100%; min-height: 300px; font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; padding: 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); }

/* ===== 캘린더 ===== */
.cal-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.cal-bar .title { font-size: 20px; font-weight: 700; min-width: 150px; }
.cal-bar .right { margin-left: auto; display: flex; gap: 8px; }
.filters { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.fchip { padding: 4px 10px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; font-size: 12.5px; display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); }
.fchip.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.month { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--border); gap: 1px; }
.month .dow { background: var(--surface-2); padding: 6px; font-size: 12px; text-align: center; color: var(--text-2); font-weight: 600; }
.month .dow.sun, .mcell.sun .num { color: var(--danger); }
.month .dow.sat, .mcell.sat .num { color: var(--accent); }
.mcell { background: var(--surface); min-height: 112px; padding: 4px; display: flex; flex-direction: column; gap: 2px; cursor: pointer; min-width: 0; }
.mcell.other { background: color-mix(in srgb, var(--surface-2) 60%, var(--surface)); }
.mcell.other .num { opacity: .45; }
.mcell.drop { background: var(--accent-soft); }
.mcell .num { font-size: 12px; font-weight: 600; width: 24px; height: 24px; display: grid; place-items: center; border-radius: 50%; }
.mcell.today .num { background: var(--accent); color: #fff !important; }
.ev {
  font-size: 11.5px; padding: 1px 6px; border-radius: 4px; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  cursor: pointer; line-height: 18px;
}
.ev.timed { background: transparent !important; color: var(--text); padding-left: 2px; }
.ev.timed::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--evc); margin-right: 4px; }
.ev.crit { box-shadow: inset 0 0 0 1.5px var(--danger); }
.ev.cont { border-top-left-radius: 0; border-bottom-left-radius: 0; opacity: .85; }
.ev[draggable="true"] { cursor: grab; }
.ev.tx { background: transparent !important; color: var(--c-finance); font-weight: 600; }
.mcell .more { font-size: 11px; color: var(--text-2); padding-left: 4px; }

.tgrid-wrap { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.tgrid-head, .tgrid-allday { display: grid; grid-template-columns: 56px repeat(var(--cols), minmax(0, 1fr)); border-bottom: 1px solid var(--border); }
.tgrid-head > div { padding: 6px; text-align: center; font-size: 12px; color: var(--text-2); border-left: 1px solid var(--border); cursor: pointer; }
.tgrid-head > div:first-child, .tgrid-allday > div:first-child { border-left: 0; }
.tgrid-head .big { font-size: 18px; font-weight: 700; color: var(--text); }
.tgrid-head .today .big { color: var(--accent); }
.tgrid-allday > div { border-left: 1px solid var(--border); padding: 3px; min-height: 28px; display: flex; flex-direction: column; gap: 2px; }
.tgrid-allday > div:first-child { font-size: 11px; color: var(--text-3); display: grid; place-items: center; }
.tgrid-scroll { height: 600px; overflow-y: auto; position: relative; }
.tgrid { display: grid; grid-template-columns: 56px repeat(var(--cols), minmax(0, 1fr)); position: relative; }
.hours > div { height: 48px; font-size: 11px; color: var(--text-3); text-align: right; padding-right: 6px; transform: translateY(-7px); }
.tcol { position: relative; border-left: 1px solid var(--border); background: repeating-linear-gradient(to bottom, transparent 0, transparent 47px, var(--border) 47px, var(--border) 48px); }
.tcol.drop { background-color: var(--accent-soft); }
.tev { position: absolute; left: 2px; right: 2px; border-radius: 6px; padding: 3px 6px; font-size: 11.5px; color: #fff; overflow: hidden; cursor: grab; line-height: 1.3; border: 1px solid rgba(255,255,255,.4); }
.tev.crit { box-shadow: inset 0 0 0 2px var(--danger); }
.tev .tm { opacity: .85; font-size: 10.5px; }
.nowline { position: absolute; left: 0; right: 0; height: 2px; background: var(--danger); z-index: 3; pointer-events: none; }
.day-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 16px; }

/* ===== 설정 ===== */
.settings-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(380px, 1fr)); gap: 16px; align-items: start; }
.swatches { display: flex; gap: 8px; }
.swatch { width: 28px; height: 28px; border-radius: 50%; cursor: pointer; border: 3px solid transparent; }
.swatch.on { border-color: var(--text); }
.row-edit { display: flex; gap: 6px; align-items: center; padding: 4px 0; }
.row-edit input[type="text"] { flex: 1; min-width: 0; }
.row-edit input[type="color"] { width: 32px; height: 32px; padding: 0; border: 0; background: none; cursor: pointer; }
details.cat-edit { border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; margin-bottom: 6px; }
details.cat-edit summary { cursor: pointer; display: flex; align-items: center; gap: 8px; }
.status-table { width: 100%; border-collapse: collapse; }
.status-table td, .status-table th { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.status-table th { font-size: 12px; color: var(--text-3); }

/* ===== 모바일 ===== */
@media (max-width: 899px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { display: none; }
  .topbar { padding: 10px 14px; }
  .topbar .search { display: none; }
  .view { padding: 16px 14px 96px; }
  .bottomnav {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
    background: var(--surface); border-top: 1px solid var(--border);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  }
  .bottomnav a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 10.5px; color: var(--text-3); padding: 4px 0; position: relative; }
  .bottomnav a.active { color: var(--accent); font-weight: 600; }
  .bottomnav svg.i { width: 22px; height: 22px; }
  .bottomnav .count { position: absolute; top: 0; left: 55%; background: var(--danger); color: #fff; border-radius: 8px; font-size: 9px; padding: 0 5px; }
  .dash-grid { grid-template-columns: minmax(0, 1fr); }
  .dash-grid .card { min-width: 0; }
  .dash-grid .span2 { grid-column: auto; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .week-days { grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 3px; }
  .week-day { padding: 4px 2px; min-height: 70px; }
  .week-day .e { font-size: 9.5px; padding: 0 3px; }
  .work-layout { grid-template-columns: minmax(0, 1fr); }
  .cat-list { flex-direction: row; overflow-x: auto; position: static; padding-bottom: 4px; }
  .cat-item { white-space: nowrap; border: 1px solid var(--border); background: var(--surface); }
  .prow.head { display: none; }
  .prow { grid-template-columns: 22px minmax(0, 1fr) auto; grid-template-areas: "imp name dday" "imp sub status"; row-gap: 2px; }
  .prow > .c-imp { grid-area: imp; } .prow > .c-name { grid-area: name; } .prow > .c-dday { grid-area: dday; text-align: right; }
  .prow > .c-cat { grid-area: sub; } .prow > .c-status { grid-area: status; text-align: right; }
  .prow > .c-prog, .prow > .c-partner { display: none; }
  .info-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid { grid-template-columns: 1fr; }
  .mcell { min-height: 76px; padding: 2px; }
  .ev { font-size: 10px; padding: 0 3px; line-height: 15px; }
  .ev.timed::before { display: none; }
  .ev.timed { background: var(--evc) !important; color: #fff; padding: 0 3px; }
  .cal-bar .title { font-size: 17px; min-width: 0; }
  .day-layout { grid-template-columns: minmax(0, 1fr); }
  .tgrid-scroll { height: 60vh; }
  .settings-grid { grid-template-columns: minmax(0, 1fr); }
  .money { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .money .n { font-size: 14px; }
  .page-head h2 { font-size: 19px; }
}

/* ===== 공통: 보조 글자, PC/모바일 전용 표시 ===== */
.subt { color: var(--text-3); font-size: 12px; font-weight: 400; }
.subt::before { content: " · "; }
.mob-only { display: none; }
.mmonth, .agenda { display: none; }

/* ===== 모바일 최적화 (iPhone 16 Pro 402px 기준, 360~899px) ===== */
@media (max-width: 899px) {
  html { -webkit-text-size-adjust: 100%; }
  body { -webkit-tap-highlight-color: transparent; font-size: 15px; }
  .desk-only { display: none !important; }
  .mob-only { display: block; }

  /* 홈 화면 앱으로 실행 시 상단 Dynamic Island·하단 홈 바 영역 피하기 */
  .proto-banner { display: none; }
  .app { min-height: 100vh; }
  .topbar { padding: calc(10px + env(safe-area-inset-top)) 16px 10px; gap: 8px; }
  .topbar h1 { font-size: 18px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
  .topbar .mob-only.stage { display: inline-block; }
  .view { padding: 16px 16px calc(96px + env(safe-area-inset-bottom)); }

  /* iPhone은 16px 미만 입력칸을 누르면 화면을 확대하므로 16px로 */
  input, select, textarea, .input, .field input, .field select, .field textarea { font-size: 16px !important; }
  input[type="checkbox"] { width: 22px; height: 22px; }

  /* 손가락으로 누르기 쉬운 크기 (최소 40px) */
  .btn { min-height: 42px; padding: 8px 14px; }
  .btn.sm { min-height: 34px; padding: 4px 10px; }
  .icon-btn { width: 40px; height: 40px; }
  .seg button { min-height: 38px; padding: 6px 14px; }
  .tab { padding: 12px 14px; }
  .nav-item, .cat-item { min-height: 40px; }

  /* 글자가 잘리지 않도록 줄바꿈 허용 (한국어는 단어 단위로) */
  .list li { align-items: flex-start; padding: 11px 0; }
  .list li .grow { white-space: normal; overflow: visible; word-break: keep-all; overflow-wrap: anywhere; line-height: 1.45; }
  .list li .imp, .list li input[type="checkbox"] { margin-top: 1px; }
  .list li .dday, .list li .chip, .list li .faint, .list li .btn { flex: none; }
  .subt { display: block; margin-top: 2px; }
  .subt::before { content: none; }

  /* 페이지 머리말: 버튼은 아래 줄에 꽉 차게 */
  .page-head { gap: 8px; }
  .page-head .actions { margin-left: 0; width: 100%; align-items: center; }
  .page-head .actions .stage { flex: none; }
  .page-head .actions .btn { flex: 1; justify-content: center; }
  .dash-head .date { font-size: 22px; }

  /* 홈 */
  .stat .n { font-size: 24px; }
  .wk-ev { display: flex; align-items: center; gap: 6px; }
  .money .n { font-size: 15px; word-break: keep-all; }

  /* 업무 */
  .toolbar { gap: 8px; }
  .toolbar #q { flex: 1 1 100% !important; }
  .toolbar select { flex: 1 1 40%; }
  .cat-list { margin: 0 -16px; padding: 0 16px 6px; scrollbar-width: none; }
  .cat-list::-webkit-scrollbar { display: none; }
  .prow { padding: 14px; column-gap: 8px; }
  .prow .name, .prow .cell-sub { white-space: normal; word-break: keep-all; overflow-wrap: anywhere; }
  .kanban { grid-auto-columns: 82vw; scroll-snap-type: x mandatory; margin: 0 -16px; padding: 0 16px 8px; }
  .kcol { scroll-snap-align: start; }
  .pd-head h2 { font-size: 20px; word-break: keep-all; width: 100%; }
  .pd-head .actions { width: 100%; }
  .pd-head .actions .btn { flex: 1; justify-content: center; }
  .info-grid > div { padding: 10px; word-break: keep-all; }
  #taskForm input[name="title"] { flex: 1 1 100% !important; }
  #taskForm input[type="date"], #taskForm select { flex: 1 1 35%; }
  .tabs { margin: 0 -16px 16px; padding: 0 16px; scrollbar-width: none; }
  .tabs::-webkit-scrollbar { display: none; }

  /* 캘린더: 아이폰 기본 캘린더처럼 '점 표시 달력 + 선택한 날 일정 목록' */
  .cal-bar { row-gap: 10px; }
  .cal-bar .title { font-size: 19px; flex: 1; }
  .cal-bar .stage { display: none; }
  .cal-bar .right { margin-left: 0; width: 100%; }
  .cal-bar .right .seg { flex: 1; display: flex; }
  .cal-bar .right .seg button { flex: 1; }
  .filters { flex-wrap: nowrap; overflow-x: auto; margin: 0 -16px 12px; padding: 0 16px 2px; scrollbar-width: none; }
  .filters::-webkit-scrollbar { display: none; }
  .fchip { white-space: nowrap; padding: 7px 12px; font-size: 13.5px; }
  .month { display: none; }
  .mmonth { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 6px 4px; }
  .mmonth .dow { text-align: center; font-size: 12px; color: var(--text-3); padding: 4px 0 6px; }
  .mmonth .dow.sun { color: var(--danger); } .mmonth .dow.sat { color: var(--accent); }
  .mm-cell { height: 52px; display: flex; flex-direction: column; align-items: center; padding-top: 3px; cursor: pointer; }
  .mm-cell .num { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font-size: 16px; }
  .mm-cell.sun .num { color: var(--danger); } .mm-cell.sat .num { color: var(--accent); }
  .mm-cell.other .num { opacity: .35; }
  .mm-cell.today .num { color: var(--accent); font-weight: 700; }
  .mm-cell.sel .num { background: var(--text); color: var(--bg) !important; font-weight: 700; opacity: 1; }
  .mm-cell.sel.today .num { background: var(--accent); color: #fff !important; }
  .dots { display: flex; gap: 3px; height: 6px; margin-top: 2px; }
  .dots i { width: 6px; height: 6px; border-radius: 50%; }
  .agenda { display: block; margin-top: 14px; }
  .ag-day { margin-bottom: 14px; }
  .ag-day h4 { margin: 0 0 6px; font-size: 14px; display: flex; align-items: center; gap: 8px; }
  .ag-day h4.today { color: var(--accent); }
  .ag-list { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
  .ag-item { display: flex; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--border); cursor: pointer; align-items: stretch; }
  .ag-item:last-child { border-bottom: 0; }
  .ag-item .bar { width: 4px; height: auto; border-radius: 2px; flex: none; background: var(--evc); }
  .ag-time { width: 50px; flex: none; font-size: 13px; color: var(--text-2); line-height: 1.35; }
  .ag-title { font-weight: 600; word-break: keep-all; overflow-wrap: anywhere; line-height: 1.4; }
  .ag-meta { font-size: 12.5px; color: var(--text-3); margin-top: 2px; word-break: keep-all; }
  .ag-empty { padding: 14px; color: var(--text-3); font-size: 13px; }
  .ag-add { width: 100%; margin-top: 8px; justify-content: center; }
  .tgrid-head .big { font-size: 20px; }
  .tev { font-size: 12.5px; }

  /* 팝업: 화면 아래에서 올라오는 시트 형태 */
  .modal-backdrop { place-items: end center; padding: 0; }
  .modal, .modal.wide { width: 100%; max-height: 92vh; border-radius: 18px 18px 0 0; animation: sheet .2s ease-out; display: flex; flex-direction: column; position: relative; }
  .modal-b { overflow-y: auto; flex: 1; padding: 8px 16px 8px; }
  .modal-h { padding: 14px 16px 6px; }
  .modal-h::before { content: ""; position: absolute; left: 50%; transform: translateX(-50%); margin-top: -8px; width: 38px; height: 4px; border-radius: 2px; background: var(--border); }
  .modal-f { border-top: 1px solid var(--border); padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); }
  .modal-f .btn { flex: 1; justify-content: center; }
  .modal-f .left { margin-right: 0; }
  .prompt-box { min-height: 50vh; }

  /* 알림 문구는 하단 메뉴 위에 */
  .toast-wrap { bottom: calc(80px + env(safe-area-inset-bottom)); width: calc(100% - 32px); }
  .toast { width: 100%; justify-content: space-between; }

  .status-table td, .status-table th { padding: 10px 8px; word-break: keep-all; }
  .settings-grid .row-edit input[type="text"] { min-height: 40px; }
}
@keyframes sheet { from { transform: translateY(40px); opacity: .6; } }
