:root {
  --bg: #121212;
  --secondary: #b71c1c;
  --accent: #ffb300;
  --paper: #f3ecd8;
  --ink: #1234a0;
  --ink-dark: #0c2a7a;
  --ruled: rgba(60, 84, 150, 0.25);
}

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

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: #eee;
  -webkit-font-smoothing: antialiased;
}

.stage {
  position: relative;
  min-height: 100%;
  height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(circle at 30% 25%, rgba(60,60,60,0.6) 0%, transparent 50%),
    radial-gradient(circle at 70% 80%, rgba(40,40,40,0.7) 0%, transparent 45%),
    #0c0c0c;
}

.spotlight {
  position: absolute;
  top: -15%;
  left: 50%;
  transform: translateX(-50%);
  width: 130%;
  height: 70%;
  background: radial-gradient(circle, rgba(255,179,0,0.28) 0%, rgba(255,179,0,0.10) 40%, transparent 70%);
  filter: blur(6px);
  pointer-events: none;
  z-index: 0;
}

.notebook {
  position: relative;
  z-index: 1;
  flex: 1;
  margin: 0 auto;
  width: 100%;
  max-width: 480px;
  overflow: hidden;
  display: flex;
  box-shadow: 0 20px 50px rgba(0,0,0,0.8);
}

.spiral {
  width: 22px;
  background: #2a2a2a;
  background-image: repeating-linear-gradient(180deg, #3a3a3a 0 14px, #1c1c1c 14px 28px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding-top: 18px;
  position: relative;
  z-index: 3;
  flex-shrink: 0;
}

.ring {
  width: 16px;
  height: 14px;
  border-radius: 6px;
  background: #b8b8b8;
  background: linear-gradient(180deg, #e0e0e0, #8a8a8a);
  box-shadow: inset 0 0 3px rgba(0,0,0,0.6), 0 2px 3px rgba(0,0,0,0.5);
}

.page {
  flex: 1;
  overflow-y: auto;
  background: var(--paper);
  color: #333;
  background-image: linear-gradient(180deg, rgba(0,0,0,0) calc(100% - 1px), var(--ruled) calc(100% - 1px));
  background-size: 100% 32px;
  border-left: 1px solid rgba(0,0,0,0.2);
  padding-bottom: calc(env(safe-area-inset-bottom) + 0px);
}

main { padding: 20px 18px 200px; }

.view { display: none; animation: fade 0.2s ease; }
.view.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(6px);} to {opacity:1; transform:none;} }

.app-title {
  margin: 6px 0 0;
  font-size: 34px;
  letter-spacing: 1px;
  color: #1a1a1a;
  font-weight: 800;
}
.subtitle { margin: 0 0 18px; color: #8a8470; font-style: italic; font-size: 14px; }

.view-title {
  margin: 6px 0 12px;
  font-size: 26px;
  color: #1a1a1a;
  font-weight: 800;
}

.section-head {
  margin: 26px 0 8px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: #9a947e;
}

/* Knobs */
.knobs { display: flex; gap: 18px; margin: 6px 0 4px; }
.knob { flex: 1; text-align: center; }
.knob-head {
  width: 84px; height: 84px;
  margin: 0 auto 10px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #4a4a4a, #1a1a1a 60%, #0c0c0c);
  box-shadow:
    inset 0 0 8px rgba(0,0,0,0.9),
    inset 0 3px 10px rgba(255,255,255,0.08),
    0 8px 16px rgba(0,0,0,0.6);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #2c2c2c;
}
.knob-head::after {
  content: "";
  position: absolute;
  top: 8px; left: 50%;
  width: 3px; height: 12px;
  transform: translateX(-50%);
  background: var(--accent);
  border-radius: 2px;
}
.knob-number {
  font-size: 26px;
  font-weight: 800;
  color: var(--accent);
  text-shadow: 0 0 10px rgba(255,179,0,0.35), inset 0 0 4px rgba(0,0,0,0.8);
}
.tag {
  font-family: "Comic Sans MS", "Bradley Hand", cursive;
  font-size: 13px;
  color: #5c5644;
  transform: rotate(-3deg);
  display: inline-block;
}

/* Recent list */
.recent-list { list-style: none; margin: 0; padding: 0; }
.recent-list li {
  background: rgba(255,255,255,0.45);
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 8px;
  border-left: 4px solid var(--secondary);
  box-shadow: 0 2px 5px rgba(0,0,0,0.08);
}
.recent-title { font-weight: 700; color: #1a1a1a; }
.recent-meta { font-size: 13px; color: #77705c; margin-top: 3px; }

/* Buttons */
.quick-action {
  width: 100%;
  margin-top: 18px;
  padding: 14px;
  border: none;
  border-radius: 10px;
  background: linear-gradient(180deg, #d42121, var(--secondary));
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  box-shadow: 0 4px 10px rgba(183,28,28,0.4);
  cursor: pointer;
}
.btn {
  border: none;
  border-radius: 8px;
  padding: 11px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  background: #e6e0cc;
  color: #1a1a1a;
}
.btn.primary { background: linear-gradient(180deg, #d42121, var(--secondary)); color: #fff; }
.btn.danger { background: var(--secondary); color: #fff; }
.btn:disabled { opacity: 0.45; cursor: default; }

/* Log */
.search-wrap { margin-bottom: 14px; }
.search-wrap input {
  width: 100%;
  padding: 11px 14px;
  border-radius: 8px;
  border: 1px solid #d5cdb4;
  background: rgba(255,255,255,0.6);
  font-size: 15px;
  color: #1a1a1a;
}
.log-list { list-style: none; margin: 0; padding: 0; }
.entry {
  position: relative;
  padding: 12px 14px 12px 44px;
  margin-bottom: 6px;
  background: transparent;
  border-radius: 4px;
  overflow: hidden;
  cursor: pointer;
  transform: translateX(0);
  transition: transform 0.25s ease, opacity 0.25s ease, background 0.2s;
}
.entry .coffee {
  position: absolute;
  right: -12px; top: -6px;
  width: 64px; height: 64px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(140,100,50,0.18), rgba(140,100,50,0.05) 60%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}
.entry::before {
  content: "";
  position: absolute;
  left: 8px; top: 50%;
  transform: translateY(-50%);
  z-index: 1;
}
.entry .qnote {
  position: absolute;
  left: 6px; top: 50%;
  transform: translateY(-50%);
  width: 18px; height: 24px;
  z-index: 1;
}
.entry .qnote::before {
  content: "";
  position: absolute;
  left: 4px; top: 0;
  width: 14px; height: 11px;
  background: radial-gradient(ellipse at 30% 50%, #1f3a8a, var(--ink));
  transform: rotate(-18deg);
  border-radius: 60% 50% 40% 70%;
}
.entry .qnote::after {
  content: "";
  position: absolute;
  left: 15px; top: 0;
  width: 2px; height: 22px;
  background: var(--ink);
  border-radius: 1px;
}
.entry h3 {
  font-family: "Comic Sans MS", "Bradley Hand", cursive;
  color: var(--ink);
  margin: 0;
  font-size: 17px;
  position: relative;
  z-index: 1;
}
.entry .meta {
  font-family: "Comic Sans MS", "Bradley Hand", cursive;
  color: var(--ink-dark);
  font-size: 13px;
  margin-top: 2px;
  position: relative;
  z-index: 1;
}
.entry.swiping { background: rgba(183,28,28,0.12); }
.entry.swiping .swipe-hint { display: block; }
.entry .swipe-hint {
  display: none;
  position: absolute;
  right: 10px; top: 50%;
  transform: translateY(-50%);
  color: var(--secondary);
  font-size: 12px;
  font-weight: 700;
  z-index: 2;
}
.entry.gone { transform: translateX(-110%); opacity: 0; }

.empty { color: #8a8470; font-style: italic; text-align: center; padding: 20px 0; }

/* Timer */
.timer-status {
  text-align: center;
  font-size: 13px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: #9a947e;
  margin-bottom: 6px;
}
.timer-status.running { color: var(--secondary); font-weight: 700; }
.timer-display {
  text-align: center;
  font-size: 64px;
  font-weight: 800;
  letter-spacing: 2px;
  color: #1a1a1a;
  font-variant-numeric: tabular-nums;
  margin: 10px 0 20px;
}
.timer-display.running { color: var(--secondary); }
.timer-controls { display: flex; gap: 10px; justify-content: center; margin-bottom: 6px; }

/* Form */
.field { display: block; margin-bottom: 14px; }
.field > span {
  display: block;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: #8a8470;
  margin-bottom: 5px;
}
.field input, .field textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid #d5cdb4;
  border-radius: 8px;
  background: rgba(255,255,255,0.65);
  font-size: 16px;
  color: #1a1a1a;
}
.field .err { color: var(--secondary); font-size: 12px; font-style: normal; display: none; margin-top: 4px; }
.field.invalid input, .field.invalid textarea { border-color: var(--secondary); background: #fdeaea; }
.field.invalid .err { display: block; }
.form-actions { display: flex; gap: 10px; margin-top: 6px; }
.form-actions .btn { flex: 1; }

/* Tab bar */
.tab-bar {
  position: relative;
  z-index: 5;
  display: flex;
  flex-shrink: 0;
  background: rgba(10,10,10,0.92);
  border-top: 1px solid rgba(255,255,255,0.06);
  padding: 8px 6px calc(env(safe-area-inset-bottom) + 8px);
  justify-content: space-around;
}
.tab {
  background: none;
  border: none;
  color: #8a8a8a;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  cursor: pointer;
  padding: 4px 10px;
  flex: 1;
}
.tab .pick {
  width: 30px; height: 34px;
  background: #1b1b1b;
  background: radial-gradient(circle at 50% 35%, #2e2e2e, #0e0e0e 70%);
  clip-path: polygon(50% 0, 100% 38%, 100% 100%, 0 100%, 0 38%);
  display: block;
  box-shadow: inset 0 0 6px rgba(0,0,0,0.9), 0 3px 6px rgba(0,0,0,0.6);
  transition: all 0.3s ease;
}
.tab.active { color: var(--accent); }
.tab.active .pick {
  background:
    radial-gradient(circle at 50% 40%, #ffffff 0%, #ffe9b0 30%, #d9a83f 55%, #8a6a1f 90%);
  box-shadow:
    inset 0 0 10px rgba(255,255,255,0.6),
    inset 0 0 22px rgba(255,200,120,0.8),
    0 0 18px rgba(255,179,0,0.6);
  animation: glow 2.2s ease-in-out infinite;
}
.tab.active .tab-label { font-weight: 700; text-shadow: 0 0 8px rgba(255,179,0,0.6); }
@keyframes glow {
  0%, 100% { box-shadow: inset 0 0 10px rgba(255,255,255,0.5), inset 0 0 22px rgba(255,200,120,0.7), 0 0 14px rgba(255,179,0,0.5); }
  50% { box-shadow: inset 0 0 10px rgba(255,255,255,0.6), inset 0 0 26px rgba(255,210,140,0.9), 0 0 26px rgba(255,179,0,0.8); }
}

/* Modal */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: none;
  align-items: flex-end;
  justify-content: center;
  z-index: 50;
  padding-bottom: 60px;
}
.modal-mask.show { display: flex; }
.modal {
  background: #f3ecd8;
  border-radius: 14px;
  width: 90%;
  max-width: 380px;
  padding: 20px;
  color: #1a1a1a;
  box-shadow: 0 10px 40px rgba(0,0,0,0.5);
}
.modal-title { margin: 0 0 8px; font-weight: 800; font-size: 18px; }
.modal-text { margin: 0 0 18px; color: #666; font-size: 14px; }
.modal-actions { display: flex; gap: 10px; }
.modal-actions .btn { flex: 1; }