:root {
  --bg: #0f172a;
  --surface: #1a2540;
  --surface-2: #232f52;
  --text: #e6eaf5;
  --text-dim: #9aa4c0;
  --accent: #6366f1;
  --accent-2: #14b8a6;
  --red: #ef4444;
  --yellow: #eab308;
  --green: #22c55e;
  --gold: #facc15;
  --border: #2b3762;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  -webkit-tap-highlight-color: transparent;
}

#app {
  max-width: 560px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding-bottom: 96px;
}

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

.brand { font-size: 18px; font-weight: 700; }

.auth-area { display: flex; align-items: center; gap: 8px; }
.auth-area img { width: 28px; height: 28px; border-radius: 50%; }
.auth-area button {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 600;
}
.auth-area .google-btn {
  background: #fff;
  color: #1f2937;
  border: none;
  display: flex;
  align-items: center;
  gap: 6px;
}

.tabs {
  display: flex;
  gap: 4px;
  padding: 10px 16px 0;
  position: sticky;
  top: 53px;
  background: var(--bg);
  z-index: 19;
}

.tab-btn {
  flex: 1;
  padding: 10px 0;
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 15px;
  font-weight: 600;
  border-bottom: 2px solid transparent;
}
.tab-btn.active { color: var(--text); border-bottom-color: var(--accent); }

main { flex: 1; padding: 12px 16px 20px; }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

.signed-out-notice {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px 16px;
  text-align: center;
  color: var(--text-dim);
  margin-top: 24px;
}
.signed-out-notice p { margin: 0 0 8px; line-height: 1.6; }
.signed-out-notice p:last-child { margin-bottom: 0; }
.signed-out-notice strong { color: var(--red); word-break: break-all; }
.signed-out-notice .notice-sub { font-size: 13px; }

.add-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
  margin-top: 8px;
}

textarea#paste-input {
  width: 100%;
  min-height: 110px;
  resize: vertical;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  padding: 10px;
  font-size: 15px;
  font-family: inherit;
}

.add-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.lang-toggle { display: flex; gap: 6px; flex: 1; flex-wrap: wrap; }
.lang-btn {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: 999px;
  padding: 8px 10px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}
.lang-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.primary-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 700;
}
.primary-btn:disabled { opacity: 0.5; }

.ghost-btn {
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
}

.voice-warning {
  margin-top: 10px;
  background: #3a2a12;
  border: 1px solid #7c5210;
  color: #facc15;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 13px;
}

/* 과목 바로가기. 스크롤해도 위에 붙어 있어서 아무 때나 누를 수 있다. */
.subject-nav {
  position: sticky;
  top: 96px;
  z-index: 18;
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 10px 0 8px;
  margin-top: 8px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  scrollbar-width: none;
}
.subject-nav::-webkit-scrollbar { display: none; }
.jump-btn {
  flex: none;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}
.jump-btn:active { background: var(--accent); border-color: var(--accent); color: #fff; }

.file-section { margin-top: 22px; scroll-margin-top: 150px; }

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.section-head h2 { font-size: 15px; margin: 0; display: flex; align-items: center; gap: 6px; }
.count { color: var(--text-dim); font-weight: 400; font-size: 13px; }

.quick-select { display: flex; gap: 6px; }
.quick-select button {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: 8px;
  padding: 5px 8px;
  font-size: 12px;
}

.file-list { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }

.file-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
}
.file-item.playing { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }

.file-item-row { display: flex; align-items: flex-start; gap: 10px; }
.file-item-row input[type="checkbox"] {
  width: 22px; height: 22px; flex: none; margin-top: 2px;
  accent-color: var(--accent);
}
.file-item-main { flex: 1; min-width: 0; cursor: pointer; }
.file-item-title { font-size: 14px; font-weight: 600; line-height: 1.4; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.file-item-meta { font-size: 11px; color: var(--text-dim); margin-top: 4px; }
.file-item-edit {
  background: transparent; border: none; color: var(--text-dim);
  font-size: 16px; line-height: 1; padding: 4px 6px; flex: none;
}
.file-item-delete {
  background: transparent; border: none; color: var(--text-dim);
  font-size: 18px; line-height: 1; padding: 4px 6px; flex: none;
}

.file-item.editing { border-color: var(--accent); }
.edit-textarea {
  width: 100%;
  min-height: 90px;
  resize: vertical;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 8px;
  font-size: 14px;
  font-family: inherit;
}
.edit-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
}
.edit-actions .primary-btn, .edit-actions .ghost-btn {
  padding: 8px 14px;
  font-size: 13px;
}
.file-item-preview {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-dim);
  white-space: pre-wrap;
  display: none;
}
.file-item.expanded .file-item-preview { display: block; }

.empty-hint { color: var(--text-dim); font-size: 13px; margin-top: 10px; display: none; }
.empty-hint.show { display: block; }

.today-score-card {
  margin-top: 26px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
}
.today-score-row {
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 5px 0;
  font-size: 13px;
  color: var(--text-dim);
}
.today-score-row strong { font-size: 17px; color: var(--text); }
.today-score-row .max-label { font-size: 12px; }
.today-score-row.total { border-top: 1px solid var(--border); margin-top: 4px; padding-top: 10px; font-weight: 600; }
.today-score-row.total strong { color: var(--accent-2); font-size: 20px; }

/* Calendar */
.cal-header { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; }
.icon-btn { background: var(--surface); border: 1px solid var(--border); color: var(--text); width: 40px; height: 40px; border-radius: 10px; font-size: 18px; }
.cal-title { text-align: center; }
#cal-month-label { font-size: 17px; font-weight: 700; }
#cal-avg { font-size: 13px; color: var(--accent-2); font-weight: 600; margin-top: 2px; }

.cal-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  color: var(--text-dim);
  font-size: 12px;
  margin-top: 16px;
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  margin-top: 6px;
}

.cal-day {
  aspect-ratio: 1;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 11px;
  color: var(--text-dim);
}
.cal-day.empty { visibility: hidden; }
.cal-day.today { border-color: var(--accent); }
.cal-day .date-num { font-size: 12px; }
.cal-day .mark { font-size: 15px; font-weight: 700; line-height: 1; }
.cal-day.red .mark { color: var(--red); }
.cal-day.yellow .mark { color: var(--yellow); }
.cal-day.green .mark { color: var(--green); }
/* 황금별 받은 날은 칸 자체도 눈에 띄게 */
.cal-day.gold {
  border-color: var(--gold);
  background: linear-gradient(160deg, rgba(250, 204, 21, 0.16), var(--surface));
}
.cal-day.gold .mark { font-size: 14px; letter-spacing: -1px; }
.cal-day.gold-2 .mark { font-size: 11px; letter-spacing: -2px; }
/* 공부를 쉰 날. 달을 연한 회색으로 만들어(색을 빼고 밝기를 올린다) 한 날들이 더 도드라지게 */
.cal-day.moon { opacity: 0.75; }
.cal-day.moon .mark {
  font-size: 12px;
  filter: grayscale(1) brightness(1.9);
}
.cal-day.future { opacity: 0.35; }
.cal-day:not(.empty):not(.future) { cursor: pointer; }

.cal-legend { display: flex; gap: 16px; justify-content: center; margin-top: 14px; font-size: 12px; color: var(--text-dim); flex-wrap: wrap; }
.legend-item { display: flex; align-items: center; gap: 5px; }
.legend-item .mark { font-weight: 700; }
.legend-item .mark.moon-mark { filter: grayscale(1) brightness(1.9); }
.legend-item .mark.red { color: var(--red); }
.legend-item .mark.yellow { color: var(--yellow); }
.legend-item .mark.green { color: var(--green); }

.day-detail {
  margin-top: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 13px;
}
.day-detail .dd-title { font-weight: 700; margin-bottom: 6px; }
.day-detail .dd-row { display: flex; justify-content: space-between; color: var(--text-dim); padding: 2px 0; }

/* Player bar */
.player-bar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  max-width: 560px;
  margin: 0 auto;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom, 0px));
  z-index: 30;
}
.player-info { font-size: 12px; color: var(--text-dim); margin-bottom: 6px; display: flex; justify-content: space-between; gap: 8px; }
#now-playing { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player-controls { display: flex; align-items: center; gap: 8px; }
#speed-select {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 6px;
  font-size: 13px;
}
.player-controls .primary-btn, .player-controls .ghost-btn { flex: 1; }

.build-tag {
  text-align: center;
  color: var(--text-dim);
  font-size: 10px;
  opacity: 0.5;
  padding: 4px 0 110px;
}

.toast {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--accent-2);
  color: #06251f;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  z-index: 40;
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}

@media (min-width: 600px) {
  #app { padding-bottom: 100px; }
}
