/* Boti naplója — cozy warm theme */

:root {
  --bg: #FDF4E7;
  --card: #FFFFFF;
  --ink: #4A3B2F;
  --muted: #A08C77;
  --line: #F1E3D0;
  --peach: #F59E7D;
  --peach-deep: #E8825C;
  --honey: #F2B25C;
  --honey-deep: #E09B3D;
  --night-1: #7B7EB8;
  --night-2: #565988;
  --cream: #FFF8EC;
  --shadow: 0 6px 24px rgba(122, 90, 56, 0.10);
  --radius: 22px;
  --bg-glow1: #FFEAD2;
  --bg-glow2: #FBE7EE;
  --awake-1: #FFE9C9;
  --awake-2: #FFD9B3;
  --pill-sleep: #EDEDFA;
  --pill-tapszer: #FFF0DA;
  --pill-etel: #EAF4E4;
  --dur-ink: #565988;
  --soft: #FFF0E5;
  --soft-msg: #FFF3EA;
  --del-bg: #FBE9E4;
  --del-ink: #C0503E;
  --toast-bg: #4A3B2F;
  --toast-ink: #FFF8EC;
}

/* dark theme tokens — applied when the system is dark (and not overridden
   to light), or when the user picked dark with the toggle */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #211B16;
    --card: #2E2721;
    --ink: #F1E7D8;
    --muted: #A8937E;
    --line: #3E342A;
    --peach: #E8926B;
    --peach-deep: #D97B52;
    --honey: #D69A4A;
    --honey-deep: #B97F33;
    --night-1: #5A5D93;
    --night-2: #3E4168;
    --cream: #29221C;
    --shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
    --bg-glow1: #2C2216;
    --bg-glow2: #2A1F26;
    --awake-1: #46351F;
    --awake-2: #382A1A;
    --pill-sleep: #383853;
    --pill-tapszer: #46341D;
    --pill-etel: #2F3D28;
    --dur-ink: #A9ACDD;
    --soft: #3D2E23;
    --soft-msg: #382B20;
    --del-bg: #4A2B24;
    --del-ink: #F0967F;
    --toast-bg: #F1E7D8;
    --toast-ink: #332A22;
  }
}

:root[data-theme="dark"] {
  --bg: #211B16;
  --card: #2E2721;
  --ink: #F1E7D8;
  --muted: #A8937E;
  --line: #3E342A;
  --peach: #E8926B;
  --peach-deep: #D97B52;
  --honey: #D69A4A;
  --honey-deep: #B97F33;
  --night-1: #5A5D93;
  --night-2: #3E4168;
  --cream: #29221C;
  --shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
  --bg-glow1: #2C2216;
  --bg-glow2: #2A1F26;
  --awake-1: #46351F;
  --awake-2: #382A1A;
  --pill-sleep: #383853;
  --pill-tapszer: #46341D;
  --pill-etel: #2F3D28;
  --dur-ink: #A9ACDD;
  --soft: #3D2E23;
  --soft-msg: #382B20;
  --del-bg: #4A2B24;
  --del-ink: #F0967F;
  --toast-bg: #F1E7D8;
  --toast-ink: #332A22;
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: 'Quicksand', -apple-system, 'Segoe UI', system-ui, sans-serif;
  background:
    radial-gradient(circle at 15% 0%, var(--bg-glow1) 0%, transparent 45%),
    radial-gradient(circle at 90% 15%, var(--bg-glow2) 0%, transparent 35%),
    var(--bg);
  color: var(--ink);
  min-height: 100vh;
  padding: max(14px, env(safe-area-inset-top)) 16px calc(40px + env(safe-area-inset-bottom));
  max-width: 520px;
  margin: 0 auto;
  -webkit-tap-highlight-color: transparent;
}

/* ---------- top bar ---------- */

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 4px 16px;
}

.topbar h1 { font-size: 24px; font-weight: 700; letter-spacing: 0.2px; }

.topbar-date {
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  margin-top: 2px;
}

.topbar-btns { display: flex; gap: 10px; }

.bell {
  font-size: 22px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 50%;
  width: 48px;
  height: 48px;
  box-shadow: var(--shadow);
  cursor: pointer;
}

/* ---------- status card ---------- */

.status-card {
  border-radius: var(--radius);
  padding: 26px 20px 24px;
  text-align: center;
  box-shadow: var(--shadow);
  transition: background 0.6s ease;
  position: relative;
  overflow: hidden;
}

.status-card.awake {
  background: linear-gradient(160deg, var(--awake-1) 0%, var(--awake-2) 100%);
}

.status-card.sleeping {
  background: linear-gradient(160deg, var(--night-1) 0%, var(--night-2) 100%);
  color: #FFF8EC;
}

.status-card.sleeping::before,
.status-card.sleeping::after {
  content: '✦';
  position: absolute;
  color: rgba(255, 248, 236, 0.55);
  font-size: 14px;
  animation: twinkle 2.8s ease-in-out infinite;
}
.status-card.sleeping::before { top: 18px; left: 26px; }
.status-card.sleeping::after { top: 40px; right: 34px; font-size: 10px; animation-delay: 1.4s; }

@keyframes twinkle {
  0%, 100% { opacity: 0.25; }
  50% { opacity: 1; }
}

.status-emoji { font-size: 46px; line-height: 1; margin-bottom: 8px; }

.status-title { font-size: 20px; font-weight: 700; }

.status-big {
  font-size: 34px;
  font-weight: 700;
  margin-top: 6px;
  letter-spacing: 0.3px;
}
.status-big:empty { display: none; }

.status-sub {
  margin-top: 8px;
  font-size: 14px;
  font-weight: 600;
  opacity: 0.75;
  white-space: pre-line;
  line-height: 1.5;
}

/* ---------- big action buttons ---------- */

.actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 16px;
}

.big-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  border: none;
  border-radius: var(--radius);
  padding: 18px;
  font-family: inherit;
  font-size: 20px;
  font-weight: 700;
  color: #FFF;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 0.1s ease, background 0.4s ease;
}

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

.big-btn-emoji { font-size: 26px; }

.sleep-btn { background: linear-gradient(135deg, #8B8ECC, #6E71AB); }
.sleep-btn.wake { background: linear-gradient(135deg, #FBBB5B, var(--peach-deep)); }

.feed-btn { background: linear-gradient(135deg, var(--honey), var(--honey-deep)); }

/* ---------- summary chips ---------- */

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

.chip {
  flex: 1;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  box-shadow: var(--shadow);
}

.chip-emoji { font-size: 20px; }

.chip-text { display: flex; flex-direction: column; align-items: center; }
.chip-text b { font-size: 16px; }
.chip-text small { color: var(--muted); font-size: 11px; font-weight: 600; }

/* ---------- log ---------- */

.log { margin-top: 26px; }

.log h2 { font-size: 19px; margin-bottom: 2px; }

.log-hint { color: var(--muted); font-size: 13px; font-weight: 500; margin-bottom: 12px; }

.day-header {
  font-size: 14px;
  font-weight: 700;
  color: var(--muted);
  margin: 18px 4px 8px;
}

.entry {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 13px 14px;
  margin-bottom: 8px;
  box-shadow: 0 2px 10px rgba(122, 90, 56, 0.06);
  cursor: pointer;
  transition: transform 0.1s ease;
}

.entry:active { transform: scale(0.98); }

.entry-emoji {
  font-size: 22px;
  width: 42px;
  height: 42px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.entry-emoji.sleep { background: var(--pill-sleep); }
.entry-emoji.tapszer { background: var(--pill-tapszer); }
.entry-emoji.etel { background: var(--pill-etel); }

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

.entry-title { font-weight: 700; font-size: 15px; }

.entry-sub {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  margin-top: 1px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.entry-dur {
  font-weight: 700;
  font-size: 14px;
  color: var(--dur-ink);
  flex-shrink: 0;
}

.entry-dur.ongoing { color: var(--peach-deep); }

.log-empty {
  text-align: center;
  color: var(--muted);
  font-weight: 600;
  padding: 30px 10px;
  background: var(--card);
  border-radius: var(--radius);
  border: 1px dashed var(--line);
}

/* ---------- message to the AI ---------- */

.ai-msg { margin-top: 26px; text-align: center; }

.msg-btn {
  width: 100%;
  border: 1.5px dashed var(--peach);
  border-radius: var(--radius);
  background: var(--soft-msg);
  padding: 15px;
  font-family: inherit;
  font-size: 16px;
  font-weight: 700;
  color: var(--peach-deep);
  cursor: pointer;
}

.msg-btn:active { transform: scale(0.98); }

.msg-hint {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  margin-top: 8px;
}

.msg-list { margin-top: 18px; max-height: 30vh; overflow-y: auto; }

.msg-list-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 8px;
}

.msg-item {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 12px;
  margin-bottom: 8px;
}

.msg-date { font-size: 11px; font-weight: 700; color: var(--muted); }

.msg-text { font-size: 14px; font-weight: 600; margin-top: 2px; white-space: pre-wrap; }

/* ---------- bottom sheets ---------- */

.backdrop {
  position: fixed;
  inset: 0;
  background: rgba(74, 59, 47, 0.4);
  z-index: 10;
  opacity: 1;
  transition: opacity 0.25s ease;
}

.backdrop.hidden { opacity: 0; pointer-events: none; }

.sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  max-width: 520px;
  margin: 0 auto;
  background: var(--cream);
  border-radius: 26px 26px 0 0;
  padding: 12px 20px calc(24px + env(safe-area-inset-bottom));
  z-index: 11;
  box-shadow: 0 -8px 30px rgba(74, 59, 47, 0.25);
  transform: translateY(0);
  transition: transform 0.3s cubic-bezier(0.2, 0.9, 0.3, 1);
}

.sheet.hidden { transform: translateY(110%); pointer-events: none; box-shadow: none; }

.sheet-handle {
  width: 44px;
  height: 5px;
  border-radius: 3px;
  background: var(--line);
  margin: 0 auto 14px;
}

.sheet h3 { font-size: 20px; margin-bottom: 4px; }

.sheet-info {
  color: var(--muted);
  font-weight: 600;
  font-size: 14px;
  margin-top: 2px;
}

.field {
  display: block;
  margin-top: 14px;
}

.field span {
  display: block;
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 6px;
}

.field span small { color: var(--muted); font-weight: 600; }

.field input,
.field textarea {
  width: 100%;
  font-family: inherit;
  font-size: 17px;
  font-weight: 600;
  color: var(--ink);
  background: var(--card);
  border: 1.5px solid var(--line);
  border-radius: 14px;
  padding: 13px 14px;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  min-height: 52px;
}

.field textarea { resize: vertical; }

.field input:focus,
.field textarea:focus { border-color: var(--peach); }

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

.check-row input { width: 22px; height: 22px; accent-color: var(--peach-deep); }

.kind-picker {
  display: flex;
  gap: 10px;
  margin-top: 14px;
}

.kind-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: 16px;
  padding: 14px 8px;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.kind-btn.selected {
  border-color: var(--peach-deep);
  background: var(--soft);
}

.kind-emoji { font-size: 26px; }

.sheet-save {
  width: 100%;
  margin-top: 20px;
  border: none;
  border-radius: 16px;
  padding: 16px;
  font-family: inherit;
  font-size: 18px;
  font-weight: 700;
  color: #FFF;
  background: linear-gradient(135deg, var(--peach), var(--peach-deep));
  box-shadow: var(--shadow);
  cursor: pointer;
}

.sheet-save:active { transform: scale(0.98); }

.sheet-delete {
  width: 100%;
  margin-top: 10px;
  border: none;
  border-radius: 16px;
  padding: 13px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  color: var(--del-ink);
  background: var(--del-bg);
  cursor: pointer;
}

.sheet-delete.confirm { background: #C0503E; color: #FFF; }

.hidden { display: none !important; }
.sheet.hidden { display: block !important; }
.backdrop.hidden { display: block !important; }

/* ---------- PIN lock screen ---------- */

.lock {
  position: fixed;
  inset: 0;
  z-index: 40;
  background:
    radial-gradient(circle at 15% 0%, var(--bg-glow1) 0%, transparent 45%),
    radial-gradient(circle at 90% 15%, var(--bg-glow2) 0%, transparent 35%),
    var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.lock.hidden { display: none !important; }

.lock-inner {
  text-align: center;
  width: 100%;
  max-width: 320px;
}

.lock-emoji { font-size: 56px; }

.lock-inner h2 { font-size: 24px; margin-top: 10px; }

.lock-inner p {
  color: var(--muted);
  font-weight: 600;
  font-size: 15px;
  margin-top: 4px;
}

.lock-dots {
  display: flex;
  justify-content: center;
  gap: 14px;
  margin: 22px 0 26px;
  min-height: 16px;
}

.lock-dots .dot {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  border: 2px solid var(--peach-deep);
  background: transparent;
  transition: background 0.12s ease;
}

.lock-dots .dot.filled { background: var(--peach-deep); }

.lock-dots.error { animation: shake 0.4s ease; }

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-10px); }
  40% { transform: translateX(10px); }
  60% { transform: translateX(-7px); }
  80% { transform: translateX(7px); }
}

.keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.key {
  height: 68px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--card);
  font-family: inherit;
  font-size: 26px;
  font-weight: 700;
  color: var(--ink);
  cursor: pointer;
  box-shadow: 0 3px 12px rgba(122, 90, 56, 0.08);
}

.key:active { transform: scale(0.94); }

.key-soft { font-size: 22px; color: var(--muted); }

.key-ok {
  background: linear-gradient(135deg, var(--peach), var(--peach-deep));
  color: #FFF;
  border: none;
}

/* ---------- toast ---------- */

.toast {
  position: fixed;
  bottom: calc(24px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  background: var(--toast-bg);
  color: var(--toast-ink);
  font-weight: 700;
  font-size: 15px;
  padding: 12px 22px;
  border-radius: 30px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.25);
  z-index: 60;
  opacity: 1;
  transition: opacity 0.3s ease;
  max-width: 85vw;
  text-align: center;
}

.toast.hidden { opacity: 0; pointer-events: none; display: block !important; }
