/* ===== Auth Screen ===== */
.auth-screen {
  max-width: 400px;
  margin: 0 auto;
  padding: 3rem 0;
  animation: fadeInUp 500ms cubic-bezier(0.25,0.46,0.45,0.94) both;
}
.auth-screen[hidden] { display: none; }

.auth-logo {
  text-align: center;
  margin-bottom: 2rem;
}
.auth-logo-title {
  font-family: var(--font-diary);
  font-size: clamp(1.5rem, 1.2rem + 1.5vw, 2.25rem);
  font-weight: 700;
  color: var(--color-text);
}
.auth-logo-title::after {
  content: '';
  display: block;
  width: 60px;
  height: 2px;
  background: var(--color-primary);
  margin: 0.5rem auto 0;
  border-radius: 1px;
}
.auth-logo-sub {
  font-size: 0.85rem;
  color: var(--color-text-light);
  margin-top: 0.5rem;
}

.auth-card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 1.5rem;
}
.auth-card-title {
  font-family: var(--font-body);
  font-size: 1.1rem;
  font-weight: 500;
  color: var(--color-text);
  margin-bottom: 1.25rem;
  text-align: center;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.auth-field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}
.auth-field label {
  font-size: 0.85rem;
  color: var(--color-text-light);
  font-weight: 500;
}
.auth-field input {
  font-family: var(--font-body);
  font-size: 0.9rem;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  outline: none;
  background: var(--color-surface);
  color: var(--color-text);
  transition: border-color 200ms ease;
}
.auth-field input:focus {
  border-color: var(--color-primary);
}
.auth-field input[aria-invalid="true"] {
  border-color: var(--color-error);
}
.auth-field-error {
  font-size: 0.75rem;
  color: var(--color-error);
  min-height: 1.1em;
}

.btn-auth {
  display: block;
  width: 100%;
  background: var(--color-primary);
  color: #fff;
  border: none;
  padding: 0.7rem 1.2rem;
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 200ms ease;
  margin-top: 0.5rem;
}
.btn-auth:hover { background: var(--color-primary-hover); }
.btn-auth:active { transform: scale(0.98); }
.btn-auth:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn-auth:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; }

.auth-switch {
  text-align: center;
  margin-top: 1rem;
  font-size: 0.85rem;
  color: var(--color-text-light);
}
.auth-switch-link {
  background: none;
  border: none;
  color: var(--color-primary);
  font-family: var(--font-body);
  font-size: 0.85rem;
  cursor: pointer;
  text-decoration: underline;
  padding: 0;
}
.auth-switch-link:hover { color: var(--color-primary-hover); }
.auth-switch-link:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; }

.auth-message {
  font-size: 0.85rem;
  padding: 0.6rem 0.85rem;
  border-radius: var(--radius-sm);
  margin-top: 0.75rem;
  text-align: center;
}
.auth-message[hidden] { display: none; }
.auth-message.success { background: var(--color-success-bg); color: var(--color-success); }
.auth-message.error { background: var(--color-error-bg); color: var(--color-error); }

.auth-divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 0.75rem 0;
  color: var(--color-text-muted);
  font-size: 0.8rem;
}
.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--color-divider);
}

/* OAuth buttons */
.btn-oauth-google {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.65rem 1.2rem;
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 200ms ease, border-color 200ms ease;
}
.btn-oauth-google:hover {
  background: var(--color-bg);
  border-color: var(--color-text-muted);
}
.btn-oauth-google:active { transform: scale(0.98); }
.btn-oauth-google:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; }
.btn-oauth-google:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.oauth-google-icon { flex-shrink: 0; }

/* Password strength indicator */
.password-strength {
  display: flex;
  gap: 4px;
  margin-top: 2px;
}
.password-strength-bar {
  flex: 1;
  height: 3px;
  background: var(--color-divider);
  border-radius: 2px;
  transition: background 200ms ease;
}
.password-strength[data-level="weak"] .password-strength-bar:nth-child(1) { background: var(--color-error); }
.password-strength[data-level="fair"] .password-strength-bar:nth-child(1),
.password-strength[data-level="fair"] .password-strength-bar:nth-child(2) { background: #f9a825; }
.password-strength[data-level="good"] .password-strength-bar:nth-child(1),
.password-strength[data-level="good"] .password-strength-bar:nth-child(2),
.password-strength[data-level="good"] .password-strength-bar:nth-child(3) { background: #66bb6a; }
.password-strength[data-level="strong"] .password-strength-bar { background: var(--color-success); }

/* ===== Onboarding ===== */
.onboarding-screen {
  max-width: 480px;
  margin: 0 auto;
  padding: 2rem 0;
  animation: fadeInUp 500ms cubic-bezier(0.25,0.46,0.45,0.94) both;
}
.onboarding-screen[hidden] { display: none; }

.onboarding-progress {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 2rem;
}
.onboarding-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-border);
  transition: all 300ms ease;
}
.onboarding-dot.active {
  background: var(--color-primary);
  width: 24px;
  border-radius: 4px;
}
.onboarding-dot.completed {
  background: var(--color-primary);
}

.onboarding-card {
  background: var(--color-surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-md);
  padding: 2rem 1.5rem;
  text-align: center;
  animation: fadeInUp 400ms cubic-bezier(0.25,0.46,0.45,0.94) both;
}
.onboarding-card[hidden] { display: none; }

.onboarding-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
  display: block;
}
.onboarding-title {
  font-family: var(--font-diary);
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: 0.75rem;
}
.onboarding-desc {
  font-size: 0.9rem;
  color: var(--color-text-light);
  line-height: 1.8;
  margin-bottom: 1.5rem;
}

.onboarding-sample {
  background: var(--gradient-response);
  border-radius: var(--radius-md);
  padding: 1rem;
  margin-bottom: 1.5rem;
  text-align: left;
}
.onboarding-sample-text {
  font-family: var(--font-diary);
  font-size: 0.95rem;
  color: var(--color-text);
  font-style: italic;
}

.onboarding-time-select {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
  margin-bottom: 1.5rem;
}
.onboarding-time-btn {
  background: var(--color-surface-warm);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 0.5rem 1rem;
  font-family: var(--font-body);
  font-size: 0.85rem;
  color: var(--color-text);
  cursor: pointer;
  transition: all 200ms ease;
}
.onboarding-time-btn:hover {
  border-color: var(--color-primary);
}
.onboarding-time-btn[aria-pressed="true"] {
  background: rgba(196, 139, 108, 0.2);
  border-color: var(--color-primary);
  font-weight: 500;
}
.onboarding-time-btn:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

.onboarding-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
}
.btn-onboarding-next {
  background: var(--color-primary);
  color: #fff;
  border: none;
  padding: 0.7rem 2rem;
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 200ms ease;
}
.btn-onboarding-next:hover { background: var(--color-primary-hover); }
.btn-onboarding-next:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; }

.btn-onboarding-skip {
  background: none;
  border: none;
  color: var(--color-text-muted);
  font-family: var(--font-body);
  font-size: 0.85rem;
  cursor: pointer;
  padding: 0.7rem 1rem;
  transition: color 200ms ease;
}
.btn-onboarding-skip:hover { color: var(--color-text-light); }
.btn-onboarding-skip:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; }

/* ===== Profile Section ===== */
.profile-screen {
  animation: fadeInUp 400ms cubic-bezier(0.25,0.46,0.45,0.94) both;
}
.profile-screen[hidden] { display: none; }

.profile-card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
  padding: 1.5rem;
  margin-bottom: 1rem;
}
.profile-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.profile-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--gradient-response);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  flex-shrink: 0;
}
.profile-info {
  flex: 1;
  min-width: 0;
}
.profile-nickname {
  font-size: 1.1rem;
  font-weight: 500;
  color: var(--color-text);
}
.profile-email {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-stats-row {
  display: flex;
  gap: 0;
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-bottom: 1.25rem;
}
.profile-stat {
  flex: 1;
  text-align: center;
  padding: 0.75rem 0.5rem;
}
.profile-stat + .profile-stat {
  border-left: 1px solid var(--color-divider);
}
.profile-stat-value {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--color-text);
  display: block;
}
.profile-stat-label {
  font-size: 0.7rem;
  color: var(--color-text-muted);
}

.profile-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.profile-field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}
.profile-field label {
  font-size: 0.85rem;
  color: var(--color-text-light);
  font-weight: 500;
}
.profile-field input,
.profile-field textarea {
  font-family: var(--font-body);
  font-size: 0.9rem;
  padding: 0.6rem 0.85rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  outline: none;
  background: var(--color-surface);
  color: var(--color-text);
  transition: border-color 200ms ease;
  resize: none;
}
.profile-field input:focus,
.profile-field textarea:focus {
  border-color: var(--color-primary);
}

.profile-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  margin-top: 0.5rem;
}
.btn-profile-save {
  background: var(--color-primary);
  color: #fff;
  border: none;
  padding: 0.55rem 1.2rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 200ms ease;
}
.btn-profile-save:hover { background: var(--color-primary-hover); }
.btn-profile-save:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-profile-save:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; }

.btn-profile-back {
  background: var(--color-surface-warm);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  padding: 0.55rem 1.2rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 200ms ease;
}
.btn-profile-back:hover { background: var(--color-divider); }
.btn-profile-back:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; }

.profile-section {
  margin-top: 1rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.profile-section-title {
  padding: 0.7rem 1rem;
  font-family: var(--font-body);
  font-size: 0.85rem;
  cursor: pointer;
  background: var(--color-surface-warm);
  user-select: none;
}
.profile-section-title:hover { background: var(--color-divider); }
.profile-section[open] > .profile-section-title { border-bottom: 1px solid var(--color-border); }
.profile-section .profile-form { padding: 1rem; }
.profile-section-danger { border-color: #e74c3c44; }
.profile-section-danger > .profile-section-title { color: #c0392b; }
.danger-warning {
  padding: 0.8rem 1rem 0;
  font-size: 0.8rem;
  color: #c0392b;
  line-height: 1.5;
}
.btn-danger {
  display: block;
  margin: 0.8rem 1rem 1rem;
  background: #c0392b;
  color: #fff;
  border: none;
  padding: 0.55rem 1.2rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 200ms ease;
}
.btn-danger:hover { background: #a93226; }
.btn-danger:disabled { opacity: 0.5; cursor: not-allowed; }

/* Profile Section Cards */
.profile-section-card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--color-border);
  margin-bottom: 1rem;
  overflow: hidden;
}
.profile-section-card-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--color-divider);
  background: var(--color-surface-warm);
}
.profile-section-card-header svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  color: var(--color-text-light);
}
.profile-section-card-header h3 {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-text);
  margin: 0;
}
.profile-section-card-body {
  padding: 1rem;
}

/* Profile streak in profile tab */
.profile-streak-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 0;
}
.profile-streak-number {
  font-size: 2rem;
  font-weight: 700;
  color: var(--color-primary);
  line-height: 1;
  min-width: 3rem;
  text-align: center;
}
.profile-streak-info {
  flex: 1;
}
.profile-streak-label {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--color-text);
}
.profile-streak-sub {
  font-size: 0.78rem;
  color: var(--color-text-muted);
  margin-top: 0.15rem;
}

/* Bio character counter */
.profile-field-footer {
  display: flex;
  justify-content: flex-end;
  margin-top: 0.15rem;
}
.char-counter {
  font-size: 0.72rem;
  color: var(--color-text-muted);
  transition: color 200ms;
}
.char-counter.near-limit { color: var(--color-warning, #e67e22); }
.char-counter.at-limit { color: var(--color-error); font-weight: 600; }

/* AI Tone Selector */
.ai-tone-group {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
}
.ai-tone-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--color-surface-warm);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 0.6rem 0.75rem;
  font-family: var(--font-body);
  font-size: 0.8rem;
  color: var(--color-text);
  cursor: pointer;
  transition: border-color 200ms ease, background 200ms ease;
}
.ai-tone-btn:hover {
  border-color: var(--color-primary);
}
.ai-tone-btn[aria-pressed="true"] {
  border-color: var(--color-primary);
  background: rgba(139,126,116,0.1);
}
.ai-tone-emoji {
  font-size: 1.2rem;
  flex-shrink: 0;
}
.ai-tone-name {
  font-size: 0.78rem;
  white-space: nowrap;
}
@media (max-width: 400px) {
  .ai-tone-group { grid-template-columns: repeat(2, 1fr); gap: 0.4rem; }
  .ai-tone-btn { padding: 0.5rem 0.5rem; }
  .ai-tone-name { font-size: 0.72rem; }
}

/* Notification time presets */
.notification-time-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.notification-time-btn {
  background: var(--color-surface-warm);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 0.4rem 0.75rem;
  font-family: var(--font-body);
  font-size: 0.8rem;
  color: var(--color-text);
  cursor: pointer;
  transition: all 200ms ease;
}
.notification-time-btn:hover {
  border-color: var(--color-primary);
  background: var(--color-surface);
}
.notification-time-btn[aria-pressed="true"] {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
}
.notification-time-btn:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* Dark mode toggle improved */
.setting-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.65rem 0;
}
.setting-row + .setting-row {
  border-top: 1px solid var(--color-divider);
}
.setting-row-label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--color-text);
}
.setting-row-desc {
  font-size: 0.72rem;
  color: var(--color-text-muted);
  margin-top: 0.1rem;
}
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  cursor: pointer;
  flex-shrink: 0;
}
.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}
.toggle-track {
  position: absolute;
  inset: 0;
  background: var(--color-border);
  border-radius: 12px;
  transition: background 200ms;
}
.toggle-switch input:checked + .toggle-track {
  background: var(--color-primary);
}
.toggle-knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  background: #fff;
  border-radius: 50%;
  transition: transform 200ms;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.toggle-switch input:checked ~ .toggle-knob {
  transform: translateX(20px);
}
.toggle-switch input:focus-visible ~ .toggle-track {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* Password strength in profile */
.profile-pw-strength {
  display: flex;
  gap: 3px;
  margin-top: 0.3rem;
}
.profile-pw-bar {
  height: 3px;
  flex: 1;
  border-radius: 2px;
  background: var(--color-divider);
  transition: background 300ms;
}
.profile-pw-strength[data-level="weak"] .profile-pw-bar:nth-child(1) { background: #e74c3c; }
.profile-pw-strength[data-level="fair"] .profile-pw-bar:nth-child(-n+2) { background: #e67e22; }
.profile-pw-strength[data-level="good"] .profile-pw-bar:nth-child(-n+3) { background: #f1c40f; }
.profile-pw-strength[data-level="strong"] .profile-pw-bar { background: #27ae60; }

.btn-logout {
  display: block;
  width: 100%;
  background: none;
  border: 1px solid var(--color-error);
  color: var(--color-error);
  padding: 0.6rem 1rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 200ms ease;
  margin-top: 1rem;
}
.btn-logout:hover { background: var(--color-error-bg); }
.btn-logout:focus-visible { outline: 2px solid var(--color-error); outline-offset: 2px; }

.profile-message {
  font-size: 0.8rem;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  margin-top: 0.5rem;
  text-align: center;
}
.profile-message[hidden] { display: none; }
.profile-message.success { background: var(--color-success-bg); color: var(--color-success); }
.profile-message.error { background: var(--color-error-bg); color: var(--color-error); }

/* ===== Header with user menu ===== */
.app-header {
  text-align: center;
  margin-bottom: 2rem;
  animation: fadeInUp 500ms cubic-bezier(0.25,0.46,0.45,0.94) both;
  position: relative;
}
.app-title {
  font-family: var(--font-diary);
  font-size: clamp(1.5rem, 1.2rem + 1.5vw, 2.25rem);
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: 0.25rem;
}
.app-title::after {
  content: '';
  display: block;
  width: 60px;
  height: 2px;
  background: var(--color-primary);
  margin: 0.5rem auto 0;
  border-radius: 1px;
}
.today-date {
  font-size: clamp(0.8rem, 0.75rem + 0.3vw, 0.875rem);
  color: var(--color-text-light);
}

.user-menu {
  position: absolute;
  top: 0;
  right: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.user-menu[hidden] { display: none; }
.user-menu-name {
  font-size: 0.8rem;
  color: var(--color-text-light);
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.btn-user-menu {
  background: var(--color-surface-warm);
  border: 1px solid var(--color-border);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--color-text);
  transition: all 200ms ease;
}
.btn-user-menu:hover { border-color: var(--color-primary); }
.btn-user-menu:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; }

/* Diary Input */
.diary-input {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
  padding: 1.25rem;
  margin-bottom: 1.5rem;
  transition: border-color 300ms ease, box-shadow 300ms ease;
  animation: fadeInUp 500ms 100ms cubic-bezier(0.25,0.46,0.45,0.94) both;
}
.diary-input:focus-within {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(196, 139, 108, 0.1);
}
.diary-form { display: flex; flex-direction: column; gap: 0.75rem; }
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
#diary-text {
  font-family: var(--font-diary);
  font-size: clamp(0.9rem, 0.85rem + 0.3vw, 1rem);
  color: var(--color-text);
  background: transparent;
  border: none;
  outline: none;
  resize: none;
  min-height: 80px;
  line-height: 1.7;
}
#diary-text::placeholder { color: var(--color-text-muted); }
.btn-expand {
  background: none; border: 1px solid var(--color-border); cursor: pointer;
  color: var(--color-text-light); font-size: 0.7rem; padding: 6px 12px;
  border-radius: var(--radius-sm); font-family: var(--font-body); transition: all 200ms;
  min-height: 32px;
}
.btn-expand:hover { background: var(--color-surface-warm); }
.btn-expand.active { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }
#diary-text.expanded { min-height: 200px; }
.form-actions { display: flex; justify-content: flex-end; align-items: center; gap: 0.5rem; }
.char-count { font-size: 0.75rem; color: var(--color-text-muted); margin-right: auto; }
.char-count.warn { color: #c62828; }
.btn-submit {
  display: inline-flex; align-items: center; gap: 0.4rem;
  background: var(--color-primary);
  color: #fff;
  border: none;
  padding: 0.65rem 1.5rem;
  border-radius: var(--radius-lg);
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 200ms ease, transform 150ms ease, box-shadow 200ms ease;
}
.btn-submit:hover { background: var(--color-primary-hover); box-shadow: 0 4px 12px rgba(194,113,79,0.25); }
.btn-submit:active { transform: scale(0.97); }
.btn-submit:disabled { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: none; }
.btn-submit svg { width: 16px; height: 16px; }

/* AI Response */
.ai-response { margin-bottom: 1.5rem; }
.my-diary-text {
  font-family: var(--font-diary);
  font-size: 0.95rem;
  line-height: 1.7;
  color: var(--color-text);
  background: rgba(0,0,0,0.03);
  border-left: 3px solid var(--color-primary);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 0.75rem 1rem;
  margin: 0 0 1rem 0;
  white-space: pre-wrap;
  word-break: break-word;
}
.my-diary-text[hidden] { display: none; }
[data-theme="dark"] .my-diary-text { background: rgba(255,255,255,0.05); }
.ai-persona-tag {
  font-size: 0.75rem;
  color: var(--color-text-secondary);
  opacity: 0.7;
  margin-bottom: 0.5rem;
  letter-spacing: 0.02em;
}
.response-card {
  background: var(--gradient-response);
  border-radius: var(--radius-xl);
  padding: 1.5rem;
  box-shadow: var(--shadow-md);
  animation: scaleIn 400ms cubic-bezier(0.25,0.46,0.45,0.94) both;
}
.response-card[hidden] { display: none; }
.emotion-emoji { font-size: 3.5rem; display: block; margin-bottom: 0.5rem; }
.emotion-emoji.pop { animation: emojiPop 500ms 200ms cubic-bezier(0.34,1.56,0.64,1) both; }

/* Similar entries section */
.similar-entries {
  margin-top: 1rem;
  padding: 1rem 1.25rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  animation: scaleIn 400ms cubic-bezier(0.25,0.46,0.45,0.94) both;
}
.similar-entries[hidden] { display: none; }
.similar-entries-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--color-text-muted);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-bottom: 0.75rem;
}
.similar-entries-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.similar-entry-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.75rem;
  background: var(--color-surface-warm);
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background 150ms, border-color 150ms;
}
.similar-entry-item:hover {
  background: var(--color-divider);
  border-color: var(--color-border);
}
.similar-entry-emoji { font-size: 1.4rem; flex-shrink: 0; }
.similar-entry-body { flex: 1; min-width: 0; }
.similar-entry-text {
  font-size: 0.85rem;
  color: var(--color-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.similar-entry-date {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  margin-top: 0.1rem;
}
@keyframes emojiPop {
  0%   { transform: scale(0) rotate(-15deg); opacity: 0; }
  60%  { transform: scale(1.25) rotate(5deg); opacity: 1; }
  100% { transform: scale(1) rotate(0deg); }
}
.emotion-label {
  font-size: clamp(0.8rem, 0.75rem + 0.3vw, 0.875rem);
  color: var(--color-text-light);
  margin-bottom: 0.75rem;
}
.empathy-message {
  font-family: var(--font-diary);
  font-size: clamp(1rem, 0.95rem + 0.3vw, 1.15rem);
  line-height: 1.8;
  color: var(--color-text);
  margin-bottom: 0.75rem;
}
.advice-message {
  font-size: clamp(0.85rem, 0.8rem + 0.25vw, 0.95rem);
  color: var(--color-text-light);
  padding-top: 0.75rem;
  border-top: 1px solid var(--color-divider);
}
.advice-message::before { content: '\1F4A1 '; }

/* Analysis Details (collapsible) */
.analysis-details {
  margin-top: 1rem;
  border-top: 1px solid var(--color-divider);
}
.analysis-details[hidden] { display: none; }
.analysis-details-summary {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.6rem 0;
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--color-text-light);
  cursor: pointer;
  list-style: none;
  user-select: none;
  transition: color 200ms ease;
}
.analysis-details-summary::-webkit-details-marker { display: none; }
.analysis-details-summary::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(-45deg);
  transition: transform 200ms ease;
  flex-shrink: 0;
}
.analysis-details[open] > .analysis-details-summary::before {
  transform: rotate(45deg);
}
.analysis-details-summary:hover {
  color: var(--color-text);
}
.analysis-details-summary:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}
[data-theme="dark"] .analysis-details-summary {
  color: var(--color-text-light);
}
[data-theme="dark"] .analysis-details-summary:hover {
  color: var(--color-text);
}

/* Ontology Insights */
.ontology-section {
  padding-top: 0.5rem;
}
.ontology-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--color-text-muted);
  margin-bottom: 0.5rem;
  display: block;
}

/* Confidence Badge (inside analysis details) */
.confidence-badge {
  margin-top: 0.75rem;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(196, 139, 108, 0.15);
  border: 1px solid rgba(196, 139, 108, 0.3);
  border-radius: var(--radius-xl);
  padding: 0.4rem 0.85rem;
  font-size: 0.8rem;
  color: var(--color-text);
}
.confidence-badge[hidden] { display: none; }
.confidence-badge-label {
  font-weight: 500;
}
.confidence-badge-bar {
  width: 80px;
  height: 6px;
  background: var(--color-divider);
  border-radius: 3px;
  overflow: hidden;
}
.confidence-badge-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 600ms cubic-bezier(0.25,0.46,0.45,0.94);
}
.confidence-badge-fill[data-level="high"] { background: #66bb6a; }
.confidence-badge-fill[data-level="mid"] { background: var(--color-primary); }
.confidence-badge-fill[data-level="low"] { background: #ef9a9a; }
.confidence-badge-percent {
  font-weight: 700;
  font-size: 0.85rem;
  min-width: 2.5em;
  text-align: right;
}

/* Vertical Emotion Hierarchy */
.emotion-hierarchy {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0;
  margin-bottom: 0.75rem;
}
.hierarchy-level {
  background: rgba(196, 139, 108, 0.1);
  color: var(--color-text);
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 500;
  position: relative;
}
.hierarchy-level:first-child {
  background: rgba(196, 139, 108, 0.22);
  font-weight: 700;
}
.hierarchy-level:last-child {
  background: rgba(196, 139, 108, 0.35);
}
.hierarchy-arrow {
  display: flex;
  align-items: center;
  padding-left: 1.2rem;
  color: var(--color-text-muted);
  font-size: 0.75rem;
  line-height: 1.4;
}

/* Situation Tags with Emoji */
.situation-tags {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
}
.situation-tag {
  background: rgba(85, 160, 180, 0.15);
  color: #1a6a87;
  padding: 0.35rem 0.65rem;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  border: 1px solid rgba(85, 160, 180, 0.2);
}
.situation-tag-emoji {
  margin-right: 0.25rem;
}

/* Legacy confidence meter (bottom, kept for fallback) */
.confidence-meter {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.75rem;
  color: var(--color-text-light);
}
.confidence-bar {
  width: 60px;
  height: 4px;
  background: var(--color-divider);
  border-radius: 2px;
  overflow: hidden;
}
.confidence-fill {
  height: 100%;
  background: var(--color-primary);
  border-radius: 2px;
  transition: width 400ms ease;
}

/* Loading */
.response-loading { text-align: center; padding: 1.5rem; }
.response-loading[hidden] { display: none; }
.typing-indicator { display: inline-flex; gap: 4px; align-items: center; }
.typing-indicator span {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--color-primary);
  animation: bounce 0.8s infinite;
}
.typing-indicator span:nth-child(2) { animation-delay: 0.15s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.3s; }

/* History */
.diary-history {
  animation: fadeInUp 500ms 200ms cubic-bezier(0.25,0.46,0.45,0.94) both;
}
.section-title {
  font-family: var(--font-body);
  font-size: clamp(1rem, 0.95rem + 0.3vw, 1.15rem);
  color: var(--color-text);
  font-weight: 600;
  margin-bottom: 1.25rem;
}
/* ===== Select Mode ===== */
.history-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}
.history-title-row .section-title { margin-bottom: 0; }
.btn-select-mode {
  background: none;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 0.3rem 0.75rem;
  font-size: 0.8rem;
  color: var(--color-text-muted);
  cursor: pointer;
  font-family: var(--font-body);
  transition: color 200ms, border-color 200ms;
}
.btn-select-mode:hover { color: var(--color-primary); border-color: var(--color-primary); }
.btn-select-mode.active { color: var(--color-primary); border-color: var(--color-primary); font-weight: 600; }
.select-toolbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 1rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  margin-bottom: 0.75rem;
}
.select-toolbar[hidden] { display: none; }
.select-all-label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.82rem;
  color: var(--color-text-muted);
  cursor: pointer;
  flex: 1;
}
.select-all-label input[type="checkbox"] { accent-color: var(--color-primary); }
.btn-select-delete {
  background: #e74c3c;
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.35rem 0.9rem;
  font-size: 0.8rem;
  cursor: pointer;
  font-family: var(--font-body);
  transition: opacity 200ms;
}
.btn-select-delete:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-select-cancel {
  background: none;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
  color: var(--color-text-muted);
  cursor: pointer;
  font-family: var(--font-body);
}
.history-item .select-check {
  display: none;
  margin-left: 0.5rem;
  margin-right: -0.5rem;
  accent-color: var(--color-primary);
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  cursor: pointer;
}
.select-mode .history-item .select-check { display: block; }
.select-mode .history-item .btn-bookmark { display: none; }
.history-item.selected { border-color: var(--color-primary); background: rgba(196, 139, 108, 0.05); }

.history-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-height: 60vh;
  overflow-y: auto;
  padding-right: 4px;
}
.history-list::-webkit-scrollbar { width: 4px; }
.history-list::-webkit-scrollbar-thumb { background: var(--color-border); border-radius: 2px; }
.history-list::-webkit-scrollbar-track { background: transparent; }
.history-item {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  position: relative;
  display: flex;
  align-items: stretch;
  border: 1px solid var(--color-border);
  animation: fadeInUp 300ms cubic-bezier(0.25,0.46,0.45,0.94) both;
  transition: box-shadow 200ms ease, border-color 200ms ease, transform 200ms ease;
}
.history-item:hover {
  box-shadow: var(--shadow-md);
  border-color: transparent;
  transform: translateY(-1px);
}
.history-item-inner {
  display: flex;
  align-items: center;
  gap: 1rem;
  width: 100%;
  padding: 1rem 1.25rem;
  background: none;
  border: none;
  cursor: pointer;
  font: inherit;
  color: inherit;
  text-align: left;
  border-radius: var(--radius-lg);
}
.history-item-inner:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}
.history-emoji {
  width: 48px; height: 48px;
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem;
  flex-shrink: 0;
}
.history-content { flex: 1; min-width: 0; }
.history-meta {
  display: flex; align-items: center; gap: 0.5rem;
  margin-top: 0.35rem;
}
.history-emotion {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--color-primary);
  background: rgba(196, 139, 108, 0.1);
  padding: 0.1rem 0.5rem;
  border-radius: var(--radius-sm);
}
.history-date {
  font-size: 0.72rem;
  color: var(--color-text-muted);
}
.history-text {
  font-family: var(--font-diary);
  font-size: 0.92rem;
  color: var(--color-text);
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  white-space: normal;
  line-height: 1.6;
}
.btn-delete {
  background: none; border: none;
  color: var(--color-text-muted);
  font-size: 1.2rem;
  cursor: pointer;
  opacity: 0;
  transition: opacity 200ms;
  padding: 8px 12px;
  min-width: 44px; min-height: 44px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.history-item:hover .btn-delete { opacity: 1; }
.btn-delete:hover { color: #c0392b; }
.btn-delete:focus-visible { opacity: 1; outline: 2px solid var(--color-primary); outline-offset: 2px; }
.btn-bookmark {
  background: none; border: none; cursor: pointer;
  font-size: 1.4rem; color: var(--color-text-muted);
  padding: 0.75rem; flex-shrink: 0; transition: color 200ms, transform 200ms;
  align-self: center;
  opacity: 0.7;
}
.history-item:hover .btn-bookmark { opacity: 1; }
.btn-bookmark.active { color: #e74c3c; opacity: 1; font-size: 1.5rem; }
.btn-bookmark:hover { transform: scale(1.15); opacity: 1; }
@media (hover: none) { .btn-delete { opacity: 0.6; } }
.history-item.deleting {
  animation: slideOut 300ms ease forwards;
}
@keyframes slideOut {
  to { transform: translateX(100%); opacity: 0; max-height: 0; margin: 0; padding: 0; overflow: hidden; }
}
.history-item:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; }

/* 더 보기 버튼 */
.history-load-more {
  list-style: none;
  text-align: center;
  padding: 0.75rem 0;
}
.btn-load-more {
  display: inline-block;
  padding: 0.6rem 1.5rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-primary);
  font-family: var(--font-ui);
  font-size: clamp(0.8rem, 0.75rem + 0.25vw, 0.9rem);
  cursor: pointer;
  transition: background 200ms ease, box-shadow 200ms ease;
}
.btn-load-more:hover {
  background: var(--color-bg);
  box-shadow: var(--shadow-sm);
}
.btn-load-more:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

.empty-state {
  text-align: center;
  color: var(--color-text-muted);
  font-size: clamp(0.85rem, 0.8rem + 0.25vw, 0.9rem);
  padding: 3rem 1rem;
  background: var(--color-surface);
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-lg);
}

/* History Search & Filter */
.history-filter {
  margin-bottom: 1rem;
}
.search-input {
  width: 100%;
  font-family: var(--font-body);
  font-size: 0.88rem;
  padding: 0.7rem 1rem 0.7rem 2.5rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  outline: none;
  background: var(--color-surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23B8A99A' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E") no-repeat 0.85rem center;
  color: var(--color-text);
  transition: border-color 200ms ease, box-shadow 200ms ease;
}
.search-input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(196, 139, 108, 0.1);
}
.search-input::placeholder {
  color: var(--color-text-muted);
}
/* Prompt chips (diary input) */
.prompt-chips {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding: 0.5rem 0;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.prompt-chips::-webkit-scrollbar { display: none; }
.prompt-chip {
  flex-shrink: 0;
  padding: 0.375rem 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  background: var(--color-surface);
  color: var(--color-text-light);
  font-size: 0.8rem;
  font-family: var(--font-ui);
  cursor: pointer;
  transition: background-color 0.2s, color 0.2s, border-color 0.2s;
  white-space: nowrap;
}
.prompt-chip:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
}
.prompt-chip.active {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
}
.prompt-chip--more {
  font-size: 1rem;
  font-weight: 700;
  min-width: 2rem;
  text-align: center;
  padding: 0.375rem 0.5rem;
}

/* ===== Prompt Library Modal ===== */
.prompt-library-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  z-index: 1100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fadeIn 200ms ease;
}
.prompt-library-overlay[hidden] { display: none; }
.prompt-library {
  background: var(--color-surface);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  width: 100%;
  max-width: 480px;
  max-height: 70vh;
  display: flex;
  flex-direction: column;
  animation: slideUp 250ms cubic-bezier(0.25,0.46,0.45,0.94);
}
@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}
.prompt-library-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem 0.5rem;
}
.prompt-library-title {
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-text);
  margin: 0;
}
.prompt-library-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--color-text-muted);
  cursor: pointer;
  padding: 0.25rem;
  line-height: 1;
}
.prompt-library-tabs {
  display: flex;
  gap: 0.25rem;
  padding: 0.5rem 1.25rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.prompt-lib-tab {
  flex-shrink: 0;
  background: none;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: 0.3rem 0.7rem;
  font-family: var(--font-body);
  font-size: 0.8rem;
  color: var(--color-text-light);
  cursor: pointer;
  transition: border-color 150ms ease, color 150ms ease;
}
.prompt-lib-tab:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
}
.prompt-lib-tab.active {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
}
.prompt-library-list {
  list-style: none;
  margin: 0;
  padding: 0.5rem 1.25rem 1.25rem;
  overflow-y: auto;
  flex: 1;
}
.prompt-library-item {
  padding: 0.75rem 0.85rem;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background 150ms ease;
  margin-bottom: 0.35rem;
}
.prompt-library-item:hover {
  background: var(--color-background);
}
.prompt-library-item-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 0.2rem;
}
.prompt-library-item-text {
  display: block;
  font-size: 0.8rem;
  color: var(--color-text-light);
  line-height: 1.4;
}

.filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.6rem;
}
.filter-chips:empty { margin-top: 0; }
.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: 0.5rem 0.85rem;
  font-family: var(--font-body);
  font-size: 0.75rem;
  color: var(--color-text-light);
  cursor: pointer;
  transition: all 150ms ease;
  user-select: none;
  min-height: 36px;
}
.filter-chip:hover {
  border-color: var(--color-primary);
}
.filter-chip[aria-pressed="true"] {
  background: rgba(194, 113, 79, 0.15);
  border-color: var(--color-primary);
  color: var(--color-text);
  font-weight: 500;
}
.filter-chip:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 1px;
}
.filter-result-count {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  margin-top: 0.5rem;
}
.filter-result-count[hidden] { display: none; }

/* Legal modal */
.legal-modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
  animation: fadeIn 200ms ease;
}
.legal-modal-overlay[hidden] { display: none; }
.legal-modal {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  max-width: 600px; width: 100%;
  max-height: 80vh;
  display: flex; flex-direction: column;
  animation: scaleIn 300ms cubic-bezier(0.25,0.46,0.45,0.94) both;
}
.legal-modal-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--color-divider);
}
.legal-modal-title {
  font-family: var(--font-body);
  font-size: 1rem; font-weight: 600;
  color: var(--color-text);
}
.legal-modal-close {
  background: none; border: none; cursor: pointer;
  color: var(--color-text-muted); font-size: 1.3rem;
  padding: 4px 8px; border-radius: var(--radius-sm);
}
.legal-modal-close:hover { color: var(--color-text); background: var(--color-surface-warm); }
.legal-modal-body {
  padding: 1.25rem;
  overflow-y: auto;
  font-size: 0.85rem;
  line-height: 1.8;
  color: var(--color-text);
}
.legal-modal-body h3 {
  font-size: 0.9rem; font-weight: 600;
  margin: 1.2rem 0 0.4rem; color: var(--color-text);
}
.legal-modal-body h3:first-child { margin-top: 0; }
.legal-modal-body p { margin-bottom: 0.6rem; }
.legal-modal-body ul { margin: 0.3rem 0 0.6rem 1.2rem; }
.legal-modal-body li { margin-bottom: 0.2rem; }

/* Calendar */
.calendar-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 1rem;
}
.calendar-month-title {
  font-family: var(--font-diary); font-size: 1.1rem; font-weight: 700;
  color: var(--color-text);
}
.btn-cal-nav {
  background: var(--color-surface); border: 1px solid var(--color-border); cursor: pointer;
  color: var(--color-text-light); width: 36px; height: 36px;
  border-radius: 50%; font-size: 1rem;
  display: flex; align-items: center; justify-content: center;
  transition: border-color 200ms ease, color 200ms ease, background 200ms ease;
}
.btn-cal-nav:hover { border-color: var(--color-primary); color: var(--color-primary); }
.calendar-grid {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px;
}
.cal-weekday {
  text-align: center; font-size: 0.7rem; font-weight: 500;
  color: var(--color-text-muted); padding: 4px 0;
}
.cal-day {
  aspect-ratio: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 2px;
  border-radius: var(--radius-sm); cursor: default;
  font-size: 0.8rem; color: var(--color-text-light);
  position: relative; transition: all 150ms ease;
}
.cal-day.empty { visibility: hidden; }
.cal-day.has-entry {
  cursor: pointer; color: var(--color-text); font-weight: 500;
  transition: background-color 300ms ease;
}
.cal-day.has-entry:hover { background: var(--color-primary); color: #fff; }
.cal-day.has-entry:hover .cal-emoji { filter: brightness(1.2); }
.cal-day.selected { background: var(--color-primary); color: #fff; }
.cal-emoji {
  font-size: 0.65rem; line-height: 1;
}
.cal-dot {
  width: 6px; height: 6px; border-radius: 50%; display: inline-block; margin: 0 1px;
}
.cal-dots { display: flex; justify-content: center; gap: 2px; margin-top: 2px; }
.cal-day-entries {
  margin-top: 1rem; animation: fadeInUp 300ms ease both;
}
.cal-day-entries-header {
  font-family: var(--font-diary); font-size: 0.95rem; font-weight: 600;
  color: var(--color-text); margin-bottom: 0.75rem;
  padding-bottom: 0.5rem; border-bottom: 1px solid var(--color-divider);
}
.cal-entry-card {
  background: var(--gradient-response);
  border-radius: var(--radius-md); padding: 1rem;
  margin-bottom: 0.5rem;
}
.cal-entry-text {
  font-family: var(--font-diary); font-size: 0.9rem;
  color: var(--color-text); margin-bottom: 0.5rem; line-height: 1.6;
}
.cal-entry-meta {
  display: flex; gap: 0.5rem; align-items: center;
  font-size: 0.75rem; color: var(--color-text-light);
}
.cal-entry-emotion { font-weight: 500; }
.cal-entry-message {
  font-size: 0.8rem; color: var(--color-text-light);
  margin-top: 0.4rem; font-style: italic;
}

/* Calendar: "today" button */
.btn-cal-today {
  background: none; border: 1px solid var(--color-primary);
  color: var(--color-primary); cursor: pointer;
  font-size: 0.75rem; font-weight: 600;
  padding: 8px 16px; border-radius: var(--radius-sm);
  font-family: var(--font-ui);
  transition: all 200ms ease;
  min-height: 36px;
}
.btn-cal-today:hover { background: var(--color-primary); color: #fff; }
.btn-cal-today:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; }
.calendar-header-center {
  display: flex; align-items: center; gap: 0.5rem;
}

/* Calendar: clickable all days */
.cal-day.clickable { cursor: pointer; }
.cal-day.clickable:hover { background: var(--color-surface-warm); }
.cal-day.selected .cal-dot { box-shadow: 0 0 0 1px #fff; }

/* Calendar: today emphasis (override base) */
.cal-day.today {
  border: 2px solid var(--color-primary);
  font-weight: 700; color: var(--color-primary);
}
.cal-day.today.has-entry { color: var(--color-text); }
.cal-day.today.selected { color: #fff; border-color: transparent; }

/* Calendar: no-entry message */
.cal-no-entry {
  text-align: center; padding: 1.5rem 1rem;
  color: var(--color-text-muted); font-size: 0.85rem;
  font-family: var(--font-diary);
}

/* Calendar: monthly summary */
.cal-monthly-summary {
  margin-top: 1.25rem; padding: 1rem;
  background: var(--gradient-response);
  border-radius: var(--radius-md);
  animation: fadeInUp 300ms ease both;
}
.cal-summary-title {
  font-family: var(--font-diary); font-size: 0.85rem;
  font-weight: 600; color: var(--color-text);
  margin-bottom: 0.75rem;
}
.cal-summary-stats {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 0.75rem; padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--color-divider);
}
.cal-stat-item { text-align: center; flex: 1; }
.cal-stat-value {
  font-size: 1.3rem; font-weight: 700;
  color: var(--color-primary); line-height: 1.2;
}
.cal-stat-label {
  font-size: 0.7rem; color: var(--color-text-muted); margin-top: 2px;
}
.cal-stat-divider {
  width: 1px; height: 28px; background: var(--color-divider);
}
.cal-top-emotions {
  display: flex; gap: 0.5rem; flex-wrap: wrap;
}
.cal-top-emotion-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px; border-radius: 20px;
  font-size: 0.75rem; font-weight: 500;
  background: var(--color-surface-warm);
  color: var(--color-text);
  border: 1px solid var(--color-border);
}
.cal-top-emotion-dot {
  width: 8px; height: 8px; border-radius: 50%; display: inline-block;
}
.cal-top-emotion-count {
  color: var(--color-text-muted); font-size: 0.7rem;
}
.cal-summary-empty {
  font-size: 0.8rem; color: var(--color-text-muted);
  text-align: center; padding: 0.5rem 0;
}

/* Skeleton loading */
.skeleton {
  background: linear-gradient(90deg, #e0d5c8 25%, #ebe3d9 37%, #e0d5c8 63%);
  background-size: 400% 100%;
  animation: skeletonPulse 1.6s ease infinite;
  border-radius: var(--radius-sm);
}
[data-theme="dark"] .situation-tag {
  color: #6ec0d8;
}
[data-theme="dark"] .skeleton {
  background: linear-gradient(90deg, #292524 25%, #3a3533 37%, #292524 63%);
  background-size: 400% 100%;
}
@keyframes skeletonPulse {
  0% { background-position: 100% 50%; }
  100% { background-position: 0 50%; }
}
.skeleton-line { height: 1em; margin-bottom: 0.5rem; }
.skeleton-line:last-child { width: 60%; }
.skeleton-card { height: 60px; margin-bottom: 0.5rem; border-radius: var(--radius-md); }
.skeleton-summary { height: 70px; border-radius: var(--radius-md); }

/* Analyze skeleton: mimics the response-card layout */
.skeleton-analyze {
  background: var(--gradient-response);
  border-radius: var(--radius-xl);
  padding: 1.5rem;
  box-shadow: var(--shadow-md);
}
.skeleton-analyze .skeleton-emoji {
  width: 56px; height: 56px;
  border-radius: 50%;
  margin-bottom: 0.75rem;
}
.skeleton-analyze .skeleton-title {
  height: 1.1em; width: 40%;
  margin-bottom: 0.75rem;
}
.skeleton-analyze .skeleton-text {
  height: 0.9em;
  margin-bottom: 0.5rem;
}
.skeleton-analyze .skeleton-text:nth-child(4) { width: 90%; }
.skeleton-analyze .skeleton-text:nth-child(5) { width: 75%; }
.skeleton-analyze .skeleton-text:nth-child(6) { width: 60%; }
.skeleton-analyze .skeleton-ontology {
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--color-divider);
}
.skeleton-analyze .skeleton-chip {
  display: inline-block;
  width: 60px; height: 24px;
  border-radius: 999px;
  margin-right: 0.4rem;
  margin-bottom: 0.4rem;
}

/* Entry skeleton: mimics history-item layout */
.skeleton-entry {
  background: var(--color-surface-warm);
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.skeleton-entry .skeleton-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  flex-shrink: 0;
}
.skeleton-entry .skeleton-body {
  flex: 1; min-width: 0;
}
.skeleton-entry .skeleton-body-line {
  height: 0.85em;
  margin-bottom: 0.4rem;
}
.skeleton-entry .skeleton-body-line:first-child { width: 80%; }
.skeleton-entry .skeleton-body-line:last-child { width: 45%; margin-bottom: 0; }

/* Stats skeleton: mimics summary cards + bar chart */
.skeleton-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}
.skeleton-stats-card {
  background: var(--color-surface);
  border-radius: var(--radius-md);
  padding: 1rem;
  box-shadow: var(--shadow-sm);
  display: flex; flex-direction: column;
  align-items: center; gap: 0.5rem;
}
.skeleton-stats-card .skeleton-value {
  width: 50px; height: 1.5em;
  border-radius: var(--radius-sm);
}
.skeleton-stats-card .skeleton-label {
  width: 70px; height: 0.8em;
  border-radius: var(--radius-sm);
}
.skeleton-bar-group {
  display: flex; flex-direction: column; gap: 0.5rem;
}
.skeleton-bar-row {
  display: flex; align-items: center; gap: 0.5rem;
}
.skeleton-bar-label {
  width: 50px; height: 0.85em;
  flex-shrink: 0;
}
.skeleton-bar-track {
  flex: 1; height: 20px;
  border-radius: var(--radius-sm);
}
.skeleton-bar-row:nth-child(2) .skeleton-bar-track { width: 75%; }
.skeleton-bar-row:nth-child(3) .skeleton-bar-track { width: 55%; }
.skeleton-bar-row:nth-child(4) .skeleton-bar-track { width: 35%; }

/* Stats period filter */
.period-filter {
  display: flex; gap: 4px; margin-bottom: 1.25rem;
  background: var(--color-surface-warm); border-radius: var(--radius-md); padding: 3px;
}
.period-chip {
  font-family: var(--font-body); font-size: 0.78rem;
  padding: 0.4rem 1rem; border-radius: var(--radius-sm);
  border: none;
  background: transparent; color: var(--color-text-muted);
  cursor: pointer; transition: color 200ms ease, background 200ms ease, box-shadow 200ms ease;
  font-weight: 500;
}
.period-chip:hover { color: var(--color-text-light); }
.period-chip.active {
  background: var(--color-surface); color: var(--color-text);
  box-shadow: var(--shadow-sm);
}

/* Keyboard shortcut hint */
.shortcut-hint {
  font-size: 0.65rem; color: var(--color-text-muted);
  margin-top: 0.3rem; text-align: right;
}
@media (hover: none), (pointer: coarse) {
  .shortcut-hint { display: none; }
}
kbd {
  display: inline-block; padding: 1px 5px;
  font-family: var(--font-body); font-size: 0.6rem;
  background: var(--color-surface-warm); border: 1px solid var(--color-border);
  border-radius: 3px; color: var(--color-text-light);
}

/* Edit entry */
.btn-edit-detail {
  background: none; border: 1px solid var(--color-border); cursor: pointer;
  color: var(--color-text-light); font-size: 0.75rem; padding: 4px 10px;
  border-radius: var(--radius-sm); font-family: var(--font-body);
  transition: all 200ms ease;
}
.btn-edit-detail:hover { background: var(--color-surface-warm); color: var(--color-text); }
.edit-textarea {
  width: 100%; min-height: 80px; padding: 0.6rem;
  border: 1px solid var(--color-primary); border-radius: var(--radius-sm);
  font-family: var(--font-diary); font-size: 0.9rem; line-height: 1.6;
  color: var(--color-text); background: var(--color-surface);
  resize: vertical; outline: none;
}
.edit-actions { display: flex; gap: 0.5rem; margin-top: 0.5rem; }
.btn-edit-save {
  background: var(--color-primary); color: #fff; border: none;
  padding: 6px 14px; border-radius: var(--radius-sm); font-family: var(--font-body);
  font-size: 0.8rem; cursor: pointer;
}
.btn-edit-save:hover { background: var(--color-primary-hover); }
.btn-edit-save:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-edit-cancel {
  background: none; color: var(--color-text-light); border: 1px solid var(--color-border);
  padding: 6px 14px; border-radius: var(--radius-sm); font-family: var(--font-body);
  font-size: 0.8rem; cursor: pointer;
}
.btn-edit-cancel:hover { background: var(--color-surface-warm); }
.edit-char-count { font-size: 0.7rem; color: var(--color-text-muted); margin-top: 0.3rem; }

/* Keyboard shortcut help button & modal */
.shortcut-help-btn {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 900;
  width: 44px;
  height: 44px;
  border: 1px solid var(--color-border);
  border-radius: 50%;
  background: var(--color-surface);
  box-shadow: var(--shadow-md);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  color: var(--color-text-light);
  transition: background 200ms, box-shadow 200ms, transform 200ms;
}
.shortcut-help-btn:hover {
  background: var(--color-surface-warm);
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}
.shortcut-help-btn:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}
@media (hover: none), (pointer: coarse) {
  .shortcut-help-btn { display: none; }
}

.shortcut-modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
  animation: fadeIn 200ms ease;
}
.shortcut-modal-overlay[hidden] { display: none; }
.shortcut-modal {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  max-width: 420px; width: 100%;
  animation: scaleIn 300ms cubic-bezier(0.25,0.46,0.45,0.94) both;
}
.shortcut-modal-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--color-divider);
}
.shortcut-modal-title {
  font-family: var(--font-body);
  font-size: 1rem; font-weight: 600;
  color: var(--color-text);
}
.shortcut-modal-close {
  background: none; border: none; cursor: pointer;
  color: var(--color-text-muted); font-size: 1.3rem;
  padding: 4px 8px; border-radius: var(--radius-sm);
}
.shortcut-modal-close:hover { color: var(--color-text); background: var(--color-surface-warm); }
.shortcut-modal-body {
  padding: 1rem 1.25rem;
}
.shortcut-list {
  list-style: none;
  display: flex; flex-direction: column;
  gap: 0.6rem;
}
.shortcut-list li {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 0.85rem;
  color: var(--color-text);
}
.shortcut-list .shortcut-keys {
  display: flex; gap: 4px; align-items: center;
  flex-shrink: 0;
  margin-left: 1rem;
}
.shortcut-list kbd {
  font-size: 0.7rem;
  padding: 2px 7px;
}
.shortcut-list .shortcut-sep {
  font-size: 0.65rem;
  color: var(--color-text-muted);
}
.shortcut-modal-footer {
  padding: 0.75rem 1.25rem;
  border-top: 1px solid var(--color-divider);
  font-size: 0.7rem;
  color: var(--color-text-muted);
  text-align: center;
}

/* Dark mode — Stone warm dark */
[data-theme="dark"] {
  --color-bg: #141211;
  --color-surface: #1C1917;
  --color-surface-warm: #292524;
  --color-primary: #FB923C;
  --color-primary-hover: #F97316;
  --color-secondary: #FDBA74;
  --color-text: #FAFAF9;
  --color-text-light: #A8A29E;
  --color-text-muted: #57534E;
  --color-border: #292524;
  --color-divider: #1C1917;
  --color-error: #EF4444;
  --color-error-bg: #2E1A1A;
  --color-success: #22C55E;
  --color-success-bg: #1A2E1E;
  --gradient-response: linear-gradient(160deg, #1C1917 0%, #292524 100%);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.5);
  --shadow-glow: 0 0 20px rgba(251,146,60,0.12);
}
[data-theme="dark"] .history-item { background: var(--color-surface); border-color: var(--color-border); }
[data-theme="dark"] .history-item:hover { border-color: var(--color-divider); }
[data-theme="dark"] .history-emotion { background: rgba(251, 146, 60, 0.12); color: var(--color-primary); }
[data-theme="dark"] .btn-detail-delete:hover { background: var(--color-error-bg); }
[data-theme="dark"] .summary-card { border-color: var(--color-border); }
[data-theme="dark"] .summary-card:hover { border-color: rgba(251, 146, 60, 0.3); }
[data-theme="dark"] .dashboard-section { border-color: var(--color-border); }
[data-theme="dark"] .trend-chart { border-color: var(--color-border); }
[data-theme="dark"] .search-input:focus { box-shadow: 0 0 0 3px rgba(251, 146, 60, 0.1); }
[data-theme="dark"] .diary-input:focus-within { box-shadow: 0 0 0 3px rgba(251, 146, 60, 0.1); }
[data-theme="dark"] .empty-state { background: var(--color-surface); border-color: var(--color-border); }
[data-theme="dark"] .btn-load-more { background: var(--color-surface); border-color: var(--color-border); }
[data-theme="dark"] .btn-load-more:hover { border-color: var(--color-primary); background: var(--color-surface-warm); }

/* History detail modal */
.history-detail-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
  padding: 1rem;
  animation: overlayFadeIn 200ms ease;
}
@keyframes overlayFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
.history-detail-overlay[hidden] { display: none; }
.history-detail-content {
  background: var(--color-surface);
  border-radius: var(--radius-xl);
  padding: 2rem;
  box-shadow: var(--shadow-lg);
  max-width: 520px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  position: relative;
  animation: modalSlideIn 300ms cubic-bezier(0.25,0.46,0.45,0.94) both;
}
@keyframes modalSlideIn {
  from { opacity: 0; transform: translateY(24px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.history-detail-close {
  position: absolute; top: 1rem; right: 1rem;
  background: var(--color-surface-warm); border: none; cursor: pointer;
  color: var(--color-text-muted); font-size: 1.25rem;
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  transition: background 200ms, color 200ms;
  line-height: 1;
}
.history-detail-close:hover { background: var(--color-border); color: var(--color-text); }
.history-detail-date {
  font-size: 0.8rem; color: var(--color-text-muted);
  margin-bottom: 1rem;
  letter-spacing: 0.01em;
}
.history-detail-emotion {
  display: flex; align-items: center; gap: 0.75rem;
  margin-bottom: 1.5rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--color-divider);
}
.history-detail-emoji { font-size: 2.5rem; }
.history-detail-emotion-text {
  font-size: 1.2rem; font-weight: 600;
  color: var(--color-text);
}
.history-detail-section {
  margin-bottom: 1.25rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--color-divider);
}
.history-detail-section:last-of-type { border-bottom: none; padding-bottom: 0; }
.history-detail-section h4 {
  font-size: 0.72rem; color: var(--color-text-muted);
  margin-bottom: 0.5rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.05em;
}
.history-detail-text {
  font-family: var(--font-diary);
  font-size: 1.05rem; color: var(--color-text);
  line-height: 1.8;
}
.history-detail-message,
.history-detail-advice {
  font-size: 0.92rem; color: var(--color-text-light);
  line-height: 1.7;
}
.btn-detail-delete {
  display: block; width: 100%;
  margin-top: 1.25rem; padding: 0.65rem;
  background: none; border: 1px solid var(--color-border);
  color: var(--color-text-muted);
  border-radius: var(--radius-md);
  cursor: pointer; font-size: 0.82rem;
  font-family: var(--font-body);
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}
.btn-detail-delete:hover {
  background: var(--color-error-bg);
  border-color: var(--color-error);
  color: var(--color-error);
}

/* Settings */
.settings-panel {
  margin-top: 2rem;
  border-top: 1px solid var(--color-divider);
  padding-top: 1rem;
}
.settings-panel summary {
  display: flex; align-items: center; gap: 0.5rem;
  color: var(--color-text-light);
  font-size: 0.85rem;
  cursor: pointer;
  list-style: none;
  user-select: none;
}
.settings-panel summary::-webkit-details-marker { display: none; }
.settings-panel summary svg { width: 16px; height: 16px; }
.settings-content {
  padding-top: 1rem;
  overflow: hidden;
}
.form-group {
  display: flex; gap: 0.5rem; align-items: center;
  margin-bottom: 0.5rem;
}
.form-group label {
  font-size: 0.85rem; color: var(--color-text-light); white-space: nowrap;
}
.form-group input {
  flex: 1;
  font-family: var(--font-body);
  font-size: 0.85rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  outline: none;
  background: var(--color-surface);
  color: var(--color-text);
}
.form-group input:focus { border-color: var(--color-primary); }
.btn-save-key {
  background: var(--color-secondary);
  color: #fff;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 0.8rem;
  cursor: pointer;
  transition: background 200ms;
}
.btn-save-key:hover { background: var(--color-primary-hover); }
.settings-hint {
  font-size: clamp(0.7rem, 0.65rem + 0.25vw, 0.75rem);
  color: var(--color-text-muted);
}
.settings-status {
  font-size: 0.8rem;
  margin-top: 0.5rem;
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius-sm);
}
.settings-status.success { background: #e8f5e9; color: #2e7d32; }
.settings-status.error { background: #fce4ec; color: #c62828; }
.settings-status[hidden] { display: none; }


/* Dashboard */
.dashboard {
  animation: fadeInUp 400ms cubic-bezier(0.25,0.46,0.45,0.94) both;
}
.dashboard-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}
.summary-card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1rem;
  text-align: center;
  border: 1px solid var(--color-border);
  transition: border-color 200ms ease;
}
.summary-card:hover {
  border-color: var(--color-primary);
}
.summary-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--color-primary);
  display: block;
}
.summary-label {
  font-size: 0.73rem;
  color: var(--color-text-muted);
  margin-top: 0.3rem;
}
.dashboard-section {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-bottom: 1rem;
  border: 1px solid var(--color-border);
}
.dashboard-section-title {
  font-size: 0.88rem;
  color: var(--color-text);
  margin-bottom: 1rem;
  font-weight: 600;
}
/* AI 리포트 버튼 및 카드 */
.report-btn-group {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.btn-report {
  flex: 1;
  padding: 0.65rem 1rem;
  border: 1px solid var(--color-primary);
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--color-primary);
  font-size: 0.85rem;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, transform 0.1s;
}
.btn-report:hover { background: var(--color-primary); color: #fff; }
.btn-report:active { transform: scale(0.97); }
.btn-report:disabled { opacity: 0.5; cursor: not-allowed; }
.report-card {
  background: var(--gradient-response);
  border-radius: 16px;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.report-card-section {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}
.report-card-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--color-text-light);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.report-card-text {
  font-size: 0.9rem;
  color: var(--color-text);
  line-height: 1.6;
}
/* CSS Bar chart */
.bar-chart {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.bar-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.bar-label {
  min-width: 5em;
  font-size: 0.8rem;
  color: var(--color-text);
  text-align: right;
  flex-shrink: 0;
}
.bar-track {
  flex: 1;
  height: 22px;
  background: var(--color-surface-warm);
  border-radius: 6px;
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  background: var(--color-primary);
  border-radius: 6px;
  transition: width 600ms cubic-bezier(0.25,0.46,0.45,0.94);
  min-width: 2px;
}
.bar-fill[data-emotion="기쁨"], .bar-fill[data-emotion="감사"], .bar-fill[data-emotion="설렘"] { background: #F4A261; }
.bar-fill[data-emotion="슬픔"], .bar-fill[data-emotion="외로움"], .bar-fill[data-emotion="그리움"] { background: #7EB8DA; }
.bar-fill[data-emotion="분노"], .bar-fill[data-emotion="짜증"], .bar-fill[data-emotion="억울함"] { background: #E76F51; }
.bar-fill[data-emotion="불안"], .bar-fill[data-emotion="걱정"], .bar-fill[data-emotion="두려움"] { background: #9C89B8; }
.bar-fill[data-emotion="평온"], .bar-fill[data-emotion="편안함"], .bar-fill[data-emotion="안도"] { background: #A8DAAB; }
.bar-fill[data-emotion="사랑"], .bar-fill[data-emotion="애정"] { background: #F2A0A0; }
.bar-fill[data-emotion="피곤"], .bar-fill[data-emotion="지침"], .bar-fill[data-emotion="무기력"] { background: #B0A89A; }
.bar-count {
  min-width: 2em;
  font-size: 0.75rem;
  color: var(--color-text-muted);
  text-align: left;
}
/* Situation bar alternate color */
.bar-fill.situation {
  background: rgba(85, 160, 180, 0.6);
}
/* Recent entries in dashboard */
.recent-entry {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--color-divider);
}
.recent-entry:last-child { border-bottom: none; }
.recent-emoji { font-size: 1.2rem; flex-shrink: 0; }
.recent-info { flex: 1; min-width: 0; }
.recent-text {
  font-family: var(--font-diary);
  font-size: 0.85rem;
  color: var(--color-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.recent-meta {
  font-size: 0.7rem;
  color: var(--color-text-muted);
}
.dashboard-empty {
  text-align: center;
  color: var(--color-text-muted);
  padding: 2rem 0;
  font-size: 0.9rem;
}
.dashboard-progress-nudge {
  margin-top: 0.75rem;
  padding: 0.75rem 1rem;
  background: var(--color-surface-warm, var(--color-surface));
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
}
.dashboard-progress-text {
  font-size: 0.82rem;
  color: var(--color-text-secondary);
  margin-bottom: 0.5rem;
  text-align: center;
}
.dashboard-progress-bar {
  height: 6px;
  background: var(--color-border);
  border-radius: 99px;
  overflow: hidden;
}
.dashboard-progress-fill {
  height: 100%;
  background: var(--color-primary);
  border-radius: 99px;
  transition: width 0.4s ease;
}
/* Trend Chart */
.trend-chart {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-bottom: 1rem;
  border: 1px solid var(--color-border);
}
.trend-chart-title {
  font-size: 0.88rem;
  color: var(--color-text);
  margin-bottom: 1rem;
  font-weight: 600;
}
.trend-chart svg {
  width: 100%;
  height: auto;
  display: block;
  overflow: visible;
}
.trend-chart-empty {
  text-align: center;
  color: var(--color-text-muted);
  font-size: 0.85rem;
  padding: 1.5rem 0;
}
.trend-chart-legend {
  text-align: center;
  color: var(--color-text-muted);
  font-size: 0.75rem;
  margin-top: 0.5rem;
  line-height: 1.5;
}
.trend-chart-legend strong {
  color: var(--color-text-light);
  font-weight: 600;
}
.trend-tooltip {
  position: fixed;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 0.35rem 0.65rem;
  font-size: 0.75rem;
  color: var(--color-text);
  box-shadow: var(--shadow-md);
  pointer-events: none;
  white-space: nowrap;
  z-index: 9999;
  display: none;
}

/* Emotion Flower Chart */
#emotionFlowerChart {
  text-align: center;
  padding: 0.5rem 0;
}
#emotionFlowerChart svg {
  max-width: 320px;
  width: 100%;
  height: auto;
  overflow: visible;
}
.flower-subtitle {
  font-size: 0.78rem;
  color: var(--color-text-muted);
  text-align: center;
  margin-bottom: 0.5rem;
  margin-top: -0.25rem;
}
.flower-petal {
  transition: opacity 0.2s;
  cursor: pointer;
}
.flower-petal:hover { opacity: 0.75; }
.flower-petal-label {
  font-family: var(--font-ui, sans-serif);
  fill: var(--color-text);
}
.flower-tooltip {
  position: fixed;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 0.35rem 0.65rem;
  font-size: 0.75rem;
  color: var(--color-text);
  box-shadow: var(--shadow-md);
  pointer-events: none;
  white-space: nowrap;
  z-index: 9999;
  display: none;
}
.flower-center-label {
  font-family: var(--font-ui, sans-serif);
  fill: var(--color-text);
}
.flower-empty {
  text-align: center;
  color: var(--color-text-muted);
  font-size: 0.85rem;
  padding: 1.5rem 0;
}
.flower-legend {
  margin-top: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0 0.25rem;
}
.flower-legend-item {
  display: grid;
  grid-template-columns: 10px 3.5rem 1fr 2.2rem 2.4rem;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.78rem;
}
.flower-legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}
.flower-legend-name {
  color: var(--color-text-light);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.flower-legend-bar {
  height: 5px;
  background: var(--color-border);
  border-radius: 3px;
  overflow: hidden;
}
.flower-legend-fill {
  display: block;
  height: 100%;
  border-radius: 3px;
  transition: width 0.6s ease;
}
.flower-legend-count {
  color: var(--color-text-muted);
  text-align: right;
  font-size: 0.73rem;
}
.flower-legend-pct {
  color: var(--color-text);
  font-weight: 600;
  text-align: right;
  font-size: 0.73rem;
}
.flower-legend-item:first-child .flower-legend-name {
  color: var(--color-text);
  font-weight: 600;
}
.flower-legend-hidden {
  font-size: 0.73rem;
  color: var(--color-text-muted);
  text-align: right;
  margin-top: 0.2rem;
  display: block;
}
.flower-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  padding: 1.5rem 0 0.5rem;
}
.flower-empty-state svg {
  opacity: 0.18;
  width: 120px;
  height: 120px;
}
.flower-empty-state p {
  font-size: 0.83rem;
  color: var(--color-text-muted);
  text-align: center;
  line-height: 1.5;
}

/* Emotion × Situation Heatmap */
#emotionSituationHeatmap { overflow-x: auto; }
#emotionSituationHeatmap svg { min-width: 300px; display: block; max-width: 100%; }
.heatmap-cell { transition: opacity 0.2s; cursor: pointer; }
.heatmap-cell:hover { stroke: var(--color-text); stroke-width: 2; }
.heatmap-tooltip {
  position: fixed;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 0.35rem 0.65rem;
  font-size: 0.75rem;
  color: var(--color-text);
  box-shadow: var(--shadow-md);
  pointer-events: none;
  white-space: nowrap;
  z-index: 9999;
  display: none;
}
.heatmap-empty {
  text-align: center;
  color: var(--color-text-muted);
  font-size: 0.85rem;
  padding: 1.5rem 0;
}

/* ===== Crisis Safety Modal ===== */
.crisis-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  animation: fadeIn 200ms ease;
}
.crisis-modal-overlay[hidden] { display: none; }
.crisis-modal {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  max-width: 420px;
  width: 100%;
  padding: 2rem 1.5rem;
  text-align: center;
  animation: fadeInUp 300ms ease;
}
.crisis-modal-icon {
  font-size: 2.5rem;
  margin-bottom: 0.75rem;
}
.crisis-modal-title {
  font-family: var(--font-body);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--color-text);
  margin: 0 0 0.5rem;
}
.crisis-modal-text {
  font-size: 0.9rem;
  color: var(--color-text-light);
  line-height: 1.6;
  margin: 0 0 1.25rem;
}
.crisis-contacts {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.crisis-contact-btn {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  text-decoration: none;
  color: var(--color-text);
  transition: background 150ms ease, border-color 150ms ease;
}
.crisis-contact-btn:hover {
  background: var(--color-background);
  border-color: var(--color-primary);
}
.crisis-contact-btn--primary {
  border-color: #e74c3c;
  background: #fef0ef;
}
[data-theme="dark"] .crisis-contact-btn--primary {
  background: rgba(231,76,60,0.1);
}
.crisis-contact-icon {
  font-size: 1.25rem;
  flex-shrink: 0;
}
.crisis-contact-info {
  display: flex;
  flex-direction: column;
  text-align: left;
}
.crisis-contact-info strong {
  font-size: 0.9rem;
  font-weight: 600;
}
.crisis-contact-info span {
  font-size: 0.75rem;
  color: var(--color-text-muted);
}
.crisis-modal-disclaimer {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  margin: 0 0 1rem;
}
.crisis-modal-close {
  display: inline-block;
  background: var(--color-primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  padding: 0.6rem 2rem;
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 150ms ease;
}
.crisis-modal-close:hover { opacity: 0.85; }

/* ===== Activity Tags ===== */
.activity-tags {
  margin-top: 0.5rem;
}
.activity-tags-label {
  display: block;
  font-size: 0.8rem;
  color: var(--color-text-muted);
  margin-bottom: 0.35rem;
}
.activity-tags-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}
.activity-tag {
  font-family: var(--font-body);
  font-size: 0.75rem;
  padding: 0.25rem 0.6rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  background: var(--color-surface);
  color: var(--color-text-light);
  cursor: pointer;
  transition: border-color 150ms ease, background 150ms ease, color 150ms ease;
}
.activity-tag:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
}
.activity-tag.active {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
}

/* ===== Emotion Growth Graph ===== */
.growth-empty {
  text-align: center;
  color: var(--color-text-muted);
  font-size: 0.85rem;
  padding: 1.5rem 0;
}
.growth-legend {
  display: flex;
  justify-content: center;
  gap: 1rem;
  margin-top: 0.5rem;
  font-size: 0.75rem;
  color: var(--color-text-muted);
}
.growth-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}
.growth-legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

/* ===== Activity Correlation Chart ===== */
.correlation-empty {
  text-align: center;
  color: var(--color-text-muted);
  font-size: 0.85rem;
  padding: 1.5rem 0;
}
.correlation-bars {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.correlation-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.correlation-label {
  font-size: 0.8rem;
  color: var(--color-text);
  min-width: 3rem;
  text-align: right;
  flex-shrink: 0;
}
.correlation-track {
  flex: 1;
  height: 20px;
  background: var(--color-background);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.correlation-fill {
  height: 100%;
  border-radius: var(--radius-sm);
  transition: width 400ms ease;
}
.correlation-fill--positive { background: var(--color-success); }
.correlation-fill--negative { background: var(--color-error); }
.correlation-fill--neutral { background: var(--color-primary); opacity: 0.6; }
.correlation-meta {
  font-size: 0.7rem;
  color: var(--color-text-muted);
  min-width: 5rem;
  flex-shrink: 0;
}

/* ===== AI Follow-up Conversation ===== */
.followup-section {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 1rem;
  margin-top: 0.75rem;
}
.followup-section[hidden] { display: none; }
.followup-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}
.followup-stage-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--color-primary);
}
.followup-stages {
  display: flex;
  gap: 0.35rem;
}
.followup-stage-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-border);
  transition: background 200ms ease;
}
.followup-stage-dot.active {
  background: var(--color-primary);
}
.followup-stage-dot.completed {
  background: var(--color-success);
}
.followup-messages {
  max-height: 280px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  padding-right: 0.25rem;
}
.followup-msg {
  padding: 0.6rem 0.85rem;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  line-height: 1.5;
  max-width: 85%;
  white-space: pre-line;
  animation: fadeInUp 250ms ease;
}
.followup-msg--ai {
  background: var(--color-background);
  color: var(--color-text);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}
.followup-msg--user {
  background: var(--color-primary);
  color: #fff;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}
.followup-msg--loading {
  padding: 0.6rem 1rem;
}
.followup-typing {
  display: inline-flex;
  gap: 3px;
}
.followup-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--color-text-muted);
  animation: typingBounce 1.2s infinite;
}
.followup-typing span:nth-child(2) { animation-delay: 0.2s; }
.followup-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-4px); }
}
.followup-input-row {
  display: flex;
  gap: 0.5rem;
}
.followup-input-row[hidden] { display: none; }
.followup-input {
  flex: 1;
  font-family: var(--font-body);
  font-size: 0.85rem;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-text);
  outline: none;
  transition: border-color 200ms ease;
}
.followup-input:focus {
  border-color: var(--color-primary);
}
.followup-send {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: var(--color-primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: opacity 150ms ease;
  flex-shrink: 0;
}
.followup-send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.followup-send:hover:not(:disabled) {
  opacity: 0.85;
}
.followup-done {
  text-align: center;
  font-size: 0.8rem;
  color: var(--color-text-muted);
  padding: 0.5rem 0;
  margin: 0;
}

/* ===== Year in Pixels ===== */
.year-pixels-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}
.year-pixels-year {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--color-text);
  min-width: 4rem;
  text-align: center;
}
.year-pixels-svg {
  width: 100%;
  max-width: 800px;
  display: block;
  margin: 0 auto;
}
.pixel-cell {
  cursor: pointer;
  transition: opacity 150ms ease;
}
.pixel-cell:hover {
  opacity: 1 !important;
  stroke: var(--color-text);
  stroke-width: 1;
}
.pixels-tooltip {
  display: none;
  position: fixed;
  background: var(--color-text);
  color: var(--color-surface);
  font-size: 0.75rem;
  padding: 0.3rem 0.6rem;
  border-radius: var(--radius-sm);
  pointer-events: none;
  white-space: nowrap;
  z-index: 100;
}
.pixels-empty {
  text-align: center;
  color: var(--color-text-muted);
  font-size: 0.85rem;
  padding: 1.5rem 0;
}
.pixels-legend {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  margin-top: 0.5rem;
  font-size: 0.75rem;
  color: var(--color-text-muted);
}
.pixels-legend-box {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 2px;
}

/* Footer */
.app-footer {
  text-align: center;
  margin-top: 3rem;
  padding-bottom: 2rem;
  font-size: clamp(0.75rem, 0.7rem + 0.25vw, 0.8rem);
  color: var(--color-text-muted);
}

/* Toast notification system */
.toast-container {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2000;
  display: flex;
  flex-direction: column-reverse;
  gap: 0.5rem;
  align-items: center;
  pointer-events: none;
  max-width: calc(100% - 32px);
  width: 400px;
}
.toast {
  pointer-events: auto;
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-family: var(--font-body);
  box-shadow: var(--shadow-lg);
  text-align: center;
  animation: toastSlideUp 300ms cubic-bezier(0.25,0.46,0.45,0.94) both;
  max-width: 100%;
}
.toast.toast-error {
  background: #c62828;
  color: #fff;
}
.toast.toast-success {
  background: #2e7d32;
  color: #fff;
}
.toast.toast-info {
  background: var(--color-surface);
  color: var(--color-text);
  border: 1px solid var(--color-border);
}
[data-theme="dark"] .toast.toast-info {
  background: var(--color-surface);
  color: var(--color-text);
  border-color: var(--color-border);
}
.toast.toast-dismissing {
  animation: toastSlideDown 300ms cubic-bezier(0.55,0.06,0.68,0.19) forwards;
}
@keyframes toastSlideUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes toastSlideDown {
  from { opacity: 1; transform: translateY(0); }
  to   { opacity: 0; transform: translateY(16px); }
}

/* Legacy error-toast (kept for backward compat) */
.error-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: #c62828;
  color: #fff;
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  box-shadow: var(--shadow-lg);
  z-index: 1000;
  transition: transform 300ms ease;
  max-width: calc(100% - 32px);
  text-align: center;
}
.error-toast.show { transform: translateX(-50%) translateY(0); }

/* Focus trap overlay for modals */
.focus-trap-active { overflow: hidden; }

/* Improved focus indicators */
:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* aria-busy loading state */
[aria-busy="true"] {
  cursor: wait;
}


/* === Feature 1: Calendar legend === */
.cal-legend { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.75rem; justify-content: center; }
.cal-legend-item { display: inline-flex; align-items: center; gap: 4px; font-size: 0.7rem; color: var(--color-text-muted); }
.cal-legend-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }

/* === Feature 2: Streak sparkle & badges === */
@keyframes sparkle {
  0%, 100% { box-shadow: var(--shadow-sm); }
  50% { box-shadow: 0 0 15px rgba(232,168,124,0.5), 0 0 30px rgba(232,168,124,0.3); }
}
.sparkle { animation: sparkle 0.75s ease 2; }
.profile-badges { margin-top: 1rem; }
.profile-badges-title {
  font-family: var(--font-diary); font-size: 0.9rem; font-weight: 600;
  color: var(--color-text); margin-bottom: 0.75rem;
}
.badges-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.5rem;
}
.badge-item {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 0.75rem 0.5rem; border-radius: var(--radius-md);
  background: var(--color-surface); border: 1px solid var(--color-border);
  opacity: 0.4; filter: grayscale(1); transition: all 300ms ease;
}
.badge-item.achieved { opacity: 1; filter: none; border-color: var(--color-primary); }
.badge-emoji { font-size: 1.5rem; }
.badge-name { font-size: 0.7rem; color: var(--color-text); font-weight: 500; text-align: center; }
.badge-days { font-size: 0.65rem; color: var(--color-text-muted); }

/* === Feature 3: Confetti animation === */
@keyframes confettiFall {
  0% { transform: translateY(0) rotate(0deg); opacity: 1; }
  100% { transform: translateY(120vh) rotate(720deg); opacity: 0; }
}
@keyframes gradientPulse {
  0% { background-size: 100% 100%; }
  50% { background-size: 150% 150%; }
  100% { background-size: 100% 100%; }
}
.confetti-container {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  pointer-events: none; z-index: 9999; overflow: hidden;
}
.confetti-piece {
  position: absolute; top: -10px;
  width: 10px; height: 10px; border-radius: 2px;
  animation: confettiFall 2s ease-out forwards;
}
/* Gentle floating particles for negative emotions */
@keyframes gentleFloat {
  0% {
    transform: translateY(0) scale(0.5);
    opacity: 0;
  }
  20% {
    opacity: 0.6;
    transform: translateY(-15vh) scale(1);
  }
  100% {
    transform: translateY(-60vh) scale(0.3);
    opacity: 0;
  }
}
.gentle-particle {
  position: absolute;
  border-radius: 50%;
  opacity: 0;
  animation: gentleFloat 3s ease-out forwards;
}
@media (prefers-reduced-motion: reduce) {
  .gentle-particle { animation: none; display: none; }
}

.response-card.pulse-bg {
  animation: gradientPulse 1s ease-in-out 1;
}

/* === Feature 4: Insight cards === */
.insight-card {
  padding: 0.75rem; margin-bottom: 0.5rem;
  background: var(--gradient-response);
  border-radius: var(--radius-md);
  animation: fadeInUp 300ms ease both;
}
.insight-card:last-child { margin-bottom: 0; }
.insight-icon { font-size: 1.2rem; margin-bottom: 0.25rem; }
.insight-text {
  font-size: 0.8rem; color: var(--color-text); line-height: 1.5;
  font-family: var(--font-diary);
}
.insight-label {
  font-size: 0.65rem; color: var(--color-text-muted); margin-top: 0.25rem;
}
.insight-empty {
  font-size: 0.8rem; color: var(--color-text-muted); text-align: center;
  padding: 1rem 0; font-family: var(--font-diary);
}

/* ===== AI Feedback Section ===== */
.feedback-section {
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--color-divider);
  text-align: center;
}
.feedback-section[hidden] { display: none; }
.feedback-question {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  margin-bottom: 0.5rem;
}
.feedback-buttons {
  display: flex;
  justify-content: center;
  gap: 1rem;
}
.feedback-buttons[hidden] { display: none; }
.feedback-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 200ms ease;
}
.feedback-btn:hover {
  transform: scale(1.15);
  border-color: var(--color-primary);
  background: rgba(196, 139, 108, 0.1);
}
.feedback-btn:active { transform: scale(0.95); }
.feedback-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.feedback-btn.active {
  border-color: var(--color-primary);
  background: rgba(196, 139, 108, 0.2);
  transform: scale(1.1);
}
.feedback-btn:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; }
.feedback-icon { font-size: 1.2rem; line-height: 1; }
.feedback-thanks {
  font-size: 0.8rem;
  color: var(--color-success);
  animation: fadeInUp 300ms ease both;
}
.feedback-thanks[hidden] { display: none; }

/* ===== Retention Card ===== */
.retention-card {
  margin-top: 0.75rem;
  padding: 0.85rem 1rem;
  background: var(--gradient-response);
  border-radius: var(--radius-md);
  animation: fadeInUp 400ms cubic-bezier(0.25,0.46,0.45,0.94) both;
}
.retention-card[hidden] { display: none; }
.retention-card-content {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.retention-card-icon {
  font-size: 1.3rem;
  flex-shrink: 0;
  line-height: 1;
}
.retention-card-text {
  font-size: 0.85rem;
  color: var(--color-text);
  line-height: 1.5;
  font-family: var(--font-diary);
}
.retention-link {
  color: var(--color-primary);
  text-decoration: underline;
  cursor: pointer;
  font-weight: 500;
}
.retention-link:hover { color: var(--color-primary-hover); }

/* Dark mode overrides */
[data-theme="dark"] .feedback-btn {
  background: var(--color-surface);
  border-color: var(--color-border);
}
[data-theme="dark"] .feedback-btn:hover {
  background: rgba(251, 146, 60, 0.15);
}
[data-theme="dark"] .feedback-btn.active {
  background: rgba(251, 146, 60, 0.25);
}
[data-theme="dark"] .retention-card {
  background: var(--gradient-response);
}

/* === Feature 5: Emotion theme colors === */
[data-emotion-theme="joy"] .response-card { background: linear-gradient(135deg, #FFF3E0 0%, #FFE0B2 50%, #FFCC80 100%); }
[data-emotion-theme="sadness"] .response-card { background: linear-gradient(135deg, #E3F2FD 0%, #BBDEFB 50%, #90CAF9 100%); }
[data-emotion-theme="anger"] .response-card { background: linear-gradient(135deg, #FBE9E7 0%, #FFCCBC 50%, #FFAB91 100%); }
[data-emotion-theme="anxiety"] .response-card { background: linear-gradient(135deg, #F3E5F5 0%, #E1BEE7 50%, #CE93D8 100%); }
[data-emotion-theme="peace"] .response-card { background: linear-gradient(135deg, #E8F5E9 0%, #C8E6C9 50%, #A5D6A7 100%); }
[data-emotion-theme="love"] .response-card { background: linear-gradient(135deg, #FCE4EC 0%, #F8BBD0 50%, #F48FB1 100%); }
[data-emotion-theme="tired"] .response-card { background: linear-gradient(135deg, #EFEBE9 0%, #D7CCC8 50%, #BCAAA4 100%); }
[data-theme="dark"][data-emotion-theme="joy"] .response-card { background: linear-gradient(135deg, #2a2418 0%, #33291e 50%, #2a2418 100%); }
[data-theme="dark"][data-emotion-theme="sadness"] .response-card { background: linear-gradient(135deg, #181e2e 0%, #1c2438 50%, #181e2e 100%); }
[data-theme="dark"][data-emotion-theme="anger"] .response-card { background: linear-gradient(135deg, #2a1818 0%, #331e1e 50%, #2a1818 100%); }
[data-theme="dark"][data-emotion-theme="anxiety"] .response-card { background: linear-gradient(135deg, #221830 0%, #281e38 50%, #221830 100%); }
[data-theme="dark"][data-emotion-theme="peace"] .response-card { background: linear-gradient(135deg, #182a1c 0%, #1e3322 50%, #182a1c 100%); }
[data-theme="dark"][data-emotion-theme="love"] .response-card { background: linear-gradient(135deg, #2a1822 0%, #331e28 50%, #2a1822 100%); }
[data-theme="dark"][data-emotion-theme="tired"] .response-card { background: linear-gradient(135deg, #201e1c 0%, #282522 50%, #201e1c 100%); }
.history-item[data-emotion-group="joy"] { border-left: 4px solid #F4A261; }
.history-item[data-emotion-group="sadness"] { border-left: 4px solid #7EB8DA; }
.history-item[data-emotion-group="anger"] { border-left: 4px solid #E76F51; }
.history-item[data-emotion-group="anxiety"] { border-left: 4px solid #9C89B8; }
.history-item[data-emotion-group="peace"] { border-left: 4px solid #A8DAAB; }
.history-item[data-emotion-group="love"] { border-left: 4px solid #F2A0A0; }
.history-item[data-emotion-group="tired"] { border-left: 4px solid #B0A89A; }

/* Emotion group — emoji background sync */
.history-item[data-emotion-group="joy"] .history-emoji { background: rgba(244, 162, 97, 0.12); }
.history-item[data-emotion-group="sadness"] .history-emoji { background: rgba(126, 184, 218, 0.12); }
.history-item[data-emotion-group="anger"] .history-emoji { background: rgba(231, 111, 81, 0.12); }
.history-item[data-emotion-group="anxiety"] .history-emoji { background: rgba(156, 137, 184, 0.12); }
.history-item[data-emotion-group="peace"] .history-emoji { background: rgba(168, 218, 171, 0.12); }
.history-item[data-emotion-group="love"] .history-emoji { background: rgba(242, 160, 160, 0.12); }
.history-item[data-emotion-group="tired"] .history-emoji { background: rgba(176, 168, 154, 0.12); }

/* Card active/press feedback */
.history-item:active {
  transform: translateY(0) scale(0.99);
  transition-duration: 50ms;
}

/* Load more button */
.btn-load-more {
  display: block;
  width: 100%;
  padding: 0.75rem;
  margin-top: 0.75rem;
  background: var(--color-surface);
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-lg);
  color: var(--color-text-light);
  font-family: var(--font-body);
  font-size: 0.85rem;
  cursor: pointer;
  transition: border-color 200ms, color 200ms, background 200ms;
}
.btn-load-more:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
  background: var(--color-surface-warm);
}

/* ===== AI Relationship Anniversary Card ===== */
.anniversary-card {
  background: linear-gradient(135deg, var(--color-surface) 0%, rgba(196, 139, 108, 0.08) 100%);
  border: 1px solid rgba(196, 139, 108, 0.25);
  overflow: hidden;
  position: relative;
}
.anniversary-card[hidden] { display: none; }
.anniversary-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--color-primary), #F4A261, var(--color-primary));
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.anniversary-card-inner {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
}
.anniversary-icon {
  font-size: 1.5rem;
  flex-shrink: 0;
  line-height: 1;
}
.anniversary-body {
  flex: 1;
  min-width: 0;
}
.anniversary-title {
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--color-primary);
  margin-bottom: 0.25rem;
  letter-spacing: 0.02em;
}
.anniversary-message {
  font-family: var(--font-diary);
  font-size: 0.85rem;
  color: var(--color-text);
  line-height: 1.5;
}

[data-theme="dark"] .anniversary-card {
  background: linear-gradient(135deg, var(--color-surface) 0%, rgba(251, 146, 60, 0.05) 100%);
  border-color: rgba(251, 146, 60, 0.15);
}

/* ===== Emotion Vocabulary Growth Card ===== */
.emotion-vocab-card[hidden] { display: none; }
.emotion-vocab-inner { padding: 0.25rem 0; }
.emotion-vocab-count {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  margin-bottom: 0.75rem;
}
.emotion-vocab-number {
  font-size: 2rem;
  font-weight: 700;
  color: var(--color-primary);
  line-height: 1;
}
.emotion-vocab-label {
  font-size: 0.9rem;
  color: var(--color-text-secondary);
}
.emotion-vocab-bar {
  display: flex;
  gap: 3px;
  flex-wrap: wrap;
  margin-bottom: 0.6rem;
}
.emotion-vocab-dot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  transition: transform 0.2s;
  cursor: default;
  position: relative;
}
.emotion-vocab-dot:hover {
  transform: scale(1.3);
  z-index: 1;
}
.emotion-vocab-dot[title]::after {
  content: attr(title);
  position: absolute;
  bottom: 110%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--color-text);
  color: var(--color-bg);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.7rem;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
}
.emotion-vocab-dot:hover[title]::after { opacity: 1; }
.emotion-vocab-message {
  font-size: 0.85rem;
  color: var(--color-text-secondary);
  line-height: 1.5;
}

/* ===== 1개월 전 오늘의 마음 회고 카드 ===== */
.memory-card[hidden] { display: none; }
.memory-card {
  background: linear-gradient(135deg, var(--color-surface) 0%, rgba(196, 139, 108, 0.06) 100%);
  border: 1px solid var(--color-border);
  position: relative;
  overflow: hidden;
}
.memory-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--color-primary-light, #D4A574), var(--color-primary));
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.memory-card-inner {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding-top: 0.25rem;
}
.memory-card-emoji {
  font-size: 1.8rem;
  line-height: 1;
  flex-shrink: 0;
}
.memory-card-body {
  flex: 1;
  min-width: 0;
}
.memory-card-emotion {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--color-primary);
  margin-bottom: 0.25rem;
}
.memory-card-text {
  font-size: 0.82rem;
  color: var(--color-text-secondary);
  line-height: 1.55;
  font-family: var(--font-diary);
  word-break: break-word;
}
[data-theme="dark"] .memory-card {
  background: linear-gradient(135deg, var(--color-surface) 0%, rgba(251, 146, 60, 0.04) 100%);
}

/* ===== Inline Style Extractions ===== */

/* Auth switch spacing variants */
.auth-switch--sm { margin-top: 0.5rem; }
.auth-switch--md { margin-top: 1rem; }

/* Welcome / Signup complete screen */
.welcome-card {
  text-align: center;
  padding: 3rem 2rem;
}
.welcome-emoji {
  font-size: 3rem;
  margin-bottom: 1rem;
}
.welcome-title {
  font-family: var(--font-diary);
  font-size: 1.5rem;
  margin-bottom: 0.75rem;
}
.welcome-desc {
  color: var(--color-text-light);
  margin-bottom: 2rem;
  line-height: 1.6;
}
.welcome-start-btn { width: 100%; }

/* Ontology label spacing */
.ontology-label--context { margin-top: 0.75rem; }

/* Response / report loading indicators */
.response-loading-text {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  margin-top: 0.5rem;
}
.report-loading-indicator {
  justify-content: center;
  margin: 1rem 0;
}
.report-loading-text {
  text-align: center;
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

/* Export button wrapper */
.export-btn-group {
  display: flex;
  gap: 0.4rem;
}
.export-btn { font-size: 0.78rem; }

/* Notification time custom input */
.notification-time-custom {
  width: 5.5rem;
  text-align: center;
}

/* Profile section resets */
.profile-section--no-top { margin-top: 0; border: none; }
.profile-section-title--reset { background: none; padding-left: 0; }
.profile-form--top-pad { padding: 0.75rem 0 0; }
.profile-section--danger-gap { margin-top: 0.75rem; }
.danger-warning--reset { padding-left: 0; }
.btn-danger--reset { margin-left: 0; }

/* Footer legal links */
.footer-legal {
  font-size: 0.7rem;
  margin-top: 0.3rem;
  opacity: 0.6;
}
.footer-legal a { color: inherit; }

/* ===== 마음의 별자리 (Constellation Graph) ===== */

.constellation-section { position: relative; }

.constellation-loading {
  text-align: center;
  padding: 2rem 0;
  color: var(--color-text-muted);
  font-size: 0.875rem;
}

.constellation-message {
  text-align: center;
  font-size: 0.8rem;
  color: var(--color-text-muted);
  margin-bottom: 0.75rem;
  font-style: italic;
}

.constellation-svg {
  width: 100%;
  height: auto;
  border-radius: 12px;
  display: block;
}

/* 별자리 배경 (다크모드에서 자연스러운 밤하늘) */
.constellation-background { rx: 12; }
[data-theme="dark"] .constellation-background { opacity: 1; }

/* 배경 작은 별 — 반짝임 */
.constellation-bg-star {
  animation: constellationTwinkle 4s ease-in-out infinite;
  animation-delay: calc(var(--i, 0) * 0.7s);
}

/* 별(노드) 반짝임 애니메이션 */
@keyframes constellationTwinkle {
  0%, 100% { opacity: 0.3; filter: drop-shadow(0 0 1px currentColor); }
  50% { opacity: 1; filter: drop-shadow(0 0 4px currentColor); }
}

@keyframes constellationStarPulse {
  0%, 100% { filter: drop-shadow(0 0 3px currentColor); }
  50% { filter: drop-shadow(0 0 8px currentColor); }
}

.constellation-star {
  cursor: pointer;
  animation: constellationStarPulse 3s ease-in-out infinite;
  transition: r 0.2s ease;
}
.constellation-star:hover,
.constellation-star--active {
  filter: drop-shadow(0 0 12px currentColor) !important;
}

/* 별자리 연결선 */
.constellation-line {
  transition: opacity 0.3s ease;
}

/* 중심 "나" */
.constellation-center {
  animation: constellationTwinkle 5s ease-in-out infinite;
}

/* 별자리 이름 레이블 */
.constellation-name-label {
  font-family: var(--font-ui);
  letter-spacing: 0.05em;
}

/* 툴팁 */
.constellation-tooltip {
  position: absolute;
  display: none;
  flex-direction: column;
  gap: 2px;
  background: rgba(20, 22, 40, 0.95);
  color: #fff;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 0.75rem;
  pointer-events: none;
  z-index: 10;
  white-space: nowrap;
  border: 1px solid rgba(255,255,255,0.1);
  backdrop-filter: blur(4px);
}
.constellation-tooltip-emotion { font-weight: 600; font-size: 0.85rem; }
.constellation-tooltip-count { color: rgba(255,255,255,0.7); }
.constellation-tooltip-date { color: rgba(255,255,255,0.5); font-size: 0.7rem; }

/* 빈 상태 */
.constellation-empty {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--color-text-muted);
}
.constellation-empty-icon { font-size: 2rem; margin-bottom: 0.5rem; }
.constellation-empty-text { font-size: 0.9rem; margin-bottom: 0.25rem; }
.constellation-empty-sub { font-size: 0.75rem; opacity: 0.7; }

/* 별자리 정보 패널 */
.constellation-info {
  margin-top: 1rem;
}
.constellation-info-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 0.5rem;
}

.constellation-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 10px;
  padding: 0.75rem;
  margin-bottom: 0.5rem;
}
.constellation-card--complete {
  border-color: var(--color-primary);
  background: var(--color-surface-hover);
}
.constellation-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.25rem;
}
.constellation-card-name {
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--color-text);
}
.constellation-card-badge {
  font-size: 0.65rem;
  background: var(--color-primary);
  color: #fff;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 600;
}
.constellation-card-desc {
  display: block;
  font-size: 0.75rem;
  color: var(--color-text-muted);
  margin-bottom: 0.5rem;
}
.constellation-progress {
  height: 4px;
  background: var(--color-border);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 0.4rem;
}
.constellation-progress-bar {
  height: 100%;
  background: var(--color-primary);
  border-radius: 2px;
  transition: width 0.5s ease;
}
.constellation-card-emotions {
  font-size: 0.7rem;
  color: var(--color-text-muted);
  margin: 0;
}
.constellation-emotion-tag.matched {
  color: var(--color-primary);
  font-weight: 600;
}

/* 모바일 최적화 */
@media (max-width: 480px) {
  .constellation-star-label { display: none; }
}
