/* ==========================================================================
   こころクエスト (Kokoro Quest) - Design System & Mobile-First Styles
   温かみがあり安心感のあるRPG風UI（プレッシャーを感じない優しい配色）
   ========================================================================== */

:root {
  /* Palette: Warm Parchment & Earthy Cozy RPG */
  --bg-page: #f5efe4;
  --bg-app: #fbf8f1;
  --bg-card: #fffdf9;
  --bg-card-soft: #f6f0e4;
  --bg-inset: #f2eadc;

  --text-main: #3a322a;
  --text-sub: #74685c;
  --text-muted: #9b8f82;

  --border-soft: #e7decb;
  --border-strong: #d5c8ae;

  /* Calming Accents */
  --primary: #5b8a6b;
  --primary-dark: #467054;
  --primary-soft: #e6f0e9;

  --gold: #d09232;
  --gold-soft: #fbf1dc;

  --coral: #c96f59;
  --coral-soft: #faeae5;

  --sky: #5d84a3;
  --sky-soft: #e7f0f7;

  --danger: #b8564d;
  --danger-soft: #fbeae8;

  /* Shadows (Soft paper depth) */
  --shadow-xs: 0 1px 2px rgba(74, 58, 38, 0.05);
  --shadow-sm: 0 3px 10px rgba(74, 58, 38, 0.06), 0 1px 2px rgba(74, 58, 38, 0.04);
  --shadow-md: 0 8px 24px rgba(74, 58, 38, 0.1), 0 2px 6px rgba(74, 58, 38, 0.05);
  --shadow-nav: 0 -4px 16px rgba(74, 58, 38, 0.07);

  /* Radii */
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 22px;
  --radius-pill: 999px;

  /* Layout */
  --app-max-width: 500px;
  --nav-height: 70px;
  --header-height: 60px;

  /* Typography */
  --font-display: 'Zen Maru Gothic', 'Hiragino Maru Gothic ProN', 'Yu Gothic', sans-serif;
  --font-body: 'Noto Sans JP', -apple-system, BlinkMacSystemFont, 'Hiragino Sans', sans-serif;
  --font-num: 'Quicksand', 'Zen Maru Gothic', sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html {
  font-size: 16px;
  background-color: var(--bg-page);
  color: var(--text-main);
  font-family: var(--font-body);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

body {
  margin: 0;
  min-height: 100dvh;
  background: radial-gradient(circle at top center, #fdfaf3 0%, var(--bg-page) 70%);
  display: flex;
  justify-content: center;
}

/* App Shell */
.app-shell {
  width: 100%;
  max-width: var(--app-max-width);
  min-height: 100dvh;
  background-color: var(--bg-app);
  position: relative;
  display: flex;
  flex-direction: column;
  box-shadow: 0 0 40px rgba(74, 58, 38, 0.08);
}

/* Header */
.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  height: var(--header-height);
  padding: 0 16px;
  background: rgba(251, 248, 241, 0.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-soft);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-icon {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  object-fit: cover;
  border: 1px solid var(--border-soft);
  box-shadow: var(--shadow-xs);
  flex-shrink: 0;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.brand-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.08rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--text-main);
}

.brand-sub {
  font-size: 0.7rem;
  color: var(--text-sub);
}

.header-level-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--gold-soft);
  border: 1px solid #ead4a6;
  color: #8c5c12;
  padding: 5px 11px;
  border-radius: var(--radius-pill);
  font-family: var(--font-num);
  font-weight: 700;
  font-size: 0.84rem;
  flex-shrink: 0;
  cursor: pointer;
  transition: transform 0.15s ease;
}

.header-level-pill:active {
  transform: scale(0.95);
}

/* Main Content */
.app-main {
  flex: 1;
  padding: 16px 16px calc(var(--nav-height) + env(safe-area-inset-bottom, 12px) + 24px);
}

.view {
  display: none;
  animation: fadeSlideUp 0.24s ease-out;
}

.view.is-active {
  display: block;
}

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

/* Section Headers */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 22px 0 10px;
}

.section-header:first-child {
  margin-top: 2px;
}

.section-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Cards */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  padding: 16px;
  box-shadow: var(--shadow-sm);
}

.card + .card {
  margin-top: 12px;
}

.card-soft {
  background: var(--bg-card-soft);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  padding: 14px 16px;
}

/* Hero Player Status Card */
.player-card {
  background: linear-gradient(155deg, #fffdf8 0%, #f7f0e1 100%);
  border: 1px solid #e4d6bb;
  border-radius: var(--radius-lg);
  padding: 18px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}

.player-card-top {
  display: flex;
  align-items: center;
  gap: 14px;
}

.player-emblem {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: #fff;
  border: 2px solid #e6d5b2;
  padding: 3px;
  box-shadow: var(--shadow-xs);
  flex-shrink: 0;
}

.player-emblem img {
  width: 100%;
  height: 100%;
  border-radius: 12px;
  object-fit: cover;
  display: block;
}

.player-info {
  flex: 1;
  min-width: 0;
}

.player-name-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.player-name {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
}

.player-edit-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.85rem;
  padding: 4px 6px;
  border-radius: 8px;
  cursor: pointer;
}

.player-edit-btn:hover {
  background: rgba(0, 0, 0, 0.04);
  color: var(--text-main);
}

.player-title-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 3px;
  font-size: 0.78rem;
  color: #8a5c14;
  background: var(--gold-soft);
  padding: 2px 10px;
  border-radius: var(--radius-pill);
  font-weight: 600;
}

.player-level-box {
  text-align: right;
  flex-shrink: 0;
}

.player-level-label {
  display: block;
  font-size: 0.68rem;
  color: var(--text-sub);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.player-level-num {
  font-family: var(--font-num);
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1;
  color: var(--primary-dark);
}

/* Progress Bars */
.xp-block {
  margin-top: 14px;
}

.xp-meta {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 0.78rem;
  color: var(--text-sub);
  margin-bottom: 6px;
}

.xp-numbers {
  font-family: var(--font-num);
  font-weight: 700;
  color: var(--text-main);
}

.progress-track {
  width: 100%;
  height: 11px;
  background: var(--bg-inset);
  border-radius: var(--radius-pill);
  overflow: hidden;
  box-shadow: inset 0 1px 2px rgba(74, 58, 38, 0.08);
}

.progress-track.is-slim {
  height: 7px;
}

.progress-fill {
  height: 100%;
  border-radius: var(--radius-pill);
  background: linear-gradient(90deg, #6fa180 0%, var(--primary) 100%);
  transition: width 0.5s cubic-bezier(0.22, 1, 0.36, 1);
  min-width: 4px;
}

/* Guide / AI Encouragement Card */
.guide-card {
  margin-top: 14px;
  background: #fffdf9;
  border: 1px solid #e6dcc8;
  border-radius: var(--radius-md);
  padding: 14px 15px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
  box-shadow: var(--shadow-xs);
}

.guide-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--primary-soft);
  border: 1px solid #cde0d3;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}

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

.guide-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--primary-dark);
  margin-bottom: 3px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.guide-date {
  font-weight: 400;
  color: var(--text-muted);
}

.guide-message {
  margin: 0;
  font-size: 0.88rem;
  color: var(--text-main);
  line-height: 1.6;
  white-space: pre-wrap;
}

/* Category Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  padding: 13px;
  box-shadow: var(--shadow-xs);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  text-align: left;
  width: 100%;
  font-family: inherit;
  color: inherit;
}

.stat-card:hover {
  box-shadow: var(--shadow-sm);
}

.stat-card:active {
  transform: scale(0.98);
}

.stat-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 8px;
}

.stat-name-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.stat-icon {
  font-size: 1.15rem;
  line-height: 1;
}

.stat-name {
  font-family: var(--font-display);
  font-size: 0.9rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stat-lv {
  font-family: var(--font-num);
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-sub);
  background: var(--bg-card-soft);
  padding: 2px 7px;
  border-radius: var(--radius-pill);
  flex-shrink: 0;
}

.stat-xp-text {
  margin-top: 5px;
  font-size: 0.72rem;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
}

/* Quick Steps on Home & Quest Steps */
.step-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px;
  background: var(--bg-app);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  margin-top: 8px;
}

.step-item-main {
  flex: 1;
  min-width: 0;
}

.step-title {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-main);
  line-height: 1.45;
}

.step-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 5px;
  font-size: 0.73rem;
  color: var(--text-sub);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  font-size: 0.72rem;
  font-weight: 600;
  background: var(--bg-card-soft);
  color: var(--text-sub);
  border: 1px solid var(--border-soft);
}

.badge-xp {
  background: var(--gold-soft);
  border-color: #ebd6ab;
  color: #8a5c14;
  font-family: var(--font-num);
}

.badge-count {
  background: var(--primary-soft);
  border-color: #cbe0d2;
  color: var(--primary-dark);
}

.step-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-family: var(--font-display);
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.14s ease, background-color 0.18s ease, box-shadow 0.18s ease;
  text-decoration: none;
  line-height: 1.2;
}

.btn:active {
  transform: scale(0.97);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  background: var(--primary);
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(91, 138, 107, 0.25);
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-dark);
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-main);
  border-color: var(--border-strong);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--bg-card-soft);
}

.btn-soft {
  background: var(--primary-soft);
  color: var(--primary-dark);
  border-color: #cde0d3;
}

.btn-soft:hover:not(:disabled) {
  background: #d9eadf;
}

.btn-danger-soft {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: #efc9c5;
}

.btn-ghost {
  background: transparent;
  color: var(--text-sub);
  border-color: transparent;
  min-height: 36px;
  padding: 6px 10px;
  font-size: 0.82rem;
}

.btn-ghost:hover {
  background: var(--bg-card-soft);
  color: var(--text-main);
}

.btn-sm {
  min-height: 36px;
  padding: 6px 12px;
  font-size: 0.82rem;
  border-radius: 10px;
}

.btn-record {
  min-height: 40px;
  padding: 8px 13px;
  font-size: 0.82rem;
  border-radius: var(--radius-pill);
  background: var(--primary);
  color: #fff;
  border: none;
  font-family: var(--font-display);
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 2px 6px rgba(91, 138, 107, 0.24);
  transition: transform 0.14s ease, background-color 0.16s ease;
}

.btn-record:active {
  transform: scale(0.95);
}

.btn-block {
  width: 100%;
}

.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid var(--border-soft);
  background: var(--bg-card);
  color: var(--text-sub);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.9rem;
  flex-shrink: 0;
}

.icon-btn:hover {
  background: var(--bg-card-soft);
  color: var(--text-main);
}

/* Quest Cards */
.quest-card {
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 14px;
}

.quest-card.is-completed {
  opacity: 0.82;
  background: #faf7f0;
}

.quest-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.quest-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.04rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.35;
}

.quest-worry {
  margin: 6px 0 0;
  font-size: 0.83rem;
  color: var(--text-sub);
  background: var(--bg-card-soft);
  padding: 8px 11px;
  border-radius: 10px;
  line-height: 1.5;
}

.quest-footer {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px dashed var(--border-soft);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

/* Segmented Tabs (Filter / AI Sub-tabs) */
.segmented {
  display: flex;
  background: var(--bg-inset);
  padding: 4px;
  border-radius: var(--radius-sm);
  gap: 4px;
  margin-bottom: 14px;
}

.segmented-btn {
  flex: 1;
  min-height: 40px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-sub);
  font-family: var(--font-display);
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  transition: background-color 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
}

.segmented-btn.is-active {
  background: var(--bg-card);
  color: var(--primary-dark);
  box-shadow: var(--shadow-xs);
}

/* Forms */
.form-group {
  margin-bottom: 14px;
}

.form-label {
  display: block;
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 6px;
}

.form-hint {
  display: block;
  font-size: 0.75rem;
  color: var(--text-sub);
  margin-top: 4px;
}

.input,
.textarea,
.select {
  width: 100%;
  font-family: var(--font-body);
  font-size: 0.94rem;
  color: var(--text-main);
  background: #ffffff;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 11px 12px;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.input:focus,
.textarea:focus,
.select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(91, 138, 107, 0.16);
}

.textarea {
  resize: vertical;
  min-height: 92px;
  line-height: 1.55;
}

.textarea-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.8rem;
  min-height: 140px;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.86rem;
  color: var(--text-main);
  cursor: pointer;
  user-select: none;
}

.checkbox-row input {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
}

/* AI Validation Feedback Boxes */
.feedback-box {
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin: 12px 0;
  font-size: 0.84rem;
  line-height: 1.55;
}

.feedback-box ul {
  margin: 6px 0 0;
  padding-left: 18px;
}

.feedback-error {
  background: var(--danger-soft);
  border: 1px solid #ebc3be;
  color: #8c352d;
}

.feedback-success {
  background: var(--primary-soft);
  border: 1px solid #c4dccb;
  color: #2f543c;
}

.feedback-warn {
  background: var(--gold-soft);
  border: 1px solid #ead5a7;
  color: #7d5310;
}

.code-preview {
  background: #2f2a24;
  color: #f4eee3;
  border-radius: var(--radius-sm);
  padding: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.76rem;
  line-height: 1.5;
  overflow-x: auto;
  max-height: 260px;
  white-space: pre-wrap;
  word-break: break-word;
}

/* Log Timeline */
.log-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.log-item {
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  box-shadow: var(--shadow-xs);
}

.log-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.log-date {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.log-xp {
  font-family: var(--font-num);
  font-weight: 700;
  font-size: 0.84rem;
  color: var(--primary-dark);
  background: var(--primary-soft);
  padding: 2px 8px;
  border-radius: var(--radius-pill);
}

.log-title {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 600;
}

.log-sub {
  margin-top: 4px;
  font-size: 0.78rem;
  color: var(--text-sub);
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.log-memo {
  margin: 6px 0 0;
  font-size: 0.82rem;
  color: var(--text-sub);
  background: var(--bg-app);
  padding: 6px 10px;
  border-radius: 8px;
}

/* 5-Level Gentle Rating Selector */
.rating-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 12px 0;
}

.rating-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border-soft);
  background: var(--bg-card);
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  transition: border-color 0.15s ease, background-color 0.15s ease, transform 0.12s ease;
}

.rating-option:active {
  transform: scale(0.985);
}

.rating-option.is-selected {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.rating-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.rating-emoji {
  font-size: 1.35rem;
  line-height: 1;
}

.rating-label {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.94rem;
  color: var(--text-main);
}

.rating-xp-preview {
  font-family: var(--font-num);
  font-weight: 700;
  font-size: 0.86rem;
  color: #8a5c14;
  background: var(--gold-soft);
  padding: 3px 9px;
  border-radius: var(--radius-pill);
}

.rating-encouragement {
  font-size: 0.82rem;
  color: var(--primary-dark);
  background: var(--primary-soft);
  padding: 9px 12px;
  border-radius: 10px;
  margin-bottom: 12px;
}

/* Color Swatches */
.color-swatches {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.color-swatch {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 3px solid transparent;
  cursor: pointer;
  transition: transform 0.14s ease;
}

.color-swatch.is-selected {
  border-color: var(--text-main);
  transform: scale(1.1);
}

/* Bottom Navigation Bar (One-Handed Friendly) */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: var(--app-max-width);
  height: calc(var(--nav-height) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: rgba(255, 253, 249, 0.96);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--border-soft);
  box-shadow: var(--shadow-nav);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  z-index: 30;
}

.nav-item {
  border: none;
  background: transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--text-muted);
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
  padding: 6px 4px;
  transition: color 0.16s ease;
}

.nav-item-icon {
  font-size: 1.35rem;
  line-height: 1;
  transition: transform 0.18s ease;
}

.nav-item.is-active {
  color: var(--primary-dark);
}

.nav-item.is-active .nav-item-icon {
  transform: translateY(-2px) scale(1.08);
}

/* Bottom Sheet Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(45, 36, 26, 0.48);
  backdrop-filter: blur(3px);
  z-index: 50;
  display: none;
  align-items: flex-end;
  justify-content: center;
}

.modal-overlay.is-open {
  display: flex;
  animation: fadeIn 0.18s ease-out;
}

@media (min-width: 600px) {
  .modal-overlay {
    align-items: center;
    padding: 16px;
  }
}

.modal-sheet {
  width: 100%;
  max-width: var(--app-max-width);
  max-height: 88dvh;
  overflow-y: auto;
  background: var(--bg-app);
  border-radius: 22px 22px 0 0;
  padding: 18px 18px calc(20px + env(safe-area-inset-bottom, 0px));
  box-shadow: var(--shadow-md);
  animation: slideUpSheet 0.24s cubic-bezier(0.22, 1, 0.36, 1);
}

@media (min-width: 600px) {
  .modal-sheet {
    border-radius: 22px;
  }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}

.modal-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.08rem;
  font-weight: 700;
}

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

.modal-actions > * {
  flex: 1;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUpSheet {
  from { transform: translateY(32px); opacity: 0.4; }
  to { transform: translateY(0); opacity: 1; }
}

/* Level-Up Celebration Overlay */
.celebration-overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(45, 36, 26, 0.62);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.celebration-overlay.is-open {
  display: flex;
  animation: fadeIn 0.25s ease-out;
}

.celebration-card {
  width: 100%;
  max-width: 360px;
  background: linear-gradient(160deg, #fffef9 0%, #fbf1dc 100%);
  border: 2px solid #e7c986;
  border-radius: 26px;
  padding: 28px 22px 22px;
  text-align: center;
  box-shadow: 0 20px 50px rgba(45, 36, 26, 0.25);
  position: relative;
  overflow: hidden;
  animation: popIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes popIn {
  from { transform: scale(0.84); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.celebration-sparkle {
  font-size: 3rem;
  line-height: 1;
  margin-bottom: 10px;
  animation: gentleFloat 2s ease-in-out infinite;
}

@keyframes gentleFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

.celebration-kicker {
  font-family: var(--font-num);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--gold);
  margin: 0;
}

.celebration-title {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-main);
  margin: 6px 0 8px;
}

.celebration-detail {
  margin: 0 0 18px;
  font-size: 0.9rem;
  color: var(--text-sub);
  line-height: 1.6;
}

.confetti-piece {
  position: absolute;
  width: 9px;
  height: 9px;
  border-radius: 3px;
  top: -12px;
  animation: confettiFall 2.2s linear forwards;
  pointer-events: none;
}

@keyframes confettiFall {
  0% { transform: translateY(0) rotate(0deg); opacity: 1; }
  100% { transform: translateY(380px) rotate(360deg); opacity: 0; }
}

/* Toast */
.toast {
  position: fixed;
  bottom: calc(var(--nav-height) + env(safe-area-inset-bottom, 0px) + 14px);
  left: 50%;
  transform: translateX(-50%) translateY(16px);
  background: rgba(58, 50, 42, 0.94);
  color: #fffdf9;
  padding: 10px 18px;
  border-radius: var(--radius-pill);
  font-size: 0.85rem;
  font-weight: 600;
  z-index: 90;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  max-width: 90vw;
  text-align: center;
  box-shadow: var(--shadow-md);
}

.toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Empty State & Helpers */
.empty-state {
  text-align: center;
  padding: 26px 16px;
  color: var(--text-sub);
  background: var(--bg-card);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-md);
  font-size: 0.88rem;
}

.empty-state-icon {
  font-size: 1.8rem;
  margin-bottom: 6px;
}

.stack-sm {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.row-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.row-gap {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.mt-12 {
  margin-top: 12px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}
