/* ── 리셋 & 변수 ── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #0f0f0e;
  --surface: #1a1a18;
  --surface2: #222220;
  --border: rgba(255, 255, 255, 0.08);
  --border2: rgba(255, 255, 255, 0.14);
  --text: #f0ede6;
  --text2: #9c9a93;
  --text3: #5a5955;
  --accent: #c9b97a;
  --accent2: #a09456;
  --green: #4db88a;
  --green-bg: rgba(77, 184, 138, 0.12);
  --red: #e05a5a;
  --red-bg: rgba(224, 90, 90, 0.12);
  --amber: #e09a3a;
  --amber-bg: rgba(224, 154, 58, 0.1);
}

html {
  font-size: 16px;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Noto Sans KR', sans-serif;
  font-weight: 400;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* ── 배경 노이즈 텍스처 ── */
.noise {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.025;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 200px;
}

[data-theme="light"] .noise {
  display: none;
}

/* ── 로그인 화면 ── */
#auth-screen {
  width: 100%;
  max-width: 400px;
  padding: 4rem 1.5rem;
  position: relative;
  z-index: 1;
}

.auth-logo {
  font-family: 'DM Serif Display', serif;
  font-size: 2.2rem;
  color: var(--text);
  margin-bottom: 0.3rem;
}

.auth-logo em {
  font-style: italic;
  color: var(--accent);
}

.auth-sub {
  font-size: 13px;
  color: var(--text3);
  font-weight: 300;
  margin-bottom: 2.5rem;
}

.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
}

.auth-tabs {
  display: flex;
  margin-bottom: 20px;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.auth-tab {
  flex: 1;
  height: 36px;
  background: transparent;
  border: none;
  color: var(--text3);
  font-family: 'Noto Sans KR', sans-serif;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
}

.auth-tab.active {
  background: var(--surface2);
  color: var(--text);
  font-weight: 500;
}

.auth-input {
  width: 100%;
  height: 42px;
  padding: 0 14px;
  margin-bottom: 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  font-family: 'Noto Sans KR', sans-serif;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}

.auth-input::placeholder {
  color: var(--text3);
}

.auth-input:focus {
  border-color: var(--accent2);
}

.auth-btn {
  width: 100%;
  height: 42px;
  border-radius: 10px;
  border: 1px solid var(--accent2);
  background: transparent;
  color: var(--accent);
  font-family: 'Noto Sans KR', sans-serif;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  margin-top: 4px;
}

.auth-btn:hover {
  background: var(--accent2);
  color: #0f0f0e;
}

.auth-divider {
  text-align: center;
  font-size: 12px;
  color: var(--text3);
  margin: 16px 0;
  position: relative;
}

.auth-divider::before,
.auth-divider::after {
  content: '';
  position: absolute;
  top: 50%;
  width: calc(50% - 24px);
  height: 1px;
  background: var(--border);
}

.auth-divider::before {
  left: 0;
}

.auth-divider::after {
  right: 0;
}

.google-btn {
  width: 100%;
  height: 42px;
  border-radius: 10px;
  border: 1px solid var(--border2);
  background: transparent;
  color: var(--text2);
  font-family: 'Noto Sans KR', sans-serif;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.google-btn:hover {
  background: var(--surface2);
}

.g-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.auth-error {
  font-size: 12px;
  color: var(--red);
  margin-top: 8px;
  min-height: 16px;
}

/* ── 앱 화면 ── */
#app-screen {
  display: none;
  width: 100%;
  max-width: 560px;
  padding: 2.5rem 1rem 5rem;
  position: relative;
  z-index: 1;
}

.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 2rem;
}

.eyebrow {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 4px;
}

h1 {
  font-family: 'DM Serif Display', serif;
  font-size: clamp(1.8rem, 5vw, 2.4rem);
  font-weight: 400;
  line-height: 1.1;
}

h1 em {
  font-style: italic;
  color: var(--accent);
}

.user-area {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--surface2);
  border: 1px solid var(--border2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 500;
  color: var(--accent);
  overflow: hidden;
}

.user-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.logout-btn {
  font-size: 11px;
  color: var(--text3);
  background: none;
  border: none;
  cursor: pointer;
  font-family: 'Noto Sans KR', sans-serif;
}

.logout-btn:hover {
  color: var(--text2);
}

/* ── 입력 ── */
.input-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  margin-bottom: 1.5rem;
  transition: border-color 0.2s;
}

.input-card:focus-within {
  border-color: var(--border2);
}

.input-top {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
}

.main-input {
  flex: 1;
  height: 42px;
  padding: 0 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  font-family: 'Noto Sans KR', sans-serif;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}

.main-input::placeholder {
  color: var(--text3);
}

.main-input:focus {
  border-color: var(--accent2);
}

.add-btn {
  height: 42px;
  padding: 0 20px;
  border-radius: 10px;
  border: 1px solid var(--accent2);
  background: transparent;
  color: var(--accent);
  font-family: 'Noto Sans KR', sans-serif;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}

.add-btn:hover {
  background: var(--accent2);
  color: #0f0f0e;
}

.input-meta {
  display: flex;
  align-items: center;
  gap: 10px;
}

.meta-label {
  font-size: 12px;
  color: var(--text3);
  white-space: nowrap;
}

.date-picker {
  height: 32px;
  padding: 0 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text2);
  font-family: 'Noto Sans KR', sans-serif;
  font-size: 13px;
  outline: none;
  cursor: pointer;
  color-scheme: dark;
}

.date-picker:focus {
  border-color: var(--accent2);
}

/* ── 통계 ── */
.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 1.5rem;
}

.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  text-align: center;
}

.stat-num {
  font-size: 24px;
  font-weight: 600;
  line-height: 1;
}

.stat-lbl {
  font-size: 11px;
  color: var(--text3);
  margin-top: 4px;
}

.stat.good .stat-num {
  color: var(--green);
}

.stat.danger .stat-num {
  color: var(--red);
}

/* ── 진행률 ── */
.progress-wrap {
  margin-bottom: 1.5rem;
}

.progress-label {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text3);
  margin-bottom: 6px;
}

.progress-bar-bg {
  height: 3px;
  background: var(--surface2);
  border-radius: 99px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 99px;
  transition: width 0.4s ease;
}

/* ── 필터 ── */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 1.25rem;
}

.filter-btn {
  padding: 6px 14px;
  border-radius: 99px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text3);
  font-family: 'Noto Sans KR', sans-serif;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.filter-btn:hover {
  border-color: var(--border2);
  color: var(--text2);
}

.filter-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #0f0f0e;
  font-weight: 500;
}

.section-title {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text3);
  margin-bottom: 10px;
  padding-left: 2px;
}

/* ── 투두 아이템 ── */
.todo-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.todo-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  transition: opacity 0.2s, border-color 0.15s;
  animation: slideIn 0.2s ease;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.todo-item:hover {
  border-color: var(--border2);
}

.todo-item.done {
  opacity: 0.4;
}

.cb-wrap {
  padding-top: 2px;
  flex-shrink: 0;
}

.cb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1.5px solid var(--border2);
  background: transparent;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  transition: all 0.15s;
}

.cb:checked {
  background: var(--accent);
  border-color: var(--accent);
}

.cb:checked::after {
  content: '';
  position: absolute;
  width: 5px;
  height: 9px;
  border: 1.5px solid #0f0f0e;
  border-top: none;
  border-left: none;
  transform: rotate(45deg);
  top: 1px;
  left: 4px;
}

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

.todo-text {
  font-size: 14px;
  color: var(--text);
  line-height: 1.5;
  word-break: break-word;
}

.done .todo-text {
  text-decoration: line-through;
  color: var(--text3);
}

.todo-footer {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  flex-wrap: wrap;
}

.date-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  padding: 3px 9px;
  border-radius: 99px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text3);
  cursor: pointer;
  transition: border-color 0.15s;
  white-space: nowrap;
}

.date-tag:hover {
  border-color: var(--border2);
}

.date-tag.overdue {
  background: var(--red-bg);
  color: var(--red);
  border-color: rgba(224, 90, 90, 0.25);
}

.date-tag.today {
  background: var(--green-bg);
  color: var(--green);
  border-color: rgba(77, 184, 138, 0.25);
}

.date-tag.upcoming {
  background: var(--amber-bg);
  color: var(--amber);
  border-color: rgba(224, 154, 58, 0.2);
}

.inline-dp {
  height: 26px;
  padding: 0 8px;
  border-radius: 8px;
  border: 1px solid var(--accent2);
  background: var(--surface2);
  color: var(--text);
  font-family: 'Noto Sans KR', sans-serif;
  font-size: 12px;
  outline: none;
  color-scheme: dark;
  display: none;
}

.del-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text3);
  font-size: 20px;
  line-height: 1;
  padding: 0 2px;
  flex-shrink: 0;
  transition: color 0.15s;
}

.del-btn:hover {
  color: var(--red);
}

.empty {
  text-align: center;
  padding: 3rem 0;
  font-size: 14px;
  color: var(--text3);
  font-weight: 300;
}

.empty span {
  display: block;
  font-size: 28px;
  margin-bottom: 12px;
}

.loading {
  text-align: center;
  padding: 2rem 0;
  font-size: 13px;
  color: var(--text3);
}

/* ── 스크롤바 ── */
::-webkit-scrollbar {
  width: 4px;
}

::-webkit-scrollbar-thumb {
  background: var(--border2);
  border-radius: 99px;
}

[data-theme="light"] .add-btn,
[data-theme="light"] .auth-btn,
[data-theme="light"] .filter-btn.active,
[data-theme="light"] .lang-btn.active,
[data-theme="light"] .settings-save {
  background: #8a7040;
  border-color: #8a7040;
  color: #ffffff;
}

[data-theme="light"] .add-btn:hover,
[data-theme="light"] .auth-btn:hover,
[data-theme="light"] .settings-save:hover {
  background: #6e5830;
  border-color: #6e5830;
}

.auth-link-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text3);
  font-size: 12px;
  font-family: 'Noto Sans KR', sans-serif;
  transition: color 0.15s;
}

.auth-link-btn:hover {
  color: var(--text2);
}