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

:root {
  --bg: #1a1a1a;
  --surface: #242424;
  --surface2: #2e2e2e;
  --border: #3a3a3a;
  --text: #e8e8e8;
  --text-dim: #888;
  --accent: #4a9eff;
  --user-bg: #1e3a5f;
  --assistant-bg: #242424;
  --thinking-bg: #1e2820;
  --thinking-text: #7fb87f;
  --approval-bg: #2e2416;
  --approval-border: #7a5c1a;
  --nav-height: 68px;
  --header-height: 56px;
  --danger: #e05252;
  --danger-bg: #3a1a1a;
  --success: #4caf50;
}

html, body, #root {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

#root {
  display: flex;
  justify-content: center;
}

.app {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 576px;
  min-width: 360px;
  height: 100%;
  margin: 0 8px;
}

/* ── Header ────────────────────────────────────────────── */
.header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  user-select: none;
}

.header img {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
}

.header-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.header-title {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.4px;
}

.header-meta {
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-version {
  font-size: 12px;
  color: var(--text-dim);
}

.header-tokens {
  font-size: 12px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

.header-tokens.tokens-warn   { color: #e6b800; }
.header-tokens.tokens-danger { color: #e05252; }

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-dot.enabled  { background: #4caf50; box-shadow: 0 0 4px #4caf5088; }
.status-dot.disabled { background: #f44336; box-shadow: 0 0 4px #f4433688; }

.header-info-hoverable {
  position: relative;
  border-radius: 8px;
  padding: 2px 6px;
  margin: -2px -6px;
}
.header-info-hoverable:hover { background: var(--surface2); }

.ctx-popup {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  min-width: 260px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  z-index: 200;
  cursor: default;
}

.ctx-popup-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-dim);
  margin-bottom: 6px;
}

.ctx-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 13px;
  padding: 2px 0;
  color: var(--text-dim);
  gap: 16px;
}
.ctx-row span:last-child {
  color: var(--text);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.ctx-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 10px 0;
}

.ctx-model-block {
  margin: 4px 0;
}

.ctx-model-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}

.ctx-model-detail {
  font-size: 12px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

.ctx-usage-totals {
  display: flex;
  gap: 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  margin-top: 4px;
  padding-top: 4px;
  border-top: 1px solid var(--border);
}

.header-user {
  margin-left: auto;
  font-size: 13px;
  color: var(--text-dim);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 4px 12px;
  cursor: pointer;
  transition: border-color 0.15s;
  flex-shrink: 0;
}

.header-user:hover { border-color: var(--accent); color: var(--text); }

/* Section headers for Lists and Journal */
.section-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.section-title {
  font-size: 18px;
  font-weight: 700;
  flex: 1;
}

.section-header .header-user {
  margin-left: 0;
}

.back-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-size: 15px;
  padding: 6px 2px;
  flex-shrink: 0;
}

.back-btn:hover { opacity: 0.8; }

.icon-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
}

.icon-btn:hover { background: var(--surface2); color: var(--text); }
.icon-btn.accent { color: var(--accent); }

.refresh-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  padding: 5px 10px;
  transition: border-color 0.15s, background 0.15s;
  flex-shrink: 0;
}
.refresh-btn:hover { border-color: var(--accent); background: var(--surface); }

/* ── Bottom nav ─────────────────────────────────────────── */
.bottom-nav {
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--border);
  height: var(--nav-height);
  flex-shrink: 0;
}

.nav-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  padding: 8px 4px;
  transition: color 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.nav-tab svg { width: 26px; height: 26px; }
.nav-tab.active { color: var(--accent); }
.nav-tab:hover:not(.active) { color: var(--text); }

@media (max-width: 480px) {
  .nav-tab svg { width: 18px; height: 18px; }
  .nav-tab { font-size: 11px; }
  .messages { padding: 12px; }
  .message { max-width: 92%; }
}

/* ── Views ──────────────────────────────────────────────── */
.view {
  display: none;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

.view.active { display: flex; }

.view-scroll {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* ── Login overlay ──────────────────────────────────────── */
.login-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  backdrop-filter: blur(4px);
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 36px 40px;
  width: min(420px, calc(100vw - 32px));
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.login-logo {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 4px;
}

.login-logo img {
  width: 52px;
  height: 52px;
  border-radius: 10px;
  object-fit: cover;
}

.login-logo-text {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.login-card h2 {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  margin: 0;
}

.login-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.login-field label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.login-field input {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
  padding: 10px 14px;
  outline: none;
  transition: border-color 0.15s;
}

.login-field input:focus { border-color: var(--accent); }
.login-field input.error { border-color: #f44336; }

.login-error {
  font-size: 13px;
  color: #f44336;
  min-height: 18px;
}

.login-btn {
  background: var(--accent);
  border: none;
  border-radius: 8px;
  color: #fff;
  cursor: pointer;
  font-size: 15px;
  font-weight: 600;
  padding: 11px;
  transition: opacity 0.15s;
}

.login-btn:disabled { opacity: 0.4; cursor: default; }
.login-btn:not(:disabled):hover { opacity: 0.85; }

.login-hint {
  font-size: 13px;
  color: var(--text-dim);
  margin: -8px 0 0;
}

.login-link {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-size: 13px;
  padding: 0;
  text-align: center;
  text-decoration: underline;
}
.login-link:hover { opacity: 0.8; }

/* ── Chat view ──────────────────────────────────────────── */
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scroll-behavior: smooth;
}

.message {
  display: flex;
  flex-direction: column;
  max-width: 82%;
}

.message.user, .message.assistant, .message.thinking, .message.approval {
  align-self: flex-start;
  align-items: flex-start;
}

.message-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-dim);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.message-bubble {
  padding: 10px 14px;
  border-radius: 12px;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.message.user .message-bubble {
  background: var(--user-bg);
  border-radius: 2px 12px 12px 12px;
}

.message.assistant .message-bubble {
  background: var(--assistant-bg);
  border: 1px solid var(--border);
  border-radius: 2px 12px 12px 12px;
}

.message.thinking .message-bubble {
  background: var(--thinking-bg);
  border: 1px solid #2a3a2a;
  border-radius: 2px 12px 12px 12px;
  color: var(--thinking-text);
  font-size: 13px;
  font-family: 'SF Mono', Consolas, monospace;
  white-space: pre-wrap;
  max-height: 200px;
  overflow-y: auto;
}

.thinking-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.thinking-elapsed {
  font-size: 12px;
  color: var(--text-dim);
  font-family: inherit;
}

.thinking-text {
  margin-top: 6px;
  opacity: 0.85;
}

.spinner {
  display: inline-block;
  width: 10px;
  height: 10px;
  border: 2px solid var(--text-dim);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}

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

.message.assistant .message-bubble p { margin-bottom: 0.6em; }
.message.assistant .message-bubble p:last-child { margin-bottom: 0; }
.message.assistant .message-bubble pre {
  background: var(--surface2);
  padding: 10px 12px;
  border-radius: 6px;
  overflow-x: auto;
  font-size: 13px;
  margin: 0.4em 0;
}
.message.assistant .message-bubble code {
  background: var(--surface2);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 13px;
}
.message.assistant .message-bubble pre code { background: none; padding: 0; }
.message.assistant .message-bubble h1,
.message.assistant .message-bubble h2,
.message.assistant .message-bubble h3 { margin: 0.6em 0 0.3em; font-size: 1em; font-weight: 700; }
.message.assistant .message-bubble ul,
.message.assistant .message-bubble ol { padding-left: 1.4em; margin: 0.3em 0; }
.message.assistant .message-bubble a { color: var(--accent); word-break: break-all; }
.message.assistant .message-bubble blockquote {
  border-left: 3px solid var(--border);
  padding-left: 0.8em;
  color: var(--text-dim);
  margin: 0.4em 0;
}

.message.approval .message-bubble {
  background: var(--approval-bg);
  border: 1px solid var(--approval-border);
  border-radius: 2px 12px 12px 12px;
}

.approval-question { margin-bottom: 10px; white-space: pre-wrap; }
.approval-buttons { display: flex; gap: 8px; }
.approval-buttons button {
  padding: 5px 16px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: opacity 0.15s;
}
.approval-buttons button:disabled { opacity: 0.4; cursor: default; }
.btn-yes { background: #2a6a3a; color: #a0e0b0; }
.btn-no  { background: #5a2a2a; color: #e0a0a0; }
.approval-answered { font-size: 12px; color: var(--text-dim); font-style: italic; }

.message-elapsed { font-size: 11px; color: var(--text-dim); margin-top: 4px; }

.input-area {
  display: flex;
  gap: 10px;
  padding: 14px 20px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.input-area textarea {
  flex: 1;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  line-height: 1.5;
  padding: 9px 12px;
  resize: none;
  outline: none;
  min-height: 40px;
  max-height: 160px;
  overflow-y: auto;
  transition: border-color 0.15s;
}
.input-area textarea:focus { border-color: var(--accent); }
.input-area textarea::placeholder { color: var(--text-dim); }

.send-btn {
  align-self: flex-end;
  background: var(--accent);
  border: none;
  border-radius: 8px;
  color: #fff;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  height: 40px;
  padding: 0 18px;
  transition: opacity 0.15s;
  flex-shrink: 0;
}
.send-btn:disabled { opacity: 0.4; cursor: default; }
.send-btn:not(:disabled):hover { opacity: 0.85; }

.empty-state {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  font-size: 14px;
}

/* ── Lists view ─────────────────────────────────────────── */
.list-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.12s;
  -webkit-tap-highlight-color: transparent;
}

.list-card:hover { background: var(--surface2); }
.list-card:active { background: var(--surface2); }

.list-card-info { flex: 1; min-width: 0; }

.list-card-name {
  font-size: 16px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.list-card-meta {
  font-size: 13px;
  color: var(--text-dim);
  margin-top: 2px;
}

.shared-with-label {
  cursor: pointer;
  text-decoration: underline dotted;
  text-underline-offset: 2px;
}

.shared-with-label:hover { color: var(--text); }

.list-detail-meta {
  font-size: 13px;
  color: var(--text-dim);
  padding: 6px 16px 0;
}

.badge {
  font-size: 12px;
  font-weight: 600;
  background: var(--accent);
  color: #fff;
  border-radius: 12px;
  padding: 2px 8px;
  flex-shrink: 0;
  min-width: 24px;
  text-align: center;
}

.badge.done { background: var(--surface2); color: var(--text-dim); }

.chevron {
  color: var(--text-dim);
  flex-shrink: 0;
}

.add-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.add-row input {
  flex: 1;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
  padding: 8px 12px;
  outline: none;
  transition: border-color 0.15s;
}
.add-row input:focus { border-color: var(--accent); }
.add-row input::placeholder { color: var(--text-dim); }

.add-row .add-btn {
  background: var(--accent);
  border: none;
  border-radius: 8px;
  color: #fff;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  height: 38px;
  padding: 0 16px;
  transition: opacity 0.15s;
  flex-shrink: 0;
}
.add-row .add-btn:disabled { opacity: 0.4; cursor: default; }
.add-row .add-btn:not(:disabled):hover { opacity: 0.85; }

.add-trigger {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  color: var(--accent);
  cursor: pointer;
  font-size: 15px;
  border-bottom: 1px solid var(--border);
  -webkit-tap-highlight-color: transparent;
}
.add-trigger:hover { background: var(--surface2); }

.item-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
}

.checkbox-btn {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: none;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s, background 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.checkbox-btn:hover { border-color: var(--accent); }
.checkbox-btn.checked {
  background: var(--accent);
  border-color: var(--accent);
}

.item-text {
  flex: 1;
  font-size: 15px;
  word-break: break-word;
}

.item-text.done {
  text-decoration: line-through;
  color: var(--text-dim);
}

.item-meta {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 2px;
}

.delete-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.15s, background 0.15s, color 0.15s;
  flex-shrink: 0;
}
.item-row:hover .delete-btn,
.item-row:focus-within .delete-btn { opacity: 1; }
.delete-btn:hover { background: var(--danger-bg); color: var(--danger); }

.section-divider {
  padding: 8px 16px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.item-input-area {
  display: flex;
  gap: 10px;
  padding: 12px 16px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.item-input-area input {
  flex: 1;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
  padding: 9px 12px;
  outline: none;
  transition: border-color 0.15s;
}
.item-input-area input:focus { border-color: var(--accent); }
.item-input-area input::placeholder { color: var(--text-dim); }

.item-input-area .add-btn {
  background: var(--accent);
  border: none;
  border-radius: 8px;
  color: #fff;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  height: 40px;
  padding: 0 16px;
  transition: opacity 0.15s;
  flex-shrink: 0;
}
.item-input-area .add-btn:disabled { opacity: 0.4; cursor: default; }
.item-input-area .add-btn:not(:disabled):hover { opacity: 0.85; }

/* ── Action sheet ───────────────────────────────────────── */
.overlay-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 100;
}

.action-sheet {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: min(100%, 640px);
  background: var(--surface);
  border-top: 1px solid var(--border);
  border-radius: 16px 16px 0 0;
  padding: 8px 0 env(safe-area-inset-bottom, 0);
  z-index: 101;
}

.action-sheet-title {
  padding: 12px 20px 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}

.action-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 20px;
  cursor: pointer;
  font-size: 16px;
  background: none;
  border: none;
  width: 100%;
  text-align: left;
  color: var(--text);
  transition: background 0.12s;
  -webkit-tap-highlight-color: transparent;
}
.action-item:hover { background: var(--surface2); }
.action-item.danger { color: var(--danger); }

/* Inline rename input */
.rename-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
}
.rename-row input {
  flex: 1;
  background: var(--surface2);
  border: 1px solid var(--accent);
  border-radius: 8px;
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
  padding: 8px 12px;
  outline: none;
}
.rename-row .save-btn {
  background: var(--accent);
  border: none;
  border-radius: 8px;
  color: #fff;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  height: 36px;
  padding: 0 14px;
}
.rename-row .cancel-btn {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 14px;
  height: 36px;
  padding: 0 12px;
}

/* Share modal */
.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 150;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.6);
}

.modal-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px 16px 0 0;
  padding: 20px 20px env(safe-area-inset-bottom, 20px);
  width: min(100%, 640px);
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-height: 80vh;
  overflow-y: auto;
  z-index: 1;
}

.modal-title {
  font-size: 17px;
  font-weight: 700;
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: var(--surface2);
  border: none;
  border-radius: 50%;
  color: var(--text-dim);
  cursor: pointer;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}
.modal-close:hover { color: var(--text); }

.share-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.share-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 4px 10px 4px 12px;
  font-size: 13px;
}

.share-chip button {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 14px;
  padding: 0;
  line-height: 1;
}
.share-chip button:hover { color: var(--danger); }

/* ── Confirm dialog ─────────────────────────────────────── */
.confirm-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 250;
}

.confirm-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.6);
}

.confirm-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px 20px 20px;
  width: min(300px, calc(100vw - 40px));
  display: flex;
  flex-direction: column;
  gap: 20px;
  z-index: 1;
}

.confirm-message {
  font-size: 15px;
  color: var(--text);
  text-align: center;
  line-height: 1.5;
}

.confirm-actions {
  display: flex;
  gap: 8px;
}

.confirm-actions .cancel-btn {
  flex: 1;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  text-align: center;
}

.confirm-delete-btn {
  flex: 1;
  background: var(--danger-bg);
  border: 1px solid var(--danger);
  border-radius: 8px;
  color: var(--danger);
  cursor: pointer;
  font-size: 15px;
  font-weight: 600;
  padding: 8px 12px;
  transition: background 0.15s;
}
.confirm-delete-btn:hover { background: #5a2020; }

/* ── Journal view ───────────────────────────────────────── */
.search-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.search-bar input {
  flex: 1;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
  padding: 8px 12px;
  outline: none;
  transition: border-color 0.15s;
}
.search-bar input:focus { border-color: var(--accent); }
.search-bar input::placeholder { color: var(--text-dim); }

.search-bar .clear-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 18px;
  padding: 4px;
  transition: color 0.15s;
}
.search-bar .clear-btn:hover { color: var(--text); }

.entry-card {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.12s;
  -webkit-tap-highlight-color: transparent;
}
.entry-card:hover { background: var(--surface2); }

.entry-timestamp {
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 4px;
}

.entry-text {
  font-size: 15px;
  line-height: 1.6;
  word-break: break-word;
  white-space: pre-wrap;
}

.journal-date-divider {
  padding: 8px 16px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 1;
}

.load-more-btn {
  display: block;
  width: 100%;
  padding: 16px;
  background: none;
  border: none;
  border-top: 1px solid var(--border);
  color: var(--accent);
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  text-align: center;
  transition: background 0.12s;
}
.load-more-btn:hover { background: var(--surface2); }

/* FAB */
.fab {
  position: absolute;
  bottom: 16px;
  right: 16px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
  color: #fff;
  font-size: 24px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(74,158,255,0.4);
  transition: transform 0.15s, box-shadow 0.15s;
  z-index: 10;
  -webkit-tap-highlight-color: transparent;
}
.fab:hover { transform: scale(1.08); box-shadow: 0 6px 20px rgba(74,158,255,0.5); }
.fab:active { transform: scale(0.95); }

/* Entry editor modal */
.entry-modal {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  z-index: 150;
}

.entry-modal-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.entry-modal-title {
  flex: 1;
  font-size: 17px;
  font-weight: 700;
}

.entry-modal-actions {
  display: flex;
  gap: 8px;
}

.cancel-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 15px;
  padding: 6px 12px;
  border-radius: 8px;
}
.cancel-btn:hover { background: var(--surface2); color: var(--text); }

.save-btn-primary {
  background: var(--accent);
  border: none;
  border-radius: 8px;
  color: #fff;
  cursor: pointer;
  font-size: 15px;
  font-weight: 600;
  padding: 6px 16px;
}
.save-btn-primary:disabled { opacity: 0.4; cursor: default; }
.save-btn-primary:not(:disabled):hover { opacity: 0.85; }

.entry-textarea {
  flex: 1;
  background: var(--bg);
  border: none;
  color: var(--text);
  font-family: inherit;
  font-size: 16px;
  line-height: 1.7;
  padding: 20px 16px;
  resize: none;
  outline: none;
}
.entry-textarea::placeholder { color: var(--text-dim); }

.entry-modal-meta {
  padding: 8px 16px 12px;
  font-size: 12px;
  color: var(--text-dim);
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  gap: 12px;
  flex-shrink: 0;
}

.entry-delete-btn {
  background: none;
  border: none;
  color: var(--danger);
  cursor: pointer;
  font-size: 13px;
  padding: 0;
}
.entry-delete-btn:hover { opacity: 0.8; }

/* Journal empty / loading states */
.journal-empty {
  padding: 40px 16px;
  text-align: center;
  color: var(--text-dim);
  font-size: 15px;
}

/* Relative wrapper for views that need FAB */
.view-relative {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}
