:root {
  --bg: #0f1115;
  --panel: #1c212b;
  --panel-2: #161a22;
  --border: #2b3244;
  --text: #f1f3f7;
  --text-dim: #adb6c5;
  --accent: #e5394a;
  --accent-2: #5bd0c7;
  --gold: #e5394a;
  --rank3: #5bd0c7;
  --card-border-w: 0px;
}

:root[data-theme="christmas"] {
  --bg: #0a1711;
  --panel: #12241a;
  --panel-2: #0e1d15;
  --border: rgba(217, 176, 74, 0.45);
  --text: #f1f3f7;
  --text-dim: #adc3b4;
  --accent: #c71427;
  --accent-2: #1c8a4a;
  --gold: #d9b04a;
  --rank3: #1c8a4a;
  --card-border-w: 1px;
}

:root[data-theme="simple"] {
  --bg: #ffffff;
  --panel: #f3faf5;
  --panel-2: #eaf6ee;
  --border: rgba(41, 140, 82, 0.3);
  --text: #16241b;
  --text-dim: #5c6b61;
  --accent: #298c52;
  --accent-2: #8dc7a0;
  --gold: #5cac72;
  --rank3: #8dc7a0;
  --card-border-w: 1px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", sans-serif;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: contain;
}

h1 {
  font-family: "IBM Plex Sans KR", -apple-system, sans-serif;
  font-size: 1.3rem;
  font-weight: 700;
  margin: 0;
}

#app {
  position: relative;
  min-height: 100vh;
  padding-bottom: env(safe-area-inset-bottom);
  transition: background 0.3s ease, color 0.3s ease;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: calc(env(safe-area-inset-top) + 12px) 16px 12px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.theme-switch {
  display: flex;
  gap: 6px;
  background: var(--panel-2);
  padding: 4px;
  border-radius: 10px;
  overflow-x: auto;
}

.theme-btn {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--text-dim);
  font-size: 0.82rem;
  font-weight: 600;
  padding: 7px 12px;
  border-radius: 7px;
  white-space: nowrap;
  cursor: pointer;
}

.theme-btn.active {
  background: var(--accent);
  color: white;
}

.icon-btn {
  flex-shrink: 0;
  appearance: none;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--accent);
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.icon-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

main {
  max-width: 680px;
  margin: 0 auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.card {
  background: var(--panel);
  border: var(--card-border-w) solid var(--border);
  border-radius: 16px;
  padding: 18px;
}

.form-card h1, .list-header h1 { margin-bottom: 14px; }

#titleInput {
  width: 100%;
  font-size: 1rem;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1.5px solid var(--accent);
  background: var(--panel-2);
  color: var(--text);
  margin-bottom: 16px;
}
#titleInput:focus { outline: none; }
#titleInput::placeholder { color: var(--text-dim); }

.slider-row { margin-bottom: 14px; }

.slider-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.92rem;
  margin-bottom: 4px;
}

.slider-num { font-variant-numeric: tabular-nums; font-weight: 600; }
.slider-num.pink { color: #ff4f81; }
.slider-num.orange { color: #ff9f2e; }
.slider-num.purple { color: #b85cff; }

input[type="range"] {
  width: 100%;
  -webkit-appearance: none;
  height: 6px;
  border-radius: 3px;
  background: var(--border);
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: white;
  box-shadow: 0 1px 4px rgba(0,0,0,0.4);
  cursor: pointer;
}
input[type="range"].pink::-webkit-slider-runnable-track { background: linear-gradient(90deg, #ff4f81 var(--pct, 50%), var(--border) 0); }
input#preference { accent-color: #ff4f81; }
input#urgency { accent-color: #ff9f2e; }
input#difficulty { accent-color: #b85cff; }

.radar-preview {
  display: block;
  width: 200px;
  height: 200px;
  margin: 10px auto;
}

.score-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  color: var(--text-dim);
  margin-bottom: 16px;
}

.score-num {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.form-buttons { display: flex; gap: 10px; }

.primary-btn, .secondary-btn {
  flex: 1;
  padding: 13px;
  border-radius: 12px;
  border: none;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
}

.primary-btn {
  background: var(--accent);
  color: white;
}
.primary-btn:disabled { opacity: 0.4; cursor: default; }

.secondary-btn {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  flex: 0 0 auto;
  padding: 13px 20px;
}

.list-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}

.list-count {
  font-size: 0.82rem;
  color: var(--text-dim);
}

.empty-state {
  text-align: center;
  padding: 36px 0;
  color: var(--text-dim);
}
.empty-icon {
  font-size: 2.2rem;
  margin-bottom: 8px;
  opacity: 0.4;
}
.empty-state .sub { font-size: 0.82rem; opacity: 0.7; }

.task-list { display: flex; flex-direction: column; gap: 10px; }

.task-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
  transition: opacity 0.2s ease;
}

.task-row.rank-1 {
  border-color: var(--rank-color, var(--accent));
  border-width: 2px;
}

.task-row.done { opacity: 0.5; }

.checkbox-btn {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.3rem;
}
.checkbox-btn.checked { color: var(--rank-color, var(--accent)); }

.rank-badge {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  background: color-mix(in srgb, var(--rank-color, var(--accent)) 18%, transparent);
  color: var(--rank-color, var(--accent));
}

.task-radar {
  flex-shrink: 0;
  width: 48px;
  height: 48px;
}

.task-body {
  flex: 1;
  min-width: 0;
}

.task-title {
  font-weight: 600;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.task-title.done { text-decoration: line-through; color: var(--text-dim); }

.task-tags {
  display: flex;
  gap: 5px;
  margin-top: 5px;
  flex-wrap: wrap;
}
.tag {
  font-size: 0.68rem;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 20px;
}
.tag.pink { background: rgba(255,79,129,0.15); color: #ff4f81; }
.tag.orange { background: rgba(255,159,46,0.15); color: #ff9f2e; }
.tag.purple { background: rgba(184,92,255,0.15); color: #b85cff; }

.task-score {
  flex-shrink: 0;
  text-align: right;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.task-score small { display: block; font-size: 0.65rem; font-weight: 500; color: var(--text-dim); }

.delete-btn {
  flex-shrink: 0;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 4px;
}

.snow-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 1;
}
.snow-flake {
  position: absolute;
  top: -30px;
  animation: fall linear infinite;
  opacity: 0.7;
}
@keyframes fall {
  to { transform: translateY(110vh); }
}

@media (min-width: 720px) {
  main { flex-direction: row; align-items: flex-start; }
  .form-card { flex: 0 0 320px; position: sticky; top: 86px; }
  .list-card { flex: 1; }
}
