:root {
  --bg: #f9f8f6;
  --surface: #ffffff;
  --surface-subtle: #f5f6f8;
  --border: #e6e3de;
  --text: #18191d;
  --text-muted: #5c6167;
  --accent: #3d6b50;
  --accent-light: #eaf2ec;
  --danger: #b33a2d;
  --danger-hover: #922f24;
  --radius: 12px;
  --radius-sm: 8px;
  --header-h: 52px;
  --seg-nav-h: 58px;
  --total-nav-h: calc(var(--header-h) + var(--seg-nav-h));
  --max-width: 600px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Pretendard', 'Noto Sans KR', 'Segoe UI', sans-serif;
  background: var(--surface);
  color: var(--text);
  line-height: 1.65;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

#app {
  max-width: var(--max-width);
  margin: 0 auto;
  min-height: 100vh;
  position: relative;
  background: var(--surface);
}

.hidden {
  display: none !important;
}


/* ── HEADER ── */

header {
  position: sticky;
  top: 0;
  background: var(--surface);
  height: var(--header-h);
  display: flex;
  align-items: center;
  padding: 0 20px;
  z-index: 10;
  border-bottom: 1px solid var(--border);
}

.app-title {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: var(--text);
}


/* ── SEGMENTED PICKER NAV ── */

.seg-nav-wrap {
  position: sticky;
  top: var(--header-h);
  z-index: 9;
  background: var(--surface);
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
}

.seg-nav {
  display: flex;
  background: var(--surface-subtle);
  border-radius: 9px;
  padding: 2px;
  gap: 2px;
}

.seg-btn {
  flex: 1;
  padding: 7px 0;
  border: none;
  background: transparent;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
  line-height: 1.4;
}

.seg-btn.active {
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  box-shadow: 0 2px 3px rgba(0,0,0,0.1);
}


/* ── VIEWS ── */

main {
  padding: 0;
}

.view {
  padding: 24px 20px;
  min-height: calc(100vh - var(--total-nav-h));
  background: var(--surface);
}

.view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.view-header h2 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.4px;
}

.view-toggle {
  display: flex;
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 3px;
  gap: 2px;
}

.toggle-btn {
  padding: 5px 14px;
  font-size: 12px;
  font-weight: 500;
  font-family: inherit;
  border-radius: 5px;
  color: var(--text-muted);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: all 0.15s;
}

.toggle-btn.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.empty-state {
  text-align: center;
  padding: 64px 20px;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.9;
}


/* ── TODAY VIEW ── */

.view-today {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding: 0 !important;
  height: calc(100vh - var(--total-nav-h));
  min-height: calc(100vh - var(--total-nav-h));
  background: var(--surface);
}

/* gradient blobs */
.gradient-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

.grad-blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(72px);
  opacity: 0.65;
}

.grad-blob-1 {
  width: 340px;
  height: 340px;
  top: 18%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--grad-c1, #ffc2dd);
}

.grad-blob-2 {
  width: 240px;
  height: 240px;
  top: 30%;
  left: 10%;
  background: var(--grad-c2, #e0b4ff);
}

.grad-blob-3 {
  width: 200px;
  height: 200px;
  top: 38%;
  right: 5%;
  background: var(--grad-c3, #ffd6f5);
}

/* center content */
.today-center {
  position: relative;
  z-index: 1;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 32px;
  text-align: center;
  gap: 20px;
}

.today-date-label {
  font-size: 14px;
  color: var(--text-muted);
  font-weight: 400;
  letter-spacing: -0.1px;
}

.today-question-text {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.4px;
  line-height: 1.45;
  color: var(--text);
}

.btn-other-q {
  background: rgba(255,255,255,0.8);
  border: none;
  border-radius: 360px;
  padding: 9px 20px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  color: var(--text-muted);
  cursor: pointer;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: inset 1px 1px 1px rgba(255,255,255,0.6), 0 1px 4px rgba(0,0,0,0.06);
  transition: opacity 0.15s;
}

.btn-other-q:hover {
  opacity: 0.8;
}

/* bottom button area */
.today-bottom {
  position: relative;
  z-index: 1;
  padding: 20px;
  padding-bottom: calc(20px + env(safe-area-inset-bottom));
}

.btn-dark-pill {
  width: 100%;
  padding: 16px 20px;
  background: #393838;
  color: white;
  border: none;
  border-radius: 14px;
  font-size: 16px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  letter-spacing: -0.2px;
  line-height: 1.4;
  transition: opacity 0.15s;
}

.btn-dark-pill:hover {
  opacity: 0.85;
}


/* ── ANSWER SHEET ── */

.answer-sheet {
  position: fixed;
  inset: 0;
  z-index: 100;
}

.answer-sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.3);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}

.answer-sheet-panel {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  max-width: var(--max-width);
  margin: 0 auto;
  background: var(--surface);
  border-radius: 20px 20px 0 0;
  padding: 28px 20px 24px;
  padding-bottom: calc(24px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 16px;
  animation: slideUpSheet 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  max-height: 82vh;
}

@keyframes slideUpSheet {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

.sheet-question {
  font-size: 18px;
  font-weight: 700;
  line-height: 1.5;
  letter-spacing: -0.3px;
  color: var(--text);
}

.answer-sheet-panel textarea {
  min-height: 140px;
  max-height: 280px;
  resize: none;
}


/* ── REVIEW DETAIL (full screen) ── */

.review-detail {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 100px;
  padding-bottom: calc(24px + env(safe-area-inset-bottom));
  padding-left: 20px;
  padding-right: 20px;
  gap: 20px;
  overflow: hidden;
}

.review-detail.hidden {
  display: none !important;
}

/* gradient background */
.review-detail-bg {
  position: absolute;
  inset: 0;
  background: #ffffff;
  z-index: 0;
}

.review-detail-blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(50px);
  opacity: 0.6;
}

.rd-blob-1 {
  width: 380px;
  height: 380px;
  top: -60px;
  left: 50%;
  transform: translateX(-50%);
}

.rd-blob-2 {
  width: 280px;
  height: 280px;
  bottom: 80px;
  left: -80px;
}

.rd-blob-3 {
  width: 260px;
  height: 260px;
  top: 250px;
  right: -80px;
}

/* frosted glass card */
.review-detail-card {
  position: relative;
  z-index: 1;
  background: rgba(255, 255, 255, 0.5);
  border-radius: 20px;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.06);
  width: 100%;
  max-width: 335px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 24px;
  -webkit-overflow-scrolling: touch;
  animation: fadeIn 0.25s ease;
}

.review-detail-title {
  font-size: 20px;
  font-weight: 700;
  color: #18191d;
  letter-spacing: -0.2px;
  line-height: 1.4;
  margin-bottom: 20px;
}

.review-detail-body {
  font-size: 16px;
  line-height: 1.6;
  color: #18191d;
  letter-spacing: -0.02em;
  white-space: pre-wrap;
}

/* close button */
.review-detail-close-wrap {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 335px;
  flex-shrink: 0;
}

.review-close-btn {
  width: 100%;
  height: 53px;
  background: #f5f6f8;
  border: 1px solid #edf0f7;
  border-radius: 14px;
  font-size: 16px;
  font-weight: 600;
  color: #5c6167;
  cursor: pointer;
  font-family: inherit;
  transition: opacity 0.15s;
}

.review-close-btn:hover {
  opacity: 0.75;
}


/* ── DIARY (chat style) ── */

.chat-list-container {
  background: #f5f6f8;
  border-radius: 20px;
  padding: 24px 20px;
}

.chat-group {
  margin-bottom: 28px;
}

.chat-group:last-child {
  margin-bottom: 0;
}

.chat-date-divider {
  text-align: center;
  margin-bottom: 18px;
}

.chat-date-divider span {
  font-size: 12px;
  font-weight: 500;
  color: #5c6167;
  letter-spacing: 0.06px;
}

.chat-message {
  display: flex;
  align-items: flex-end;
  gap: 0;
  margin-bottom: 0;
}

.chat-question {
  justify-content: flex-start;
  margin-bottom: 10px;
}

.chat-answer {
  justify-content: flex-end;
}

.chat-bubble {
  max-width: 88%;
  padding: 9px 13px;
  font-size: 14px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
  letter-spacing: -0.02em;
}

/* 질문 말풍선 - 흰색, 왼쪽 하단 꼭짓점 */
.chat-question .chat-bubble {
  background: #ffffff;
  border-radius: 18px 18px 18px 4px;
  color: #18191d;
  font-style: normal;
  display: flex;
  align-items: flex-start;
  gap: 5px;
}

/* 번개 아이콘 */
.chat-lightning {
  font-size: 13px;
  flex-shrink: 0;
  margin-top: 1px;
  line-height: 1.45;
}

/* 답변 말풍선 - 핑크, 오른쪽 하단 꼭짓점 */
.chat-answer .chat-bubble {
  background: #ff9dde;
  border-radius: 18px 18px 4px 18px;
  color: #ffffff;
  font-style: normal;
}

.chat-edit-btn {
  align-self: flex-end;
  flex-shrink: 0;
  margin-bottom: 2px;
  margin-right: 6px;
}

/* cal detail styles */
.entry-date {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.5px;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.entry-question {
  font-size: 13px;
  color: var(--text-muted);
  font-style: italic;
  margin-bottom: 10px;
  line-height: 1.5;
}

.entry-answer {
  font-size: 15px;
  line-height: 1.75;
  white-space: pre-wrap;
}


/* ── COMMENTS ── */

.chat-comments {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  margin-top: 8px;
  padding-right: 14px;
}

.chat-comment-item {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  max-width: 78%;
}

.chat-comment-date {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  margin-top: 4px;
  letter-spacing: 0.2px;
}

.chat-comment-text {
  background: var(--accent-light);
  border: 1px solid #c5ddc8;
  border-radius: 14px 14px 4px 14px;
  padding: 9px 14px;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
}

.comments-section {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.comments-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 12px;
}

.comment-item {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.comment-date {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
  padding-top: 2px;
}

.comment-text {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  white-space: pre-wrap;
}

.comment-add {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.comment-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
  width: 100%;
}

.comment-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  font-family: inherit;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  resize: none;
  outline: none;
  transition: border-color 0.15s;
}

.comment-input:focus {
  border-color: var(--accent);
  background: var(--surface);
}

.comment-input::placeholder {
  color: var(--text-muted);
}

.btn-comment-save {
  width: auto !important;
  padding: 8px 16px;
  font-size: 13px;
  align-self: flex-end;
}


/* ── CALENDAR ── */

.cal-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

#cal-month-title {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.3px;
}

.cal-week-headers {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  margin-bottom: 4px;
}

.cal-week-headers div {
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  padding: 6px 0;
}

.cal-week-headers div:first-child { color: #c0392b; }
.cal-week-headers div:last-child  { color: #2980b9; }

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 3px;
  margin-bottom: 16px;
}

.cal-day {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 400;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: default;
  position: relative;
  font-family: inherit;
  transition: all 0.15s;
}

.cal-day.is-sun { color: #c0392b; }
.cal-day.is-sat { color: #2980b9; }

.cal-day.has-entry {
  cursor: pointer;
  color: var(--text);
  font-weight: 600;
}

.cal-day.is-today {
  background: var(--surface-subtle);
  font-weight: 600;
}

.cal-day.is-selected {
  background: var(--text) !important;
  color: var(--surface) !important;
}

.cal-day.empty {
  pointer-events: none;
}

.cal-detail {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  animation: fadeIn 0.18s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}


/* ── SUMMARY / REVIEW LIST ── */

.review-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  background: #f5f6f8;
  border: none;
  border-radius: 20px;
  height: 60px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: opacity 0.15s;
  width: 100%;
  text-align: left;
  font-family: inherit;
}

.review-item:hover {
  opacity: 0.8;
}

.review-item-icon {
  font-size: 22px;
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.review-item-title {
  flex: 1;
  font-size: 14px;
  font-weight: 600;
  color: #18191d;
  letter-spacing: -0.14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.review-item-arrow {
  color: #5c6167;
  font-size: 16px;
  flex-shrink: 0;
  line-height: 1;
}


/* ── SETTINGS ── */

.settings-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.settings-section label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.6px;
  text-transform: uppercase;
}

.hint {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
  margin-top: -2px;
}

.danger-zone {
  border-color: #f9dedd;
}


/* ── BUTTONS ── */

button {
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  border: none;
  border-radius: var(--radius-sm);
  transition: all 0.15s;
}

.btn-primary {
  background: var(--text);
  color: var(--surface);
  padding: 12px 20px;
  width: 100%;
}

.btn-primary:hover {
  opacity: 0.82;
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  padding: 10px 16px;
}

.btn-ghost:hover {
  background: var(--surface-subtle);
  color: var(--text);
}

.btn-danger {
  background: var(--danger);
  color: white;
  padding: 10px 16px;
}

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

.btn-sm {
  font-size: 13px;
  padding: 7px 12px;
}


/* ── INPUTS ── */

input[type="password"],
input[type="text"] {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
  background: var(--surface);
  outline: none;
  transition: border-color 0.15s;
}

input:focus {
  border-color: var(--accent);
}

textarea {
  width: 100%;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  font-family: inherit;
  font-size: 15px;
  line-height: 1.75;
  color: var(--text);
  resize: vertical;
  min-height: 160px;
  outline: none;
  transition: border-color 0.15s;
}

textarea:focus {
  border-color: var(--accent);
}

textarea::placeholder {
  color: var(--text-muted);
}


/* ── TOAST ── */

.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  background: #393838;
  color: white;
  padding: 12px 24px;
  border-radius: 100px;
  font-size: 13px;
  font-weight: 500;
  z-index: 200;
  white-space: nowrap;
  animation: slideUp 0.2s ease;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateX(-50%) translateY(8px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}


/* ── RESPONSIVE ── */

@media (max-width: 480px) {
  .view {
    padding: 20px 16px;
  }

  .today-question-text {
    font-size: 20px;
  }

  textarea {
    font-size: 16px;
  }

  .btn-primary {
    padding: 14px 20px;
  }
}
