/* Journal v2 — IBM Plex, three themes, hairline grid. No frameworks. */

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

[hidden] { display: none !important; }

/* ---------- themes ---------- */

[data-theme="light"] {
  --bg: #ffffff;
  --fg: #000000;
  --fg-muted: #555555;
  --border: #000000;
  --bg-overlay: rgba(255,255,255,0.95);
}
[data-theme="dark"] {
  --bg: #1a1a1a;
  --fg: #ffffff;
  --fg-muted: #888888;
  --border: #ffffff;
  --bg-overlay: rgba(26,26,26,0.95);
}
[data-theme="night"] {
  --bg: #0a0a0a;
  --fg: #cccccc;
  --fg-muted: #555555;
  --border: #333333;
  --bg-overlay: rgba(10,10,10,0.98);
}

/* ---------- core layout ---------- */

html { height: 100%; background: var(--bg); }
body {
  display: flex; flex-direction: column; height: 100%;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 14px; line-height: 20px;
  background: var(--bg); color: var(--fg);
  max-width: 428px; margin: 0 auto;
}
body.page-today { overflow: hidden; }
body.page-menu, body.page-list, body.page-tredict, body.page-rules { overflow-y: auto; display: block; }

/* ---------- topbar ---------- */

.topbar {
  display: flex; align-items: center;
  height: 60px; flex-shrink: 0;
  border-bottom: 1px solid var(--border);
  padding: 0 8px;
}
.topbar-date { flex: 1; text-align: center; text-transform: uppercase; }

/* ---------- icon buttons ---------- */

.icon-btn {
  width: 44px; height: 44px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: none; border: none; cursor: pointer; color: var(--fg);
  text-decoration: none;
}
.icon-btn svg { display: block; }

/* ---------- today grid ---------- */

/* Two equal columns so the centre divider lines up with the sun bar's.
   Both columns follow the same rhythm: three 67px bands. */
.grid {
  display: grid; grid-template-columns: 1fr 1fr;
  border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.grid-left {
  border-right: 1px solid var(--border); height: 201px;
  display: flex; flex-direction: column;
}
.exercise-zone {
  height: 134px; flex-shrink: 0; /* bands 1+2: label + triangle */
  display: flex; flex-direction: column; align-items: center;
}
.exercise-zone .cell-label {
  height: 67px; flex-shrink: 0;
  display: flex; align-items: center;
}
.grid-left .triangle { display: block; height: 67px; width: auto; flex-shrink: 0; }
.triangle.filled polygon { fill: currentColor; }
.rd-band { height: 67px; flex-shrink: 0; display: grid; grid-template-columns: 1fr 1fr; }
.rd-cell { display: flex; align-items: center; justify-content: center; }
.grid-right { display: flex; flex-direction: column; }
.grid-cell {
  height: 67px; display: flex; align-items: center; justify-content: center;
  border-bottom: 1px solid var(--border);
}
.grid-cell:last-child { border-bottom: none; }
.cell-label--intent { text-align: center; padding: 0 12px; }
.toggle-cell { cursor: pointer; -webkit-tap-highlight-color: transparent; user-select: none; }
.read-only .toggle-cell { cursor: default; }

/* ---------- counter stepper ---------- */

.counter { display: grid; grid-template-columns: 1fr 1fr 1fr; width: 100%; height: 100%; }
.counter-btn {
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; background: none; border: none; color: var(--fg);
  font-family: 'IBM Plex Mono', monospace; font-size: 14px;
  -webkit-tap-highlight-color: transparent;
}
.counter-btn:first-child { border-right: 1px solid var(--border); }
.counter-btn:last-child { border-left: 1px solid var(--border); }
.counter-btn:disabled { cursor: default; }
.counter-value { cursor: default; }

/* ---------- sunrise / sunset bar ---------- */

.sun-bar {
  display: grid; grid-template-columns: 1fr 1fr;
  height: 67px; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.sun-cell { display: flex; align-items: center; justify-content: center; gap: 8px; }
.sun-cell:first-child { border-right: 1px solid var(--border); }
.sun-cell svg { display: block; }

/* ---------- entries feed ---------- */

.feed { flex: 1; overflow-y: auto; padding: 16px; -webkit-overflow-scrolling: touch; }
.note { margin-bottom: 16px; }
.note-time { color: var(--fg-muted); margin-bottom: 4px; }
.note-text { font-family: 'IBM Plex Sans', sans-serif; font-size: 16px; line-height: 24px; }

/* ---------- check in ---------- */

.checkin-btn {
  flex-shrink: 0; height: 60px; width: 100%;
  display: flex; align-items: center; justify-content: center;
  border: none; border-top: 1px solid var(--border);
  background: var(--bg);
  color: var(--fg-muted); cursor: pointer;
  font-family: 'IBM Plex Mono', monospace; font-size: 14px;
  text-transform: uppercase;
  padding-bottom: env(safe-area-inset-bottom);
}

#checkin-bar {
  display: none; position: fixed; bottom: 0; left: 0; right: 0;
  max-width: 428px; margin: 0 auto;
  border-top: 1px solid var(--border);
  background: var(--bg);
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 50;
}
#checkin-bar.visible { display: flex; align-items: flex-start; }
#checkin-bar textarea {
  flex: 1; padding: 16px; border: none; background: var(--bg); color: var(--fg);
  font-family: 'IBM Plex Sans', sans-serif; font-size: 16px; line-height: 24px;
  resize: none; outline: none; min-height: 56px; max-height: 144px;
}
#checkin-bar .send-btn { margin: 12px 8px 0 0; }

/* ---------- strikethrough ---------- */

.strikethrough { text-decoration: line-through; }

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

.toast {
  position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%);
  background: var(--fg); color: var(--bg);
  font-family: 'IBM Plex Mono', monospace; font-size: 14px;
  padding: 12px 20px; white-space: nowrap;
  pointer-events: none; z-index: 1000;
  text-transform: uppercase;
}

/* ---------- calendar modal ---------- */

#calendar-modal {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  display: flex; align-items: center; justify-content: center; z-index: 100;
}
.calendar-card {
  background: var(--bg); border: 1px solid var(--border);
  width: 370px; max-width: calc(100vw - 32px); padding: 0;
}
.calendar-header {
  display: flex; align-items: center; height: 60px;
  border-bottom: 1px solid var(--border); padding: 0 8px;
}
.calendar-title { flex: 1; text-align: center; text-transform: uppercase; }
.calendar-body { padding: 14px; }
.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); }
.calendar-wd {
  height: 32px; display: flex; align-items: center; justify-content: center;
  color: var(--fg-muted); font-size: 14px;
}
.calendar-day {
  height: 48px; display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 14px; -webkit-tap-highlight-color: transparent;
}
.calendar-day.today { background: var(--fg); color: var(--bg); }
.calendar-day.empty { cursor: default; }
.calendar-day.empty, .calendar-day.no-entry { color: var(--fg-muted); }

/* ---------- menu ---------- */

.menu-row {
  display: flex; align-items: center; height: 60px;
  border-bottom: 1px solid var(--border); cursor: pointer;
  color: var(--fg); text-decoration: none;
  text-transform: uppercase;
  -webkit-tap-highlight-color: transparent; user-select: none;
}
.menu-row--header { cursor: default; }
.menu-row-spacer { width: 44px; flex-shrink: 0; }
.menu-row-label { flex: 1; padding-left: 8px; }
.menu-row-icon {
  width: 44px; height: 44px; margin-right: 8px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  color: var(--fg);
}
.menu-row-icon svg { display: block; }

/* ---------- entries / archive list ---------- */

.list { display: block; }
.entry-row {
  display: flex; align-items: stretch;
  border-bottom: 1px solid var(--border);
}
.entry-row-main {
  flex: 1; min-width: 0; padding: 16px;
  color: var(--fg); text-decoration: none; display: block;
}
.entry-row-head { display: flex; margin-bottom: 4px; }
.entry-row-date { width: 176px; flex-shrink: 0; }
.entry-row-time { color: var(--fg); }
.entry-row-preview {
  font-family: 'IBM Plex Sans', sans-serif; font-size: 16px; line-height: 24px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.entry-row-action {
  width: 60px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: none; border: none; border-left: 1px solid var(--border);
  color: var(--fg); cursor: pointer;
}

/* ---------- tredict token page ---------- */

.tredict-form { padding: 16px; }
.token-box {
  display: flex; align-items: stretch;
  border: 1px solid var(--border); height: 64px;
}
.token-box input {
  flex: 1; min-width: 0; border: none; outline: none;
  background: var(--bg); color: var(--fg);
  font-family: 'IBM Plex Mono', monospace; font-size: 14px;
  padding: 0 16px; text-transform: uppercase;
}
.token-box input::placeholder { color: var(--fg-muted); text-transform: uppercase; }
.token-send {
  width: 64px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: none; border: none; border-left: 1px solid var(--border);
  color: var(--fg); cursor: pointer;
}
.token-updated { margin-top: 16px; color: var(--fg-muted); text-transform: uppercase; }

/* ---------- rules page ---------- */

.rules { display: block; }
.rule-row {
  display: flex; align-items: flex-start; gap: 16px;
  padding: 16px; border-bottom: 1px solid var(--border);
}
.rule-label { width: 96px; flex-shrink: 0; padding-top: 2px; }
.rule-text {
  flex: 1; min-width: 0; outline: none;
  font-family: 'IBM Plex Sans', sans-serif; font-size: 16px; line-height: 24px;
}
.rule-text--static { color: var(--fg-muted); }
.page-rules .checkin-btn {
  position: fixed; bottom: 0; left: 0; right: 0;
  max-width: 428px; margin: 0 auto;
}
.page-rules .rules { padding-bottom: 76px; }

/* ---------- login ---------- */

.page-login { display: flex; }
.login {
  margin: auto; width: 100%; padding: 0 24px;
  display: flex; flex-direction: column;
}
.login h1 {
  font-size: 14px; font-weight: 400; letter-spacing: 0.08em;
  margin-bottom: 24px; text-align: center;
}
.login input {
  width: 100%; font-size: 16px; color: var(--fg); background: var(--bg);
  border: 1px solid var(--border); outline: none; padding: 16px;
  font-family: 'IBM Plex Mono', monospace;
}
.login button {
  width: 100%; margin-top: 16px; padding: 16px; font-size: 14px;
  background: var(--fg); color: var(--bg); border: none; cursor: pointer;
  font-family: 'IBM Plex Mono', monospace; text-transform: uppercase;
}
.login-error { color: var(--fg-muted); margin-top: 12px; text-align: center; }
