:root {
  --bg: #0f1b2d;
  --card: #18283f;
  --text: #e8eef7;
  --muted: #8da0ba;
  --accent: #4fd1a5;
  --danger: #ff7a7a;
  --line: #243653;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", "Noto Sans KR", sans-serif;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  padding: max(20px, env(safe-area-inset-top)) 20px max(24px, env(safe-area-inset-bottom));
}

[hidden] { display: none !important; }

h1 { font-size: 1.3rem; margin: 0; letter-spacing: .02em; }
h2 { font-size: .95rem; color: var(--muted); font-weight: 600; margin: 28px 0 10px; }

header { display: flex; justify-content: space-between; align-items: center; }

.icon-btn {
  background: none; border: 0; color: var(--text);
  font-size: 1.8rem; line-height: 1; padding: 4px 10px; cursor: pointer;
}

#setup { padding-top: 18vh; text-align: center; }
#setup h1 { font-size: 2rem; }
.sub { color: var(--muted); margin: 8px 0 28px; }

.field { display: block; text-align: left; margin-bottom: 16px; }
.field span { display: block; color: var(--muted); font-size: .85rem; margin-bottom: 6px; }
input[type=date] {
  width: 100%; padding: 12px; font-size: 1rem;
  background: var(--card); color: var(--text);
  border: 1px solid var(--line); border-radius: 10px;
  color-scheme: dark;
}

button { font: inherit; }
button.primary {
  width: 100%; padding: 14px; border: 0; border-radius: 12px;
  background: var(--accent); color: #07261c; font-weight: 700; cursor: pointer;
}
button.link {
  display: block; margin: 18px auto 0; background: none; border: 0;
  color: var(--muted); text-decoration: underline; cursor: pointer;
}

.counter { text-align: center; padding: 48px 0 28px; }
.days { font-size: 7rem; font-weight: 800; line-height: 1; color: var(--accent); }
.unit { font-size: 1.3rem; margin-top: 4px; }
.since { color: var(--muted); font-size: .85rem; margin-top: 10px; }

.next-label { font-size: .85rem; color: var(--muted); margin-bottom: 8px; text-align: center; }
.bar { height: 8px; background: var(--card); border-radius: 99px; overflow: hidden; }
.fill { height: 100%; width: 0; background: var(--accent); border-radius: 99px; transition: width .6s ease; }

ul { list-style: none; margin: 0; padding: 0; }

.badges { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.badges li {
  background: var(--card); border-radius: 12px; padding: 14px 6px;
  text-align: center; font-size: .85rem; opacity: .4;
}
.badges li.done { opacity: 1; border: 1px solid var(--accent); }
.badges .ico { display: block; font-size: 1.5rem; margin-bottom: 4px; }

.history li {
  display: flex; justify-content: space-between;
  padding: 12px 14px; background: var(--card); border-radius: 10px;
  margin-bottom: 8px; font-size: .9rem;
}
.history .range { color: var(--muted); }
.history .empty { color: var(--muted); background: none; padding-left: 0; }

dialog {
  width: min(90vw, 360px); padding: 8px; border: 0; border-radius: 16px;
  background: var(--card); color: var(--text);
}
dialog::backdrop { background: rgba(0, 0, 0, .55); }
.menu-item {
  display: block; width: 100%; text-align: left; padding: 14px;
  background: none; border: 0; border-radius: 10px; color: var(--text); cursor: pointer;
}
.menu-item:hover { background: var(--line); }
.menu-item.danger { color: var(--danger); }

.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 20px);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 99px;
  font-size: .9rem; opacity: 0; pointer-events: none; transition: .25s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
