/* ── Reset & Base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0f0f0f;
  --surface: #1a1a1a;
  --border: #2e2e2e;
  --text: #e0e0e0;
  --muted: #7a7a7a;
  --accent: #d4d4d4;
  --danger: #c94040;
  --timer-large: clamp(4rem, 18vw, 9rem);
  --radius: 4px;
  --font: 'Inter', 'Helvetica Neue', Arial, sans-serif;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ── Layout ───────────────────────────────────────────────────────────────── */
.screen {
  display: none;
  flex-direction: column;
  min-height: 100vh;
  padding: 2rem 1.5rem;
  max-width: 520px;
  margin: 0 auto;
}
.screen.active { display: flex; }

.screen-center {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

/* ── Typography ───────────────────────────────────────────────────────────── */
h1 { font-size: 1.35rem; font-weight: 500; letter-spacing: -0.01em; margin-bottom: 0.35rem; }
h2 { font-size: 1.1rem; font-weight: 500; margin-bottom: 0.25rem; }
p, label { font-size: 0.9rem; color: var(--muted); }
.subtext { font-size: 0.85rem; color: var(--muted); margin-top: 0.5rem; }
.error-msg { font-size: 0.82rem; color: var(--danger); margin-top: 0.4rem; min-height: 1.1rem; }

/* ── Form elements ────────────────────────────────────────────────────────── */
input[type="email"],
input[type="text"],
textarea {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.92rem;
  padding: 0.65rem 0.75rem;
  outline: none;
  transition: border-color 0.15s;
  resize: none;
}
input[type="email"]:focus,
input[type="text"]:focus,
textarea:focus { border-color: #555; }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
button, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.65rem 1.25rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.88rem;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.12s, border-color 0.12s;
}
button:hover, .btn:hover { background: #242424; border-color: #444; }

.btn-primary {
  background: var(--accent);
  color: #111;
  border-color: var(--accent);
  font-weight: 500;
}
.btn-primary:hover { background: #c5c5c5; border-color: #c5c5c5; }

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
  padding: 0.4rem 0;
}
.btn-ghost:hover { color: var(--text); background: transparent; }

.btn-danger { border-color: var(--danger); color: var(--danger); }
.btn-danger:hover { background: #1f1414; }

/* ── Segmented control ────────────────────────────────────────────────────── */
.segmented {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}
.segmented button {
  flex: 1;
  padding: 0.55rem 0;
}
.segmented button.selected {
  background: var(--accent);
  color: #111;
  border-color: var(--accent);
  font-weight: 500;
}

/* ── Field group ──────────────────────────────────────────────────────────── */
.field-group {
  margin-bottom: 1.25rem;
}
.field-label {
  display: block;
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: 0.4rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.field-helper {
  font-size: 0.8rem;
  color: #666;
  margin-top: 0.35rem;
  line-height: 1.4;
}
.char-counter {
  font-size: 0.78rem;
  color: #555;
  text-align: right;
  margin-top: 0.2rem;
}
.char-counter.warn { color: var(--danger); }

/* ── Divider ──────────────────────────────────────────────────────────────── */
.divider { border: none; border-top: 1px solid var(--border); margin: 1.5rem 0; }

/* ── Header bar ───────────────────────────────────────────────────────────── */
.screen-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 1.5rem;
}
.screen-title { font-size: 0.85rem; color: var(--muted); letter-spacing: 0.05em; text-transform: uppercase; }

/* ── Status copy ──────────────────────────────────────────────────────────── */
.status-header {
  font-size: 1.1rem;
  font-weight: 500;
  margin-bottom: 0.5rem;
}
.status-sub {
  font-size: 0.88rem;
  color: var(--muted);
}

/* ── Alias tag ────────────────────────────────────────────────────────────── */
.alias-tag {
  font-family: 'SF Mono', 'Fira Code', 'Courier New', monospace;
  font-size: 0.85rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 0.15rem 0.4rem;
  color: var(--accent);
}

/* ── Focus timer ──────────────────────────────────────────────────────────── */
#focus-timer {
  font-size: var(--timer-large);
  font-weight: 300;
  letter-spacing: -0.03em;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  line-height: 1;
  margin: 1rem 0;
  transition: color 0.3s;
}
#focus-timer.pulse { animation: pulse 1s ease-in-out 3; }
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ── Start window timer ───────────────────────────────────────────────────── */
#start-timer {
  font-size: 2rem;
  font-weight: 300;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  margin-bottom: 1rem;
}

/* ── Open action display ──────────────────────────────────────────────────── */
.open-action-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  margin: 0.5rem 0;
  font-size: 0.9rem;
}
.open-action-label {
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.25rem;
}
.open-action-text { color: var(--text); }

/* ── Message area ─────────────────────────────────────────────────────────── */
.message-area {
  margin-top: 1rem;
  border-top: 1px solid var(--border);
  padding-top: 1rem;
}
.message-area h3 { font-size: 0.8rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 0.75rem; font-weight: 400; }

.message-list { margin-bottom: 0.75rem; min-height: 1.5rem; }
.message-item {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
}
.message-item .msg-alias { color: var(--accent); margin-right: 0.4rem; font-family: monospace; }
.message-sent-notice { font-size: 0.8rem; color: #555; font-style: italic; }

.message-input-row {
  display: flex;
  gap: 0.5rem;
}
.message-input-row input { flex: 1; }
.message-input-row button { flex-shrink: 0; }

/* ── Closing log presets ──────────────────────────────────────────────────── */
.preset-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.5rem;
}
.preset-btn {
  padding: 0.45rem 0.85rem;
  font-size: 0.82rem;
  border-radius: 20px;
}
.preset-btn.selected {
  background: var(--surface);
  border-color: #666;
  color: var(--text);
}

/* ── Confirmation toggle ──────────────────────────────────────────────────── */
.confirm-toggle {
  display: flex;
  gap: 0.75rem;
  margin-top: 0.5rem;
}
.confirm-btn {
  flex: 1;
  padding: 0.6rem;
  font-size: 0.88rem;
}
.confirm-btn.selected {
  background: var(--surface);
  border-color: #666;
  color: var(--text);
}

/* ── Overlay ──────────────────────────────────────────────────────────────── */
.overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  z-index: 100;
  align-items: center;
  justify-content: center;
}
.overlay.active { display: flex; }
.overlay-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1.75rem;
  max-width: 340px;
  width: 90%;
}
.overlay-box h3 { font-size: 1rem; margin-bottom: 0.5rem; }
.overlay-box p { font-size: 0.85rem; color: var(--muted); margin-bottom: 1.25rem; line-height: 1.5; }
.overlay-actions { display: flex; gap: 0.75rem; }
.overlay-actions button { flex: 1; }

/* ── Session history list ─────────────────────────────────────────────────── */
.history-list { list-style: none; }
.history-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  font-size: 0.88rem;
}
.history-item:hover .history-date { color: var(--text); }
.history-date { color: var(--muted); }
.history-meta { color: var(--muted); font-size: 0.82rem; text-align: right; }

/* ── Session detail ───────────────────────────────────────────────────────── */
.detail-row {
  display: flex;
  justify-content: space-between;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.88rem;
}
.detail-label { color: var(--muted); }
.detail-value { color: var(--text); text-align: right; max-width: 60%; word-break: break-word; }

/* ── Utility ──────────────────────────────────────────────────────────────── */
.hidden { display: none !important; }
.text-muted { color: var(--muted); }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.w-full { width: 100%; }
