/* ---------------------------------------------------------------------
   Digital Diary — "writing desk at night" design system
   navy study (spine + list) opening onto a warm parchment page (editor)
   --------------------------------------------------------------------- */

:root {
  --navy-deep: #12141d;
  --navy: #1b1e2b;
  --navy-raised: #232739;
  --navy-line: #323752;

  --parchment: #efe7d2;
  --parchment-raised: #f6f0e0;
  --parchment-line: #cabf9c;

  --ink: #2a2721;
  --ink-soft: #55503f;

  --wax: #8c2f39;
  --wax-dark: #6e2028;
  --gold: #c9a227;
  --gold-soft: #e6cd7c;

  --text-light: #ece7da;
  --text-muted: #9b9686;

  --font-display: Fraunces, Georgia, 'Times New Roman', serif;
  --font-body: 'Source Serif Pro', Georgia, 'Times New Roman', serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', Consolas, monospace;

  --radius-card: 3px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--navy-deep);
  color: var(--text-light);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

button {
  font-family: inherit;
  cursor: pointer;
}
button:focus-visible,
input:focus-visible,
[contenteditable]:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

.app {
  display: grid;
  grid-template-columns: 272px 320px 1fr;
  height: 100vh;
  overflow: hidden;
}

/* ============================= SPINE ============================= */
.spine {
  background: var(--navy);
  border-right: 1px solid var(--navy-line);
  padding: 20px 18px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  overflow-y: auto;
}

.spine-header {
  display: flex;
  align-items: center;
  gap: 10px;
}
.seal-mark {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, var(--wax) 0%, var(--wax-dark) 75%);
  display: flex; align-items: center; justify-content: center;
  color: var(--gold-soft);
  font-size: 16px;
  box-shadow: 0 2px 4px rgba(0,0,0,.4);
  flex-shrink: 0;
}
.spine-header h1 {
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 600;
  letter-spacing: .01em;
  margin: 0;
  color: var(--text-light);
}

.search-wrap input {
  width: 100%;
  background: var(--navy-raised);
  border: 1px solid var(--navy-line);
  border-radius: 20px;
  color: var(--text-light);
  padding: 9px 14px;
  font-size: 13px;
  font-family: var(--font-body);
}
.search-wrap input::placeholder { color: var(--text-muted); }

.calendar-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.month-label {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--gold-soft);
}
.icon-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  line-height: 1;
  padding: 2px 8px;
  border-radius: 4px;
}
.icon-btn:hover { color: var(--text-light); background: var(--navy-raised); }

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 3px;
}
.cal-dow {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--text-muted);
  text-align: center;
  padding-bottom: 4px;
}
.cal-day {
  position: relative;
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  border-radius: 4px;
  color: var(--text-light);
  background: transparent;
  border: 1px solid transparent;
}
.cal-day.other-month { color: var(--navy-line); }
.cal-day.has-entry { background: var(--navy-raised); border-color: var(--navy-line); }
.cal-day.is-today { border-color: var(--gold); color: var(--gold-soft); font-weight: 600; }
.cal-day.is-selected { background: var(--wax); color: var(--text-light); }
.cal-day:hover { border-color: var(--gold-soft); cursor: pointer; }
.cal-day .dot {
  position: absolute;
  bottom: 2px;
  width: 3px; height: 3px;
  border-radius: 50%;
  background: var(--gold);
}

.ribbon-btn {
  margin-top: 10px;
  width: 100%;
  background: none;
  border: 1px dashed var(--navy-line);
  color: var(--text-muted);
  border-radius: 4px;
  padding: 6px;
  font-size: 11px;
  font-family: var(--font-mono);
  letter-spacing: .05em;
}
.ribbon-btn:hover { color: var(--gold-soft); border-color: var(--gold-soft); }

.filter-title {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.tag-filter-list, .mood-filter-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.chip {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 3px 9px;
  border-radius: 20px;
  border: 1px solid var(--navy-line);
  color: var(--text-muted);
  background: var(--navy-raised);
}
.chip:hover { color: var(--text-light); border-color: var(--gold-soft); }
.chip.active {
  background: var(--wax);
  border-color: var(--wax);
  color: var(--text-light);
}

.spine-footer {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid var(--navy-line);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.footer-actions { display: flex; flex-direction: column; gap: 4px; }
.text-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 12px;
  text-align: left;
  padding: 3px 0;
  font-family: var(--font-body);
}
.text-btn:hover { color: var(--gold-soft); }
.text-btn.danger:hover { color: #d9666f; }

/* ============================ LIST PANE ============================ */
.list-pane {
  background: var(--navy-deep);
  border-right: 1px solid var(--navy-line);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.list-pane-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 16px 12px;
  font-family: var(--font-display);
  font-size: 15px;
  color: var(--text-light);
  border-bottom: 1px solid var(--navy-line);
}
.new-entry-btn {
  background: var(--navy-raised);
  border: 1px solid var(--navy-line);
  color: var(--gold-soft);
  font-size: 11px;
  font-family: var(--font-mono);
  padding: 6px 10px;
  border-radius: 4px;
}
.new-entry-btn:hover { border-color: var(--gold-soft); }

.entry-list {
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.entry-card {
  background: var(--navy-raised);
  border: 1px solid var(--navy-line);
  border-radius: var(--radius-card);
  padding: 12px 14px;
  cursor: pointer;
  transition: border-color .15s ease;
}
.entry-card:hover { border-color: var(--gold-soft); }
.entry-card.selected { border-color: var(--wax); background: #262a3d; }
.entry-card-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 4px;
}
.entry-card-date {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
  letter-spacing: .04em;
}
.entry-card-mood { font-size: 14px; }
.entry-card-title {
  font-family: var(--font-display);
  font-size: 14px;
  color: var(--text-light);
  margin-bottom: 4px;
}
.entry-card-snippet {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.entry-card-tags {
  margin-top: 6px;
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}
.entry-card-tags .chip { font-size: 10px; padding: 2px 7px; }

.list-empty {
  color: var(--text-muted);
  font-size: 13px;
  padding: 24px 12px;
  text-align: center;
}

/* ============================ EDITOR PANE ============================ */
.editor-pane {
  background: var(--parchment);
  color: var(--ink);
  overflow-y: auto;
  position: relative;
}

.empty-state.hidden {
  display: none;
}
.empty-state {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--ink-soft);
  gap: 10px;
}
.empty-mark { font-size: 34px; color: var(--wax); }

.editor {
  max-width: 720px;
  margin: 0 auto;
  padding: 40px 56px 60px 72px;
  position: relative;
}
.editor.hidden { display: none; }
/* ruled margin line, like a notebook page */
.editor::before {
  content: '';
  position: absolute;
  left: 48px;
  top: 0;
  bottom: 0;
  width: 1px;
  background: var(--wax);
  opacity: .35;
}

.editor-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}
.date-input {
  font-family: var(--font-mono);
  font-size: 12px;
  background: none;
  border: none;
  color: var(--ink-soft);
  letter-spacing: .04em;
}
.editor-actions { display: flex; gap: 14px; }
.editor-actions .text-btn { color: var(--ink-soft); }
.editor-actions .text-btn:hover { color: var(--wax); }

.title-input {
  width: 100%;
  border: none;
  background: none;
  font-family: var(--font-display);
  font-size: 30px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 14px;
}
.title-input::placeholder { color: var(--parchment-line); }

.mood-picker {
  display: flex;
  gap: 6px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.mood-option {
  font-size: 20px;
  background: none;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 3px 6px;
  opacity: .45;
  transition: opacity .15s ease, border-color .15s ease;
}
.mood-option:hover { opacity: .8; }
.mood-option.selected {
  opacity: 1;
  border-color: var(--wax);
  background: var(--parchment-raised);
}

.tag-editor {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-bottom: 20px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--parchment-line);
}
.tag-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.tag-chip {
  font-family: var(--font-mono);
  font-size: 11px;
  background: var(--parchment-raised);
  border: 1px solid var(--parchment-line);
  color: var(--ink-soft);
  border-radius: 20px;
  padding: 3px 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.tag-chip button {
  background: none;
  border: none;
  color: var(--wax);
  font-size: 12px;
  padding: 0;
  line-height: 1;
}
.tag-input {
  border: none;
  background: none;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink);
  flex: 1;
  min-width: 140px;
}
.tag-input::placeholder { color: var(--parchment-line); }

.format-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 12px;
}
.format-btn {
  background: var(--parchment-raised);
  border: 1px solid var(--parchment-line);
  color: var(--ink-soft);
  font-family: var(--font-body);
  font-size: 12.5px;
  padding: 5px 10px;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.format-btn:hover { color: var(--ink); border-color: var(--wax); }
.format-btn.active { background: var(--wax); border-color: var(--wax); color: var(--text-light); }
.format-divider {
  width: 1px;
  height: 18px;
  background: var(--parchment-line);
  margin: 0 4px;
}

.entry-content {
  min-height: 240px;
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.75;
  color: var(--ink);
  outline: none;
  margin-bottom: 20px;
}
.entry-content ul, .entry-content ol {
  margin: 0 0 1em;
  padding-left: 1.6em;
}
.entry-content li { margin-bottom: 0.3em; }
.entry-content:empty::before {
  content: attr(data-placeholder);
  color: var(--parchment-line);
}

.photo-zone {
  border-top: 1px solid var(--parchment-line);
  padding-top: 16px;
  margin-bottom: 24px;
}
.photo-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 10px;
}
.photo-thumb {
  width: 90px; height: 90px;
  object-fit: cover;
  border-radius: 2px;
  border: 4px solid var(--parchment-raised);
  box-shadow: 0 3px 6px rgba(0,0,0,.18);
  transform: rotate(-1.2deg);
}
.photo-thumb:nth-child(even) { transform: rotate(1.2deg); }
.photo-thumb-wrap { position: relative; }
.photo-remove {
  position: absolute;
  top: -6px; right: -6px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--wax);
  color: #fff;
  border: none;
  font-size: 11px;
  line-height: 1;
}

.save-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 14px;
}
.save-status {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-soft);
}
.seal-btn {
  background: radial-gradient(circle at 35% 30%, var(--wax) 0%, var(--wax-dark) 80%);
  color: var(--gold-soft);
  border: none;
  border-radius: 30px;
  padding: 12px 26px;
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: .02em;
  box-shadow: 0 3px 6px rgba(0,0,0,.25);
  transition: transform .08s ease, box-shadow .08s ease;
}
.seal-btn:hover { box-shadow: 0 4px 9px rgba(0,0,0,.3); }
.seal-btn:active {
  transform: scale(.94);
  box-shadow: 0 1px 2px rgba(0,0,0,.3);
}

/* generic visibility utility — used by both the login screen and the app shell */
.hidden { display: none !important; }

/* ============================ LOGIN SCREEN ============================ */
.login-screen {
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--navy-deep);
  background-image: radial-gradient(circle at 50% 20%, var(--navy) 0%, var(--navy-deep) 70%);
}
.login-card {
  text-align: center;
  max-width: 360px;
  padding: 40px 36px;
}
.login-card .seal-mark {
  width: 56px; height: 56px;
  font-size: 24px;
  margin: 0 auto 18px;
}
.login-card h1 {
  font-family: var(--font-display);
  font-size: 26px;
  color: var(--text-light);
  margin: 0 0 10px;
}
.login-card p {
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.6;
  margin: 0 0 26px;
}
.primary-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  background: var(--text-light);
  color: var(--navy-deep);
  border: none;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 14px;
  text-decoration: none;
  padding: 12px 22px;
  border-radius: 4px;
  transition: transform .08s ease;
  cursor: pointer;
}
.primary-btn:hover { transform: translateY(-1px); }

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-align: left;
  margin-bottom: 14px;
}
.auth-input {
  background: var(--navy-raised);
  border: 1px solid var(--navy-line);
  border-radius: 4px;
  color: var(--text-light);
  padding: 10px 12px;
  font-size: 14px;
  font-family: var(--font-body);
}
.auth-input::placeholder { color: var(--text-muted); }
.auth-input.hidden { display: none; }
.auth-error {
  color: #d9666f;
  font-size: 12.5px;
  min-height: 1em;
}
.auth-toggle {
  font-size: 12.5px;
  width: 100%;
  text-align: center;
}

/* ============================ ACCOUNT BAR ============================ */
.account-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--navy-line);
  margin-bottom: -6px;
}
.account-name {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 160px;
}
.account-bar form { margin: 0; }
.account-bar .text-btn { font-size: 11px; }

/* scrollbars, subtle */

/* ============================ MOBILE CONTROLS (hidden on desktop) ============================ */
.hamburger-btn { display: none; }
.back-btn { display: none; }
.mobile-backdrop { display: none; }

@media (max-width: 880px) {
  .app {
    grid-template-columns: 1fr;
    position: relative;
  }

  /* Spine becomes a slide-out drawer */
  .spine {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: 82vw;
    max-width: 300px;
    transform: translateX(-100%);
    transition: transform .22s ease;
    z-index: 50;
    box-shadow: 4px 0 24px rgba(0,0,0,.4);
  }
  .spine.mobile-open { transform: translateX(0); }

  .mobile-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 40;
  }
  .mobile-backdrop.visible { display: block; }

  .hamburger-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    margin-right: 4px;
  }

  /* Only one of list / editor shown at a time, switched via data-mobile-view */
  .list-pane, .editor-pane { grid-column: 1; width: 100%; }
  .list-pane { display: none; }
  .editor-pane { display: none; }
  .app[data-mobile-view="list"] .list-pane { display: flex; }
  .app[data-mobile-view="editor"] .editor-pane { display: block; }

  .back-btn {
    display: inline-block;
    margin-right: auto;
    font-size: 13px;
  }
  .editor-topline { justify-content: flex-start; gap: 14px; }
  .editor-actions { margin-left: auto; }

  .editor { padding: 24px 20px 40px 28px; }
  .editor::before { left: 14px; }
}

::-webkit-scrollbar { width: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--navy-line); border-radius: 5px; }
.editor-pane::-webkit-scrollbar-thumb { background: var(--parchment-line); }

@media (prefers-reduced-motion: reduce) {
  .seal-btn, .entry-card { transition: none; }
}
