:root {
  --bg: #0d0e11;
  --panel: #11171d;
  --line: #30414f;
  --text: #e8edf2;
  --muted: #7d8894;
  --accent: #8cb8d0;
  --red: #ff4d5e;
  --yellow: #ffc93c;
  --blue: #3d8bff;
  --past: #4a5260;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --radius: 3px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", sans-serif;
  font-size: 16px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }

/* ---------- 공통 ---------- */
.brand {
  margin: 0;
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.18em;
  color: var(--accent);
}
.chip {
  margin-left: 6px;
  padding: 2px 6px;
  border: 1px solid var(--muted);
  border-radius: 4px;
  font-size: 10px;
  letter-spacing: 0.1em;
  color: var(--muted);
  vertical-align: middle;
}
.label {
  margin: 20px 0 10px;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.12em;
  color: var(--muted);
}
.btn {
  min-height: 44px;
  padding: 0 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: #031317; font-weight: 700; }
.btn.danger { border-color: #4a1c22; color: var(--red); }
.btn:disabled { opacity: 0.5; }

input {
  width: 100%;
  min-height: 46px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
  font-size: 16px; /* iOS 확대 방지 */
}
input:focus { outline: none; border-color: var(--accent); }
label { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }

/* ---------- 로그인 ---------- */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.login-box {
  width: min(360px, 100%);
  display: grid;
  gap: 16px;
  padding: 28px 24px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
}
.login-box .brand { text-align: center; margin-bottom: 8px; }
.error { margin: 0; min-height: 1em; font-size: 13px; color: var(--red); }

/* ---------- 헤더 ---------- */
#app { max-width: 1200px; margin: 0 auto; padding: 0 16px calc(96px + env(safe-area-inset-bottom)); }
.top {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(14px + env(safe-area-inset-top)) 0 14px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.tabs { display: flex; padding: 3px; border: 1px solid var(--line); border-radius: var(--radius); }
.tabs button {
  min-width: 56px;
  min-height: 36px;
  border: 0;
  border-radius: 7px;
  background: none;
  font-size: 14px;
  color: var(--muted);
}
.tabs button[aria-selected="true"] { background: var(--line); color: var(--text); }

.ai { display: flex; gap: 8px; margin-top: 14px; }
.ai input { flex: 1; }

/* ---------- 일정 카드 ---------- */
.cards { display: grid; gap: 10px; }
.card {
  display: grid;
  gap: 6px;
  width: 100%;
  padding: 14px 16px 14px 18px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--c, var(--past));
  border-radius: var(--radius);
  background: var(--panel);
  text-align: left;
}
.card:active { background: #121923; }
.card-title { font-size: 17px; font-weight: 600; word-break: break-all; }
.card-meta { display: flex; justify-content: space-between; gap: 12px; font-family: var(--mono); font-size: 14px; }
.when { color: var(--text); }
.left { color: var(--c, var(--muted)); white-space: nowrap; }

.u-red { --c: var(--red); }
.u-yellow { --c: var(--yellow); }
.u-blue { --c: var(--blue); }
.u-past { --c: var(--past); }
.card.u-past .card-title, .card.u-past .when { color: var(--muted); }

.empty { margin: 0; padding: 18px 0; text-align: center; font-size: 14px; color: var(--muted); }

/* ---------- 월간 달력 ---------- */
.month-head { display: flex; align-items: center; justify-content: space-between; margin: 18px 0 10px; }
.month-head h2 { margin: 0; font-family: var(--mono); font-size: 20px; letter-spacing: 0.08em; }
.icon-btn {
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  font-size: 22px;
}
.weekdays, .grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.weekdays span { padding: 4px 0; text-align: center; font-size: 12px; color: var(--muted); }
.weekdays span:first-child { color: var(--red); }
.day {
  aspect-ratio: 1 / 1;
  min-height: 44px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: var(--panel);
}
.day.blank { background: none; }
.num { font-family: var(--mono); font-size: 15px; }
.day.today .num { color: var(--accent); font-weight: 700; }
.day.selected { border-color: var(--accent); }
.dots { display: flex; gap: 3px; height: 6px; }
.dot { width: 6px; height: 6px; border-radius: 50%; background: var(--c); }

/* ---------- 추가 버튼 ---------- */
.fab {
  position: fixed;
  right: max(20px, calc((100vw - 1200px) / 2 + 20px));
  bottom: calc(20px + env(safe-area-inset-bottom));
  width: 58px;
  height: 58px;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  color: #031317;
  font-size: 30px;
  line-height: 1;
  box-shadow: 0 6px 20px rgba(58, 209, 232, 0.25);
}

/* ---------- 일정 폼 (모바일: 하단 시트) ---------- */
.sheet {
  width: 100%;
  max-width: 100%;
  margin: auto 0 0;
  padding: 22px 18px calc(18px + env(safe-area-inset-bottom));
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 16px 16px 0 0;
  background: var(--panel);
  color: var(--text);
}
.sheet::backdrop { background: rgba(0, 0, 0, 0.6); }
.sheet form { display: grid; gap: 16px; }
.sheet h2 { margin: 0; font-size: 18px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.actions { display: flex; gap: 8px; margin-top: 4px; }
.spacer { flex: 1; }

/* ---------- 화면 전환 ---------- */
body[data-view="list"] .pane-month,
body[data-view="month"] .pane-list,
body:not([data-view="settings"]) .pane-settings,
body[data-view="settings"] .pane-list,
body[data-view="settings"] .pane-month { display: none; }

/* ---------- UNSALTED HUD · PC / 모바일 공통 ---------- */
.brand strong { display: block; font-size: 27px; line-height: 1.1; letter-spacing: .13em; color: var(--text); }
.brand-sub { display: block; margin-top: 7px; font-size: 10px; letter-spacing: .23em; }
.top { padding-top: 26px; padding-bottom: 24px; }
.tabs button { padding: 8px 19px; border-radius: 2px; min-height: 44px; }
.tabs button[aria-selected="true"] { background: #1c2b37; color: var(--accent); box-shadow: inset 0 -2px var(--accent); }
.mode-note { margin: 20px 0 28px; font-size: 12px; color: var(--muted); line-height: 1.8; }
.chip { margin: 0 7px 0 0; color: var(--accent); border-color: var(--line); }
.panes { max-width: 920px; margin: 0 auto; }
.ai { display: grid; padding: 26px; border: 1px solid var(--line); border-top: 2px solid var(--accent); background: var(--panel); margin-top: 0; gap: 16px; }
.ai label { color: var(--text); font-size: 22px; font-weight: 600; }
.ai-entry { display: flex; gap: 10px; }
.ai-entry input { min-width: 0; min-height: 58px; }
.ai-entry .btn { white-space: nowrap; }
.ai p { color: var(--muted); font-size: 12px; margin: 0; line-height: 1.7; }
.section-head { display: flex; align-items: center; justify-content: space-between; margin: 34px 0 18px; gap: 12px; }
.section-head h2 { margin: 0; font-size: 20px; }
.section-head .label { margin: 0; letter-spacing: 0; }
.cards { gap: 14px; }
.card { padding: 20px 22px; gap: 13px; background: #101a24; border-color: #345470; border-left-color: var(--c); }
.card.u-red { background: #34151c; border-color: #8c3441; border-left-color: var(--red); }
.card.u-yellow { background: #282416; border-color: #6f6030; border-left-color: var(--yellow); }
.card.u-past { background: var(--panel); border-color: var(--line); }
.card-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; }
.card-title { font-size: 19px; overflow-wrap: anywhere; }
.importance { white-space: nowrap; font-size: 11px; padding: 4px 8px; color: var(--c); border: 1px solid currentColor; }
.when { color: var(--accent); }
.left { font-weight: 700; }
.card-actions { display: flex; justify-content: flex-end; gap: 16px; border-top: 1px solid #ffffff12; padding-top: 7px; }
.text-btn { min-height: 32px; border: 0; padding: 2px 8px; background: transparent; color: #bac5ce; font-size: 12px; }
.text-btn:hover { color: white; background: #ffffff0c; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.month-head { border-bottom: 1px solid var(--line); padding-bottom: 20px; }
.grid { gap: 1px; background: var(--line); border: 1px solid var(--line); }
.day { border-radius: 0; aspect-ratio: auto; height: 88px; background: #11171d; }
.day.blank { background: var(--bg); }
.day.selected { box-shadow: inset 0 0 0 1px var(--accent); }
.settings-panel { position: relative; padding: 24px; margin: 16px 0; border: 1px solid var(--line); background: var(--panel); }
.settings-panel h3 { margin: 0 0 22px; font-size: 17px; }
.settings-panel p { font-size: 14px; }
.panel-index { position: absolute; top: 25px; right: 24px; color: var(--accent); font-family: var(--mono); }
.muted { color: var(--muted); line-height: 1.8; }
dl div { display: flex; justify-content: space-between; border-bottom: 1px solid var(--line); padding: 13px 0; font-size: 13px; }
dt { color: var(--muted); } dd { margin: 0; color: var(--accent); }
.btn:disabled { cursor: not-allowed; }
.sheet { max-height: 92dvh; overflow-y: auto; }
.sheet p { margin: 0; font-size: 12px; line-height: 1.7; }
.repeat-badge { margin-right: auto; color: var(--accent); font-size: 12px; align-self: center; }
.delete-actions { display: grid; gap: 12px; margin: 20px 0; }
.hud-notice { width: min(440px, calc(100vw - 32px)); max-height: 85dvh; overflow-y: auto; margin: auto; padding: 28px; border: 1px solid var(--accent); border-radius: var(--radius); background: var(--panel); color: var(--text); text-align: center; box-shadow: 0 0 28px #0008; }
.hud-notice::backdrop { background: #000b; }
.notice-icon { width: 46px; height: 46px; margin: 0 auto 18px; display: grid; place-items: center; border: 2px solid var(--yellow); border-radius: 50%; color: var(--yellow); font: bold 28px var(--mono); }
.hud-notice h2 { font-size: 20px; margin: 0 0 16px; }
.hud-notice p { white-space: pre-line; overflow-wrap: anywhere; line-height: 1.8; margin: 0 0 24px; font-size: 15px; }
.hud-notice .btn { width: 100%; }
select { min-height: 46px; padding: 10px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg); color: var(--text); font: inherit; }
.fab { border-radius: 4px; border: 1px solid #bdd8e8; }
@media (min-width: 900px) {
  .sheet {
    width: 440px;
    margin: auto;
    border-bottom: 1px solid var(--line);
    border-radius: 16px;
  }
}
@media (max-width: 600px) {
  #app { padding-left: 16px; padding-right: 16px; }
  .top { flex-direction: column; align-items: stretch; gap: 22px; }
  .brand strong { font-size: 23px; }
  .tabs button { flex: 1; padding: 8px; }
  .ai { padding: 20px 16px; }
  .ai label { font-size: 19px; }
  .ai-entry { flex-direction: column; }
  .ai-entry input { font-size: 16px; }
  .ai-entry .btn { min-height: 48px; }
  .card { padding: 16px 13px; }
  .card-title { font-size: 16px; }
  .card-meta { flex-wrap: wrap; font-size: 12px; gap: 8px; }
  .section-head h2 { font-size: 18px; }
  .day { height: 56px; min-width: 0; min-height: 44px; }
  .row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .row input { min-width: 0; }
}
