:root {
  --bg: #0a0a0a;
  --surface: #141414;
  --surface-2: #1a1a1a;
  --line: #2a2a2a;
  --line-soft: #1f1f1f;
  --text: #f2f2f2;
  --text-dim: #9a9a9a;
  --text-faint: #6a6a6a;
  --key: #00D4AA;
  --red: #ff4d4d;
  --fail: #777;
  --radius: 12px;
  --radius-sm: 8px;
  --maxw: 820px;
  font-family: "Pretendard", -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo",
    "Noto Sans KR", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  background: var(--bg);
  color: var(--text);
  font-size: 18px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  letter-spacing: -0.01em;
}

button, input, textarea, select {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

a { color: var(--key); text-decoration: none; }

.wrap {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 22px 160px;
}

/* 헤더 */
header.top {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  padding: 18px 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}
header.top h1 {
  font-size: 22px;
  font-weight: 700;
}
header.top .day-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 16px;
  color: var(--text-dim);
}
header.top .day-nav button {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  cursor: pointer;
  width: 36px; height: 36px;
  font-size: 20px;
  line-height: 1;
}
header.top .day-nav button:hover { color: var(--text); border-color: var(--key); }
header.top .day-nav .today-label {
  color: var(--text);
  font-variant-numeric: tabular-nums;
  min-width: 118px;
  text-align: center;
  font-size: 17px;
  font-weight: 600;
  cursor: pointer;
  position: relative;
}
header.top .day-nav .today-label:hover { color: var(--key); }
/* 날짜 라벨용 숨은 date input (라벨 위에 겹쳐 네이티브 캘린더 호출) */
.today-label input[type=date] {
  position: absolute; inset: 0;
  opacity: 0; width: 100%; height: 100%;
  border: none; cursor: pointer;
  color-scheme: dark;
}
.hidden-picker {
  position: absolute;
  opacity: 0;
  width: 1px; height: 1px;
  pointer-events: none;
  color-scheme: dark;
}
header.top .who {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-dim);
  cursor: pointer;
}
header.top .who:hover { color: var(--text); }

/* 섹션 */
section { padding: 40px 0; border-bottom: 1px solid var(--line-soft); }
section:last-child { border-bottom: none; }
.sec-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 20px;
}
.sec-head h2 {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-dim);
}

/* 목표 (년/월/주/일) */
.goal-grid { display: flex; flex-direction: column; gap: 10px; }
.goal-row { display: flex; align-items: stretch; gap: 12px; }
.goal-row label {
  flex: none;
  width: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 700;
  color: var(--text-faint);
  letter-spacing: 0.04em;
  cursor: pointer;
  position: relative;
}
.goal-row label:hover { color: var(--key); }
.goal-row label input[type=date],
.goal-row label input[type=month] {
  position: absolute; inset: 0;
  opacity: 0; width: 100%; height: 100%;
  border: none; cursor: pointer; color-scheme: dark;
}

/* 비고 */
.goal-note-wrap { margin-top: 22px; }
.goal-note-wrap .note-label {
  display: block;
  font-size: 13px; font-weight: 600;
  color: var(--text-dim);
  margin-bottom: 8px;
}
#goalNote {
  width: 100%;
  background: none;
  border: none;
  border-bottom: 1px solid var(--line-soft);
  resize: vertical;
  color: var(--text);
  font-size: 16px;
  line-height: 1.6;
  padding: 8px 2px;
  min-height: 48px;
  outline: none;
}
#goalNote:focus { border-bottom-color: var(--key); }
#goalNote::placeholder { color: var(--text-faint); }
.goal-field {
  flex: 1;
  background: none;
  border: none;
  border-bottom: 1px solid var(--line-soft);
  resize: none;
  color: var(--text);
  font-size: 19px;
  line-height: 1.5;
  font-weight: 600;
  padding: 10px 2px;
  min-height: 44px;
  outline: none;
}
.goal-field:focus { border-bottom-color: var(--key); }
.goal-field::placeholder { color: var(--text-faint); font-weight: 500; }
.goal-saved { font-size: 13px; color: var(--key); opacity: 0; transition: opacity .3s; }
.goal-saved.show { opacity: 1; }
.goal-income {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
  font-size: 17px;
}
.goal-income label { color: var(--text-dim); font-weight: 600; }
.goal-income input {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 18px;
  width: 180px;
  font-variant-numeric: tabular-nums;
  outline: none;
}
.goal-income input:focus { border-color: var(--key); }
.goal-income .unit { color: var(--text-faint); font-size: 15px; }

/* 4분면 */
.quad-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 28px 36px;
}
.quad {
  min-height: 160px;
  padding: 0 0 4px;
  display: flex;
  flex-direction: column;
}
.quad .q-label::before {
  content: "";
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 999px;
  background: var(--text-faint);
  margin-right: 8px;
  vertical-align: middle;
}
.quad.q1 .q-label::before { background: var(--red); }
.quad.q2 .q-label::before { background: var(--key); }
.q-head { display: flex; align-items: baseline; justify-content: space-between; }
.q-label {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
}
.quad.q1 .q-label { color: var(--red); }
.q-rate { font-size: 15px; font-weight: 700; color: var(--text-dim); font-variant-numeric: tabular-nums; }
.quad.q1 .q-rate { color: var(--red); }
.q-sub { font-size: 13px; color: var(--text-faint); margin: 4px 0 14px; }
.quad ul { list-style: none; flex: 1; }
.quad li {
  font-size: 17px;
  padding: 9px 0;
  display: flex;
  align-items: flex-start;
  gap: 11px;
  user-select: none;
  border-bottom: 1px solid var(--line-soft);
}
.quad li:last-child { border-bottom: none; }
.quad li .mark {
  flex: none;
  width: 18px;
  height: 18px;
  margin-top: 3px;
  border: 2px solid var(--text-faint);
  border-radius: 5px;
  cursor: pointer;
}
.quad li.done .mark { background: var(--key); border-color: var(--key); }
.quad li.failed .mark { border-color: var(--red); background: var(--red); opacity: 0.5; }
.quad li.done .txt { color: var(--text-dim); text-decoration: line-through; }
.quad li.failed .txt { color: var(--text-faint); text-decoration: line-through; }
.quad li .txt { flex: 1; word-break: break-word; }
.q-add {
  margin-top: 12px;
  background: var(--surface-2);
  border: 1px dashed var(--line);
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  padding: 11px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
}
.q-add:hover { border-color: #fff; color: #fff; background: rgba(255,255,255,0.06); }

/* 4분면 입력 바 (하단 슬라이드 업) */
.task-bar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 120;
  background: var(--surface);
  border-top: 1px solid var(--line);
  padding: 16px 20px calc(16px + env(safe-area-inset-bottom));
  transform: translateY(100%);
  transition: transform .22s ease;
  box-shadow: 0 -8px 30px rgba(0,0,0,.5);
}
.task-bar.show { transform: translateY(0); }
.task-bar-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
}
.tb-label { font-size: 15px; font-weight: 700; color: var(--text-dim); white-space: nowrap; }
.task-bar.q1 .tb-label { color: var(--red); }
#tbInput {
  flex: 1;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 13px 16px;
  font-size: 18px;
  outline: none;
}
#tbInput:focus { border-color: var(--key); }

/* 버튼 공통 */
.btn {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 20px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  color: var(--text);
  white-space: nowrap;
}
.btn:hover { border-color: var(--key); color: var(--key); }
.btn.key { background: var(--key); border-color: var(--key); color: #04221c; }
.btn.key:hover { color: #04221c; opacity: 0.9; }

/* 컨텍스트 메뉴 */
.ctx-menu {
  position: fixed;
  z-index: 130;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  min-width: 160px;
  padding: 6px 0;
  box-shadow: 0 8px 30px rgba(0,0,0,.6);
}
.ctx-menu button {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  padding: 11px 18px;
  font-size: 16px;
  cursor: pointer;
  color: var(--text);
}
.ctx-menu button:hover { background: var(--surface-2); }
.ctx-menu button.danger:hover { color: var(--red); }
.ctx-menu .sep { height: 1px; background: var(--line); margin: 6px 0; }

/* 달성률 */
.rates { display: flex; flex-wrap: wrap; gap: 18px; }
.rate { flex: 1; min-width: 120px; }
.rate .r-num { font-size: 34px; font-weight: 700; font-variant-numeric: tabular-nums; }
.rate .r-num small { font-size: 17px; color: var(--text-dim); font-weight: 600; }
.rate .r-label { font-size: 13px; color: var(--text-dim); font-weight: 600; margin-top: 2px; }
.rate .r-label.q1c { color: var(--red); }
.rate .r-label.keyc { color: var(--key); }
.rate .r-bar { height: 4px; background: var(--line); margin-top: 10px; border-radius: 999px; overflow: hidden; }
.rate .r-bar i { display: block; height: 100%; background: var(--key); border-radius: 999px; }
#bar1 { background: var(--red); }
#barIncome { background: var(--key); }

/* 수입 */
.income-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 28px 36px;
  margin-bottom: 24px;
  align-items: flex-start;
}
.income-summary .metric { min-width: 90px; }
.income-summary .big { font-size: 32px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.1; }
.income-summary .mid { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.1; color: var(--text-dim); }
.income-summary .lbl { font-size: 14px; color: var(--text-faint); font-weight: 600; margin-top: 4px; }
.income-summary .up { color: var(--key); }
.income-summary .down { color: var(--red); }
#incomeChart { width: 100%; height: 180px; display: block; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.chart-axis { font-size: 12px; fill: var(--text-faint); }
.chart-legend { display: flex; gap: 22px; margin-top: 12px; font-size: 14px; color: var(--text-dim); }
.chart-legend span { display: inline-flex; align-items: center; gap: 7px; }
.chart-legend i { width: 18px; height: 3px; border-radius: 2px; display: inline-block; }
.chart-legend .ln-one { background: #ffb74d; }
.chart-legend .ln-rec { background: #4d9fff; }
.chart-legend .ln-total { background: var(--key); }

.income-add {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 24px;
  align-items: center;
}
.income-add input, .income-add select {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 17px;
  outline: none;
  color: var(--text);
  color-scheme: dark;
}
.income-add select { -webkit-appearance: menulist; appearance: menulist; }
.income-add select option { background: var(--surface); color: var(--text); }
.income-add input:focus, .income-add select:focus { border-color: var(--key); }
.income-add input.amount { width: 150px; }
.income-add input.label { width: 160px; }
.income-add input[type=date], .income-add input[type=month] { color-scheme: dark; }

.income-list { margin-top: 22px; }
.income-list .row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 2px;
  font-size: 17px;
  border-bottom: 1px solid var(--line-soft);
}
.income-list .row .tag {
  font-size: 13px;
  font-weight: 700;
}
.income-list .row.one .tag { color: #ffb74d; }
.income-list .row.rec .tag { color: #4d9fff; }
.income-list .row .when { color: var(--text-faint); font-size: 14px; }
.income-list .row .ilabel { font-weight: 600; }
.income-list .row .qtyctl { display: inline-flex; align-items: center; gap: 8px; }
.income-list .row .qbtn {
  width: 26px; height: 26px;
  border: 1px solid var(--line);
  background: none;
  border-radius: 6px;
  color: var(--text-dim);
  font-size: 17px; line-height: 1;
  cursor: pointer;
}
.income-list .row .qbtn:hover { border-color: var(--key); color: var(--key); }
.income-list .row .qnum { font-variant-numeric: tabular-nums; font-weight: 700; min-width: 28px; text-align: center; }
.income-list .row .amt { font-variant-numeric: tabular-nums; margin-left: auto; font-weight: 700; }
.income-list .row .amt .unitnote { font-size: 12px; color: var(--text-faint); font-weight: 500; }
.income-list .row .del { color: var(--text-faint); cursor: pointer; border: none; background: none; font-size: 15px; }
.income-list .row .del:hover { color: var(--red); }
.income-add input.qty { width: 90px; }

/* 피드백 */
#feedbackInput {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  resize: vertical;
  min-height: 86px;
  outline: none;
  font-size: 18px;
  line-height: 1.55;
}
#feedbackInput:focus { border-color: var(--key); }
.feedback-actions { margin-top: 12px; display: flex; justify-content: flex-end; }
.feedback-list { margin-top: 22px; }
.feedback-list .fb {
  padding: 16px 18px;
  margin-bottom: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.feedback-list .fb .fb-meta { font-size: 14px; color: var(--text-faint); margin-bottom: 6px; display: flex; gap: 12px; align-items: center; }
.feedback-list .fb .fb-meta .who { color: var(--key); font-weight: 700; }
.feedback-list .fb .fb-body { font-size: 18px; line-height: 1.55; white-space: pre-wrap; word-break: break-word; }
.feedback-list .fb .fb-del { margin-left: auto; cursor: pointer; }
.feedback-list .fb .fb-del:hover { color: var(--red); }

/* 로그인 */
.login-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.login-box { width: 100%; max-width: 380px; }
.login-box h1 { font-size: 26px; margin-bottom: 8px; font-weight: 700; }
.login-box p { font-size: 16px; color: var(--text-dim); margin-bottom: 26px; }
.login-box input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  font-size: 18px;
  outline: none;
  margin-bottom: 12px;
}
.login-box input:focus { border-color: var(--key); }
.login-box .btn { width: 100%; padding: 15px; font-size: 18px; }
.login-box .cf-turnstile { margin: 6px 0 12px; }
.login-box .hint { font-size: 15px; color: var(--text-faint); margin-top: 14px; min-height: 20px; }

.toast {
  position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%);
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 999px; padding: 12px 22px; font-size: 16px;
  z-index: 300; opacity: 0; transition: opacity .25s; pointer-events: none;
}
.toast.show { opacity: 1; }

/* 마넥 구독 블록 */
.manex { margin-top: 30px; }
.manex-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 12px; }
.manex-title { font-size: 17px; font-weight: 700; }
.manex-title::before {
  content: ""; display: inline-block; width: 10px; height: 3px;
  background: #4d9fff; border-radius: 2px; margin-right: 8px; vertical-align: middle;
}
.manex-month { font-size: 14px; color: var(--text-faint); font-variant-numeric: tabular-nums; }
.manex-tier {
  display: flex; align-items: center; gap: 18px;
  padding: 12px 2px;
  border-bottom: 1px solid var(--line-soft);
}
.manex-tier .mt-info { display: flex; flex-direction: column; min-width: 130px; }
.manex-tier .mt-name { font-size: 17px; font-weight: 700; }
.manex-tier .mt-price { font-size: 13px; color: var(--text-faint); }
.manex-tier .qtyctl { display: inline-flex; align-items: center; gap: 10px; }
.manex-tier .qbtn {
  width: 30px; height: 30px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--text-dim);
  font-size: 18px; line-height: 1;
  cursor: pointer;
}
.manex-tier .qbtn:hover { border-color: var(--key); color: var(--key); }
.manex-tier .qnum { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 18px; min-width: 32px; text-align: center; }
.manex-tier .mt-net {
  margin-left: auto;
  font-size: 17px; font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--key);
  cursor: help;
  position: relative;
  border-bottom: 1px dotted var(--text-faint);
}
/* 순수익 계산 툴팁 */
.mt-net .net-tip {
  position: absolute;
  bottom: calc(100% + 10px);
  right: 0;
  z-index: 90;
  width: max-content;
  max-width: 280px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.7;
  color: var(--text-dim);
  white-space: nowrap;
  box-shadow: 0 8px 30px rgba(0,0,0,.6);
  opacity: 0;
  pointer-events: none;
  transition: opacity .15s;
}
.mt-net .net-tip .tip-row { display: flex; justify-content: space-between; gap: 18px; }
.mt-net .net-tip .tip-row.total { color: var(--key); font-weight: 700; border-top: 1px solid var(--line); margin-top: 5px; padding-top: 5px; }
.mt-net .net-tip .tip-row .minus { color: var(--red); }
.mt-net.show-tip .net-tip { opacity: 1; }
@media (hover: hover) {
  .mt-net:hover .net-tip { opacity: 1; }
}

.income-note { font-size: 13px; color: var(--text-faint); margin-top: 14px; }
.sec-head .meta { font-size: 13px; color: var(--text-faint); font-weight: 500; }

/* 자료 */
.resource-add { display: flex; gap: 16px; flex-wrap: wrap; align-items: center; }
.resource-add input {
  background: none;
  border: none;
  border-bottom: 1px solid var(--line);
  padding: 10px 2px;
  font-size: 17px;
  outline: none;
  color: var(--text);
}
.resource-add input:focus { border-bottom-color: var(--key); }
.resource-add input::placeholder { color: var(--text-faint); }
.resource-add #resName { width: 200px; }
.resource-add #resUrl { flex: 1; min-width: 200px; }
.resource-list { margin-top: 20px; }
.resource-list .res {
  display: flex; align-items: center; gap: 14px;
  padding: 13px 2px;
  border-bottom: 1px solid var(--line-soft);
}
.resource-list .res a {
  font-size: 18px; font-weight: 600; color: var(--text);
  text-decoration: none;
}
.resource-list .res a:hover { color: var(--key); text-decoration: underline; }
.resource-list .res .rhost { font-size: 13px; color: var(--text-faint); }
.resource-list .res .del { margin-left: auto; color: var(--text-faint); cursor: pointer; border: none; background: none; font-size: 15px; }
.resource-list .res .del:hover { color: var(--red); }

.hidden { display: none !important; }

/* Q2(중요·비긴급) 축하 — 가장 중요한 분면 */
.celebrate {
  position: fixed; inset: 0; z-index: 250;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none;
}
.celebrate .msg {
  font-size: 30px;
  font-weight: 800;
  color: var(--key);
  letter-spacing: -0.02em;
  text-align: center;
  opacity: 0;
  transform: scale(0.8);
  animation: celebratePop 1.6s ease forwards;
  text-shadow: 0 0 24px rgba(0,212,170,0.4);
}
@keyframes celebratePop {
  0%   { opacity: 0; transform: scale(0.8) translateY(8px); }
  15%  { opacity: 1; transform: scale(1.05) translateY(0); }
  30%  { transform: scale(1); }
  80%  { opacity: 1; }
  100% { opacity: 0; transform: scale(1) translateY(-12px); }
}
.celebrate .spark {
  position: absolute;
  width: 9px; height: 9px;
  border-radius: 999px;
  background: var(--key);
  opacity: 0;
  animation: sparkFly 1.1s ease-out forwards;
}
@keyframes sparkFly {
  0%   { opacity: 1; transform: translate(0,0) scale(1); }
  100% { opacity: 0; transform: translate(var(--dx), var(--dy)) scale(0.3); }
}
/* Q2 카드 잠깐 강조 */
.quad.q2.flash .q-label { animation: q2flash 0.9s ease; }
@keyframes q2flash {
  0%,100% { color: var(--text); }
  40% { color: var(--key); }
}

/* 모바일 */
@media (max-width: 640px) {
  html, body { font-size: 17px; }
  .wrap { padding: 0 16px 160px; }
  header.top { flex-wrap: wrap; gap: 10px; }
  header.top h1 { font-size: 20px; }
  .quad-grid { grid-template-columns: 1fr; }
  .quad { min-height: auto; }
  .rates { gap: 14px; }
  .rate { min-width: calc(50% - 7px); }
  .rate .r-num { font-size: 28px; }
  .income-summary { gap: 22px; }
  .income-summary .big { font-size: 26px; }
  .income-add input.amount, .income-add input.label { width: 100%; }
  .income-add { flex-direction: column; align-items: stretch; }
  .income-add .btn, .income-add select { width: 100%; }
  .goal-income input { flex: 1; width: auto; }
  .manex-tier { gap: 12px; }
  .manex-tier .mt-info { min-width: 84px; }
  .mt-net .net-tip { max-width: 78vw; white-space: normal; }
  .resource-add { flex-direction: column; align-items: stretch; gap: 12px; }
  .resource-add #resName, .resource-add #resUrl { width: 100%; }
  .resource-add .btn { width: 100%; }
  .task-bar-inner { flex-wrap: wrap; }
  #tbInput { width: 100%; flex: 1 1 100%; order: 1; }
  .tb-label { order: 0; }
  #tbAdd, #tbClose { flex: 1; order: 2; }
}
