:root {
  --accent: #FFB454;
  --green: #7CF7C4;
  --ink: #fff;
  --dim: rgba(255, 255, 255, 0.72);
  --faint: rgba(255, 255, 255, 0.45);
  --card: rgba(255, 255, 255, 0.07);
  --card-line: rgba(255, 255, 255, 0.12);
  --g1: #27313F;
  --g2: #10151C;
  --radius: 22px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* 상태별 배경 그라데이션 */
body[data-state="empty"]   { --g1: #27313F; --g2: #10151C; }
body[data-state="focus"]   { --g1: #34308C; --g2: #191654; }
body[data-state="overdue"] { --g1: #8C3038; --g2: #3A1218; }
body[data-state="done"]    { --g1: #0E7A5F; --g2: #073D33; }

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

/* 커스텀 SVG 아이콘 (currentColor 상속) */
.ico { display: inline-flex; align-items: center; justify-content: center; }
svg.ic { width: 1.05em; height: 1.05em; display: inline-block; vertical-align: -0.16em; }

html, body { min-height: 100%; }

body {
  font-family: "Pretendard", -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo",
    "Malgun Gothic", "Segoe UI", system-ui, sans-serif;
  color: var(--ink);
  background: linear-gradient(160deg, var(--g1), var(--g2));
  background-attachment: fixed;
  transition: background 1.2s ease;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  padding: calc(var(--safe-top) + 8px) 0 calc(var(--safe-bottom) + 8px);
}

.bg-glow {
  position: fixed;
  top: -20%; left: 50%;
  width: 120vw; height: 60vh;
  transform: translateX(-50%);
  background: radial-gradient(ellipse at center, rgba(255, 180, 84, 0.16), transparent 60%);
  pointer-events: none;
  z-index: 0;
  transition: opacity 1s ease;
}
body[data-state="done"] .bg-glow { background: radial-gradient(ellipse at center, rgba(124, 247, 196, 0.18), transparent 60%); }
body[data-state="overdue"] .bg-glow { opacity: 0.5; }

#app {
  position: relative;
  z-index: 1;
  max-width: 480px;
  margin: 0 auto;
  padding: 4px 18px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ---------- 상단바 ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 4px 0;
}
.brand { font-weight: 800; font-size: 16px; letter-spacing: -0.02em; display: inline-flex; align-items: center; gap: 6px; }
.brand-ico { color: var(--accent); }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.date { font-size: 13px; color: var(--faint); font-weight: 500; }
.streak {
  font-size: 13px; font-weight: 800; color: var(--accent);
  background: rgba(255, 180, 84, 0.14);
  padding: 4px 9px; border-radius: 999px;
}

/* ---------- 히어로 ---------- */
.hero {
  background: var(--card);
  border: 1px solid var(--card-line);
  border-radius: var(--radius);
  padding: 26px 22px 22px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25);
}
.hero-label {
  font-size: 12px; font-weight: 700; letter-spacing: 0.04em;
  color: var(--accent); text-transform: uppercase;
  display: flex; align-items: center; gap: 6px;
}
body[data-state="done"] .hero-label { color: var(--green); }
.hero-highlight {
  font-size: 27px; line-height: 1.28; font-weight: 800;
  letter-spacing: -0.02em; margin: 12px 0 10px;
  word-break: keep-all;
}
body[data-state="done"] .hero-highlight { text-decoration: line-through; text-decoration-color: rgba(124,247,196,0.5); text-decoration-thickness: 2px; }
.hero-status {
  font-size: 14px; color: var(--dim); font-weight: 500;
  min-height: 20px; line-height: 1.4;
}
.hero-status.live { color: var(--accent); }
body[data-state="done"] .hero-status { color: var(--green); }

.hero-actions { display: flex; gap: 10px; margin-top: 20px; flex-wrap: wrap; }
.hero-actions button {
  flex: 1 1 auto;
  min-height: 52px;
  border: none; border-radius: 15px;
  font-size: 16px; font-weight: 700;
  cursor: pointer; transition: transform 0.08s ease, filter 0.15s ease;
  font-family: inherit;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.hero-actions button svg.ic { width: 19px; height: 19px; }
.hero-actions button:active { transform: scale(0.97); }
.act-primary { background: var(--accent); color: #2a1c00; box-shadow: 0 6px 20px rgba(255,180,84,0.3); }
.act-done { background: var(--green); color: #06251c; box-shadow: 0 6px 20px rgba(124,247,196,0.3); }
.act-secondary { flex: 0 0 auto; background: rgba(255,255,255,0.1); color: var(--ink); padding: 0 18px; }

/* ---------- 카드 공통 ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--card-line);
  border-radius: var(--radius);
  padding: 18px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.card-head h2 { font-size: 14px; font-weight: 700; letter-spacing: -0.01em; }
.muted { color: var(--faint); font-size: 12px; font-weight: 600; }
.link-btn { background: none; border: none; color: var(--accent); font-size: 12px; font-weight: 700; cursor: pointer; font-family: inherit; padding: 4px; }

/* ---------- 할 일 ---------- */
.todo-list { list-style: none; display: flex; flex-direction: column; gap: 2px; }
.todo-list:empty { display: none; }
.todo-item {
  display: flex; align-items: center; gap: 11px;
  padding: 11px 6px; border-radius: 11px;
  cursor: pointer; transition: background 0.12s ease;
}
.todo-item:active { background: rgba(255,255,255,0.05); }
.todo-check {
  width: 22px; height: 22px; flex: 0 0 auto;
  border: 2px solid var(--faint); border-radius: 7px;
  display: grid; place-items: center;
  font-size: 13px; color: transparent; transition: all 0.15s ease;
}
.todo-item.done .todo-check { background: var(--green); border-color: var(--green); color: #06251c; }
.todo-text { flex: 1; font-size: 15px; line-height: 1.35; word-break: keep-all; }
.todo-item.done .todo-text { color: var(--faint); text-decoration: line-through; }
.todo-del { background: none; border: none; color: var(--faint); font-size: 18px; cursor: pointer; padding: 4px 8px; line-height: 1; opacity: 0; transition: opacity 0.15s; }
.todo-item:hover .todo-del, .todo-item.done .todo-del { opacity: 1; }

.todo-add { display: flex; gap: 8px; margin-top: 10px; }
.todo-add input {
  flex: 1; min-width: 0;
  background: rgba(0,0,0,0.2); border: 1px solid var(--card-line);
  border-radius: 12px; padding: 12px 14px;
  color: var(--ink); font-size: 15px; font-family: inherit;
}
.todo-add input::placeholder { color: var(--faint); }
.todo-add input:focus { outline: none; border-color: var(--accent); }
.todo-add button {
  flex: 0 0 48px; height: 46px;
  background: rgba(255,255,255,0.1); border: none; border-radius: 12px;
  color: var(--ink); font-size: 24px; font-weight: 300; cursor: pointer;
}
.todo-add button:active { background: rgba(255,255,255,0.18); }

/* ---------- 7일 점 ---------- */
.dots { display: flex; justify-content: space-between; align-items: flex-end; padding: 2px 2px 0; }
.dot-col { display: flex; flex-direction: column; align-items: center; gap: 7px; flex: 1; }
.dot {
  width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center; font-size: 13px;
  background: rgba(255,255,255,0.06); border: 1.5px solid var(--faint);
}
.dot.done { background: var(--green); border-color: var(--green); color: #06251c; }
.dot svg.ic { width: 15px; height: 15px; stroke-width: 2.6; }
.dot.partial { border-color: var(--accent); color: var(--accent); }
.dot.today { box-shadow: 0 0 0 2px rgba(255,255,255,0.25); }
.dot-day { font-size: 10px; color: var(--faint); font-weight: 600; }
.dot-col.is-today .dot-day { color: var(--ink); }

/* ---------- 푸터 ---------- */
.footer { display: flex; flex-direction: column; gap: 12px; align-items: center; margin-top: 2px; }
.ghost-btn {
  width: 100%;
  background: rgba(255,255,255,0.07); border: 1px solid var(--card-line);
  border-radius: 15px; padding: 15px; color: var(--ink);
  font-size: 15px; font-weight: 700; cursor: pointer; font-family: inherit;
}
.ghost-btn:active { background: rgba(255,255,255,0.13); }
.footer-rule { font-size: 12px; color: var(--faint); text-align: center; line-height: 1.5; padding: 0 12px; word-break: keep-all; }

/* ---------- 토스트 ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--safe-bottom) + 26px);
  transform: translateX(-50%) translateY(20px);
  background: rgba(20,20,28,0.92); color: #fff;
  padding: 13px 20px; border-radius: 14px;
  font-size: 14px; font-weight: 600; z-index: 100;
  border: 1px solid rgba(255,255,255,0.14);
  box-shadow: 0 10px 30px rgba(0,0,0,0.4);
  opacity: 0; transition: opacity 0.25s ease, transform 0.25s ease;
  max-width: 90vw; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- 설치 안내 ---------- */
.install-hint {
  position: fixed; left: 12px; right: 12px; bottom: calc(var(--safe-bottom) + 12px);
  background: rgba(20,20,28,0.95); border: 1px solid rgba(255,255,255,0.16);
  border-radius: 16px; padding: 14px 40px 14px 16px;
  font-size: 13px; color: var(--dim); z-index: 90; line-height: 1.5;
  box-shadow: 0 10px 30px rgba(0,0,0,0.4); max-width: 480px; margin: 0 auto;
}
.install-hint strong { color: var(--accent); }
.install-close { position: absolute; top: 10px; right: 10px; background: none; border: none; color: var(--faint); font-size: 16px; cursor: pointer; padding: 4px; }

/* ---------- 모달 ---------- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fade 0.2s ease;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal {
  width: 100%; max-width: 480px;
  background: linear-gradient(170deg, #232a36, #161a22);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 26px 26px 0 0;
  padding: 14px 22px calc(var(--safe-bottom) + 26px);
  max-height: 92vh; overflow-y: auto;
  animation: slideup 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes slideup { from { transform: translateY(100%); } to { transform: translateY(0); } }
@media (min-width: 520px) {
  .modal-overlay { align-items: center; }
  .modal { border-radius: 26px; margin: 0 16px; }
}
.modal-grip { width: 40px; height: 4px; border-radius: 999px; background: rgba(255,255,255,0.2); margin: 4px auto 16px; }
.modal h3 { font-size: 21px; font-weight: 800; letter-spacing: -0.02em; }
.modal-sub { font-size: 14px; color: var(--dim); margin-top: 6px; line-height: 1.5; }

.criteria { list-style: none; margin: 16px 0; display: flex; flex-direction: column; gap: 7px; }
.criteria li { font-size: 13px; color: var(--dim); line-height: 1.45; padding-left: 14px; position: relative; }
.criteria li::before { content: "·"; position: absolute; left: 2px; color: var(--accent); font-weight: 800; }
.criteria b { color: var(--ink); }

.modal input[type="text"], .modal textarea {
  width: 100%; margin-top: 16px;
  background: rgba(0,0,0,0.28); border: 1px solid var(--card-line);
  border-radius: 14px; padding: 15px;
  color: var(--ink); font-size: 16px; font-family: inherit; line-height: 1.4;
  resize: none;
}
.modal input::placeholder, .modal textarea::placeholder { color: var(--faint); }
.modal input:focus, .modal textarea:focus { outline: none; border-color: var(--accent); }

.deadline-row {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 18px; padding: 14px 16px;
  background: rgba(0,0,0,0.2); border: 1px solid var(--card-line); border-radius: 14px;
  font-size: 15px; font-weight: 600;
}
.deadline-row em { color: var(--faint); font-style: normal; font-weight: 500; font-size: 13px; }
.deadline-row input[type="time"] {
  background: rgba(255,255,255,0.1); border: none; border-radius: 10px;
  padding: 8px 12px; color: var(--ink); font-size: 16px; font-family: inherit;
}
.hint { font-size: 12px; color: var(--faint); margin-top: 8px; line-height: 1.5; }

.rate-block { margin-top: 20px; }
.rate-block > label { font-size: 14px; font-weight: 600; color: var(--dim); display: block; margin-bottom: 10px; }
.stars { display: flex; gap: 8px; }
.star {
  font-size: 30px; cursor: pointer; color: rgba(255,255,255,0.22);
  transition: transform 0.1s ease, color 0.1s ease; line-height: 1;
}
.star.on { color: var(--accent); }
.star:active { transform: scale(1.2); }
.exp-label { display: block; margin-top: 22px; font-size: 14px; font-weight: 600; color: var(--dim); }

.modal-actions { display: flex; gap: 10px; margin-top: 24px; }
.modal-actions button {
  flex: 1; min-height: 52px; border: none; border-radius: 15px;
  font-size: 16px; font-weight: 700; cursor: pointer; font-family: inherit;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
}
.btn-primary { background: var(--accent); color: #2a1c00; }
.btn-ghost { background: rgba(255,255,255,0.1); color: var(--ink); flex: 0 0 38%; }

/* ---------- 기록 ---------- */
.history-list { margin-top: 14px; display: flex; flex-direction: column; gap: 4px; max-height: 50vh; overflow-y: auto; }
.history-row { display: flex; align-items: flex-start; gap: 12px; padding: 12px 6px; border-bottom: 1px solid rgba(255,255,255,0.06); }
.history-mark { font-size: 17px; flex: 0 0 24px; display: flex; justify-content: center; padding-top: 2px; }
.history-mark svg.ic { width: 19px; height: 19px; stroke-width: 2.2; }
.history-body { flex: 1; min-width: 0; }
.history-date { font-size: 12px; color: var(--faint); font-weight: 600; }
.history-hl { font-size: 14px; line-height: 1.4; margin-top: 2px; word-break: keep-all; }
.history-hl.empty { color: var(--faint); font-style: italic; }
.history-meta { font-size: 12px; color: var(--accent); margin-top: 4px; }

.empty-row { text-align: center; color: var(--faint); font-size: 14px; padding: 30px 0; }
