/* =========================================
   PAGE FRAME
========================================= */
.container {
  width: min(var(--max-width), 92%);
  margin: auto;
}

.page {
  padding: 140px 0 60px;
  min-height: 82vh;
  animation: pageIn 0.7s ease both;
}

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

.page-header {
  margin-bottom: 38px;
}

.page-header h1 {
  font-family: var(--font-head);
  font-size: clamp(1.9rem, 4.5vw, 3rem);
  letter-spacing: -2px;
  line-height: 1.1;
}

.page-header .lead {
  color: var(--muted);
  margin-top: 14px;
  max-width: 640px;
  line-height: 1.8;
  font-size: 1rem;
}

.muted {
  color: var(--muted);
}

/* =========================================
   GRIDS
========================================= */
.grid {
  display: grid;
  gap: 20px;
}

.grid-2 {
  grid-template-columns: repeat(2, 1fr);
}

.grid-3 {
  grid-template-columns: repeat(3, 1fr);
}

.grid-4 {
  grid-template-columns: repeat(4, 1fr);
}

.grid-2-1 {
  grid-template-columns: 2fr 1fr;
}

.grid-1-2 {
  grid-template-columns: 1fr 2fr;
}

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

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

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

/* =========================================
   STAT CARDS
========================================= */
.stat-card {
  padding: 22px 24px;
}

.stat-card .stat-label {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.stat-card .stat-value {
  font-family: var(--font-head);
  font-size: 2.2rem;
  margin-top: 10px;
  line-height: 1;
}

.stat-card .stat-value.gradient {
  background: linear-gradient(90deg, #ffe9a3, #ffb020);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.stat-card .stat-note {
  color: var(--muted);
  font-size: 0.82rem;
  margin-top: 8px;
}

/* =========================================
   FORMS
========================================= */
label.field-label {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
  text-transform: uppercase;
}

.input,
.textarea,
.select {
  width: 100%;
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.95rem;
  padding: 13px 15px;
  outline: none;
  transition: border-color 0.25s ease, background 0.25s ease, box-shadow 0.25s ease;
  appearance: none;
}

.input:focus,
.textarea:focus,
.select:focus {
  border-color: var(--accent);
  background: rgba(255, 255, 255, 0.06);
  box-shadow: 0 0 0 3px rgba(255, 190, 60, 0.18);
}

.input::placeholder,
.textarea::placeholder {
  color: rgba(169, 175, 189, 0.55);
}

.textarea {
  min-height: 150px;
  resize: vertical;
  line-height: 1.7;
}

.select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23a9afbd' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 15px center;
  padding-right: 42px;
}

.select option {
  background: #121527;
  color: var(--text);
}

.form-section {
  margin-bottom: 26px;
}

/* =========================================
   MOOD / EMOTION PICKER
========================================= */
.emoji-picker {
  display: flex;
  gap: 10px;
  justify-content: space-between;
  flex-wrap: wrap;
}

.emoji-btn {
  flex: 1;
  min-width: 82px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 16px 8px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
  transition: 0.25s ease;
}

.emoji-btn .emoji {
  font-size: 2rem;
  line-height: 1;
  filter: grayscale(1) opacity(0.5);
  transition: 0.25s ease;
}

.emoji-btn:hover {
  transform: translateY(-4px);
  border-color: var(--border-hover);
  background: var(--card-hover);
}

.emoji-btn.selected {
  border-color: var(--accent);
  background: rgba(255, 190, 60, 0.16);
  color: #fff;
  box-shadow: 0 10px 30px rgba(255, 190, 60, 0.28);
}

.emoji-btn.selected .emoji {
  filter: none;
}

/* =========================================
   SLIDER
========================================= */
.range-row {
  margin-bottom: 18px;
}

.range-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 12px;
}

.range-header .range-label {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 600;
}

.range-header .range-value {
  font-family: var(--font-head);
  font-size: 1.4rem;
  color: var(--accent-2);
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  outline: none;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--accent);
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(255, 190, 60, 0.5);
}

input[type="range"]::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--accent);
  cursor: pointer;
}

input[type="range"]:disabled {
  opacity: 0.4;
  pointer-events: none;
}

/* =========================================
   CHIPS (triggers / tags)
========================================= */
.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
}

.chip {
  padding: 9px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  font-size: 0.84rem;
  cursor: pointer;
  user-select: none;
  transition: 0.22s ease;
}

.chip:hover {
  border-color: var(--border-hover);
  color: #fff;
}

.chip.selected {
  background: rgba(255, 190, 60, 0.16);
  border-color: var(--accent-2);
  color: #fff;
}

.chip.small {
  padding: 7px 12px;
  font-size: 0.78rem;
  cursor: default;
}

/* =========================================
   LISTS (history / entries)
========================================= */
.entry-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.entry-item {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  padding: 18px 20px;
}

.entry-main {
  min-width: 0;
}

.entry-title {
  font-weight: 600;
  font-size: 0.98rem;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.entry-date {
  color: var(--muted);
  font-size: 0.82rem;
  margin-top: 6px;
}

.entry-text {
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.7;
  margin-top: 8px;
}

.entry-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 600;
}

.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--muted);
}

.empty-state .empty-icon {
  font-size: 2.6rem;
  margin-bottom: 14px;
  opacity: 0.6;
}

.empty-state p {
  max-width: 380px;
  margin: 8px auto 0;
  line-height: 1.7;
  font-size: 0.92rem;
}

/* =========================================
   REVEAL CARD (journal editing)
========================================= */
.reveal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 14px;
}

/* =========================================
   BREATHING
========================================= */
.breath-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  padding: 40px 0;
}

.breath-orb-wrap {
  position: relative;
  width: 240px;
  height: 240px;
  display: grid;
  place-items: center;
}

.breath-orb {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: radial-gradient(circle at 32% 30%, #ffe08a, var(--accent) 45%, #c9820a);
  box-shadow: 0 0 60px rgba(255, 190, 60, 0.55), 0 0 120px rgba(255, 190, 60, 0.25);
  transition: transform cubic-bezier(0.4, 0, 0.2, 1) var(--breath-dur, 4s);
}

.breath-orb.phase-inhale {
  transform: scale(1.85);
}

.breath-orb.phase-breathe-hold,
.breath-orb.phase-hold {
  transform: scale(1.85);
}

.breath-orb.phase-exhale {
  transform: scale(1);
}

.breath-orb-ring {
  position: absolute;
  inset: -40px;
  border-radius: 50%;
  border: 1px dashed rgba(255, 190, 60, 0.35);
  animation: spin 24s linear infinite;
  z-index: -1;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.breath-phase-label {
  font-family: var(--font-head);
  font-size: 1.6rem;
  color: #fff;
}

.breath-count {
  font-size: 3.4rem;
  font-weight: 700;
  font-family: var(--font-head);
  color: var(--accent-2);
  line-height: 1;
  text-shadow: 0 0 30px rgba(255, 190, 60, 0.4);
}

.breath-cycle {
  color: var(--muted);
  font-size: 0.9rem;
  letter-spacing: 1px;
}

.breath-pattern-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.breath-pattern-card {
  padding: 20px;
  cursor: pointer;
  text-align: center;
}

.breath-pattern-card h4 {
  font-family: var(--font-head);
  font-size: 1.05rem;
  margin-bottom: 8px;
  color: #fff;
}

.breath-pattern-card p {
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.6;
}

.breath-pattern-card.selected {
  border-color: var(--accent-2);
  background: rgba(255, 190, 60, 0.1);
  box-shadow: 0 10px 30px rgba(255, 190, 60, 0.18);
}

.breath-summary {
  text-align: center;
}

.breath-summary .big {
  font-family: var(--font-head);
  font-size: 2.4rem;
  background: linear-gradient(90deg, #ffe9a3, #ffb020);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* =========================================
   COACH CHAT
========================================= */
.chat-wrap {
  display: flex;
  flex-direction: column;
  height: 620px;
  max-height: 72vh;
  overflow: hidden;
  border-radius: 22px;
  background: rgba(8, 11, 20, 0.5);
  border: 1px solid var(--border);
}

.chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.chat-bubble {
  max-width: 78%;
  padding: 13px 18px;
  border-radius: 18px;
  font-size: 0.93rem;
  line-height: 1.7;
  animation: bubbleIn 0.35s ease both;
  white-space: pre-line;
}

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

.chat-bubble.coach {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  border-bottom-left-radius: 6px;
  color: var(--text);
}

.chat-bubble.user {
  align-self: flex-end;
  background: linear-gradient(135deg, rgba(255, 202, 60, 0.95), rgba(255, 150, 30, 0.9));
  border: none;
  border-bottom-right-radius: 6px;
  color: #1a1205;
}

.chat-bubble .chat-time {
  display: block;
  margin-top: 6px;
  font-size: 0.7rem;
  opacity: 0.6;
}

.chat-typing {
  align-self: flex-start;
  display: inline-flex;
  gap: 5px;
  padding: 15px 18px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  border-radius: 18px;
  border-bottom-left-radius: 6px;
}

.chat-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
  animation: typing 1.2s infinite ease-in-out;
}

.chat-typing span:nth-child(2) {
  animation-delay: 0.15s;
}

.chat-typing span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes typing {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-5px); opacity: 1; }
}

.chat-input {
  display: flex;
  gap: 10px;
  padding: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  background: rgba(16, 13, 7, 0.6);
}

.chat-input .input {
  border-radius: 14px;
}

.chat-input .btn {
  flex-shrink: 0;
  width: auto;
  padding: 12px 18px;
}

.coach-suggestion {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  margin: 4px 8px 4px 0;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  font-size: 0.82rem;
  cursor: pointer;
  transition: 0.22s ease;
}

.coach-suggestion:hover {
  border-color: var(--accent-2);
  color: #fff;
}

/* =========================================
   CHARTS
========================================= */
.chart-card {
  position: relative;
  padding: 22px 24px;
}

.chart-card canvas {
  max-height: 320px;
}

.chart-card h3 {
  font-family: var(--font-head);
  font-size: 1.05rem;
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.chart-card h3 span {
  color: var(--muted);
  font-family: var(--font-body);
  font-size: 0.78rem;
  font-weight: 500;
}

/* =========================================
   INSIGHTS
========================================= */
.insight-card {
  position: relative;
  overflow: hidden;
  padding: 24px;
}

.insight-card .insight-emoji {
  font-size: 1.8rem;
  margin-bottom: 14px;
}

.insight-card h3 {
  font-size: 1.02rem;
  margin-bottom: 8px;
}

.insight-card p {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.75;
}

.insight-card .insight-tag-label {
  display: inline-flex;
  align-items: center;
  color: var(--green);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  margin-bottom: 12px;
}

/* =========================================
   SUSHIPTI / SLEEP
========================================= */
.sleep-orb {
  position: relative;
  width: 260px;
  height: 260px;
  margin: 0 auto;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 35% 35%, rgba(255, 190, 60, 0.55), rgba(255, 190, 60, 0.12) 60%, transparent);
  transition: transform 3s ease;
}

.sleep-orb .sleep-phase {
  text-align: center;
  color: #fff;
}

.sleep-orb .sleep-phase .phase-name {
  font-family: var(--font-head);
  font-size: 1.5rem;
}

.sleep-orb .sleep-phase .phase-desc {
  color: var(--muted);
  font-size: 0.88rem;
  margin-top: 8px;
  max-width: 210px;
  line-height: 1.6;
}

.sleep-orb.expanded {
  transform: scale(1.12);
}

.sleep-ring {
  position: absolute;
  inset: -30px;
  border-radius: 50%;
  border: 1px solid rgba(255, 190, 60, 0.25);
  animation: spin 36s linear infinite;
}

.sleep-ring:nth-child(2) {
  inset: -60px;
  border-color: rgba(255, 157, 46, 0.2);
  animation-duration: 52s;
  animation-direction: reverse;
}

/* =========================================
   AUTH (login / signup)
========================================= */
.auth-card {
  max-width: 460px;
  margin: 0 auto;
}

.auth-card .auth-logo {
  width: 56px;
  height: 56px;
  margin: 0 auto;
  object-fit: contain;
}

.auth-sub {
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.7;
  margin-top: 10px;
}

.auth-field-hint {
  color: var(--muted);
  font-size: 0.78rem;
  margin-top: 7px;
}

.auth-error {
  display: none;
  color: var(--danger);
  font-size: 0.88rem;
  margin-top: 12px;
  text-align: center;
}

.auth-link {
  color: var(--accent-2);
  font-weight: 600;
}

.auth-link:hover {
  color: #fff;
  text-decoration: underline;
}

/* =========================================
   MISC UTILITIES
========================================= */
.gradient-bar {
  height: 5px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  margin-top: 12px;
}

.pill {
  display: inline-flex;
  align-items: center;
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 600;
}

.divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.08);
  margin: 22px 0;
}

.text-center {
  text-align: center;
}

.hide {
  display: none !important;
}

.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mt-4 { margin-top: 36px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }

/* =========================================
   RESPONSIVE
========================================= */
@media (max-width: 1000px) {
  .grid-4 {
    grid-template-columns: repeat(2, 1fr);
  }

  .grid-2-1,
  .grid-1-2 {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 800px) {
  .page {
    padding: 120px 0 48px;
  }

  .grid-3,
  .grid-2 {
    grid-template-columns: 1fr;
  }

  .breath-pattern-cards {
    grid-template-columns: 1fr;
  }

  .chat-wrap {
    height: 70vh;
  }
}

@media (max-width: 650px) {
  .stat {
    flex: 1 1 100%;
    min-width: 0;
    width: 100%;
  }

  .chat-input .input {
    flex: 1 1 auto;
    width: auto;
    min-width: 0;
  }

  .chat-input .btn {
    flex: 0 0 auto;
    width: auto;
    padding: 0 20px;
  }

  .dig-card > .row.space-between {
    flex-direction: column;
    align-items: stretch;
    gap: 18px;
  }

  .dig-actions {
    flex-direction: column;
    width: 100%;
    gap: 12px;
  }

  .dig-actions .btn {
    width: 100%;
    justify-content: center;
    text-align: center;
    padding: 13px 20px;
  }
}

@media (max-width: 480px) {
  .grid-4 {
    grid-template-columns: 1fr;
  }

  .chat-bubble {
    max-width: 88%;
  }
}