/* Private Diary styles (Agent C).
   Clean, calm, light, highly readable. System font stack, mobile-first, one quiet
   accent. No frameworks, no web fonts. Tasteful dark variant via prefers-color-scheme. */

:root {
  --bg: #fbfaf7;
  --surface: #ffffff;
  --surface-2: #f3f1ec;
  --text: #23211c;
  --text-dim: #6b675e;
  --border: #e4e0d8;
  --accent: #3f6d54;            /* one quiet accent (muted green) */
  --accent-text: #ffffff;
  --danger: #9a3a30;
  --radius: 12px;
  --tap: 48px;                  /* large tap targets */
  --maxw: 40rem;                /* comfortable reading line length */
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

/* The hidden attribute must win over the ID-selector display rules below
   (#lock-screen, #main, .view all set display, which otherwise out-specify the
   UA [hidden]{display:none} rule and leave both panels visible at once). */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
    Arial, "Apple Color Emoji", "Segoe UI Emoji", sans-serif;
  font-size: 17px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

#app {
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

button, input {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: none;
}

/* ---------- Lock / setup screen ---------- */

#lock-screen {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.lock-card {
  width: 100%;
  max-width: 22rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem 1.25rem;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.brand {
  margin: 0 0 0.25rem;
  font-size: 1.4rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.hint {
  margin: 0 0 1.25rem;
  color: var(--text-dim);
  font-size: 0.92rem;
}

.field {
  display: block;
  margin-bottom: 0.9rem;
}

.field-label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-bottom: 0.3rem;
}

input[type="password"],
input[type="text"],
input[type="search"] {
  width: 100%;
  min-height: var(--tap);
  padding: 0 0.85rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  outline: none;
}

input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(63, 109, 84, 0.15);
}

.primary {
  width: 100%;
  min-height: var(--tap);
  margin-top: 0.4rem;
  background: var(--accent);
  color: var(--accent-text);
  border-radius: 10px;
  font-weight: 600;
}

.primary:disabled { opacity: 0.6; cursor: default; }

/* ---------- Main ---------- */

#main {
  flex: 1;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  /* leave room for quick-add bar + nav fixed at bottom */
  padding-bottom: calc(var(--tap) + var(--tap) + 1.5rem + var(--safe-bottom));
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.9rem 1rem;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

#day-title {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.ghost {
  min-height: 40px;
  padding: 0 0.85rem;
  border-radius: 8px;
  color: var(--text-dim);
  border: 1px solid var(--border);
  background: var(--surface);
}

.view {
  padding: 0.5rem 1rem 0;
}

/* ---------- Notes (today / day) ---------- */

.notes,
.day-list,
.search-results {
  list-style: none;
  margin: 0;
  padding: 0;
}

.note {
  display: flex;
  gap: 0.75rem;
  padding: 0.7rem 0;
  border-bottom: 1px solid var(--border);
}

.note-time {
  flex: 0 0 auto;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  font-size: 0.92rem;
  padding-top: 0.05rem;
  min-width: 3.2rem;
}

.note-text {
  flex: 1 1 auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.empty {
  color: var(--text-dim);
  padding: 1.25rem 0;
  font-size: 0.95rem;
}

/* ---------- Day list ---------- */

.day-link {
  display: block;
  width: 100%;
  text-align: left;
  min-height: var(--tap);
  padding: 0 0.25rem;
  border-bottom: 1px solid var(--border);
  font-variant-numeric: tabular-nums;
}

.day-link:hover,
.result:hover { color: var(--accent); }

/* ---------- Search ---------- */

#search-input { margin-bottom: 0.75rem; }

.result {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  width: 100%;
  text-align: left;
  padding: 0.65rem 0.25rem;
  border-bottom: 1px solid var(--border);
}

.result-meta {
  color: var(--text-dim);
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
}

.result-text {
  white-space: pre-wrap;
  word-break: break-word;
}

/* ---------- Quick-add bar (primary action, reachable one-handed) ---------- */

.quick-add-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(var(--tap) + var(--safe-bottom));
  z-index: 6;
  padding: 0.5rem 1rem;
  background: var(--bg);
  border-top: 1px solid var(--border);
}

#quick-add {
  display: block;
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  min-height: var(--tap);
}

/* ---------- Bottom nav ---------- */

.nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 6;
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding-bottom: var(--safe-bottom);
}

.nav-btn {
  flex: 1 1 0;
  min-height: var(--tap);
  color: var(--text-dim);
  font-size: 0.9rem;
}

.nav-btn.active {
  color: var(--accent);
  font-weight: 600;
  box-shadow: inset 0 2px 0 var(--accent);
}

/* ---------- Badges + errors ---------- */

.mode-badge {
  position: fixed;
  top: 0.5rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  background: var(--surface-2);
  color: var(--text-dim);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.15rem 0.7rem;
  font-size: 0.74rem;
}

.error {
  position: fixed;
  left: 1rem;
  right: 1rem;
  bottom: calc(var(--tap) + var(--tap) + 1rem + var(--safe-bottom));
  z-index: 20;
  margin: 0 auto;
  max-width: var(--maxw);
  background: #fdecea;
  color: var(--danger);
  border: 1px solid #f3c9c4;
  border-radius: 10px;
  padding: 0.6rem 0.85rem;
  font-size: 0.9rem;
}

/* ---------- Dark variant ---------- */

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15140f;
    --surface: #1e1c16;
    --surface-2: #26241d;
    --text: #ece9e1;
    --text-dim: #9b968a;
    --border: #322f27;
    --accent: #7fb89a;
    --accent-text: #15140f;
    --danger: #e0857b;
  }

  input:focus {
    box-shadow: 0 0 0 3px rgba(127, 184, 154, 0.18);
  }

  .error {
    background: #2a1c19;
    border-color: #5a2e28;
  }

  .lock-card {
    box-shadow: none;
  }
}

/* ---------- Larger screens: a touch more breathing room ---------- */

@media (min-width: 600px) {
  body { font-size: 17px; }
  .view { padding-top: 0.75rem; }
}
