:root {
  --bg: #050505;
  --bg-elevated: #101010;
  --border-subtle: #222222;
  --text-main: #f7f7f7;
  --text-muted: #a0a0a0;
  --accent: #ffffff;
  --accent-soft: rgba(255, 255, 255, 0.06);
  --radius-lg: 18px;
  --radius-sm: 10px;
  --shadow-soft: 0 16px 40px rgba(0, 0, 0, 0.6);
  --font-sans: system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Text",
    "Segoe UI", sans-serif;
}

/* Light theme overrides */
body.theme-light {
  --bg: #f6f4f0;
  --bg-elevated: #ffffff;
  --border-subtle: #d9d4cc;
  --text-main: #141414;
  --text-muted: #7a7165;
  --accent: #000000;
  --accent-soft: rgba(0, 0, 0, 0.035);
}

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

html,
body {
  margin: 0;
  padding: 0;
}

body.theme-dark {
  background-color: var(--bg);
  color: var(--text-main);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
}

body.theme-light {
  background-color: var(--bg);
  color: var(--text-main);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
}

body.focus-open {
  overflow: hidden;
}

.page {
  min-height: 100vh;
  max-width: 900px;
  margin: 0 auto;
  padding: 32px 18px 24px;
  display: flex;
  flex-direction: column;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 24px;
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.brand-name {
  font-size: 20px;
  letter-spacing: 0.12em;
  text-transform: lowercase;
  font-weight: 600;
}

.brand-tagline {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: lowercase;
}

/* Theme toggle */

.theme-toggle {
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
  background: rgba(255, 255, 255, 0.02);
  color: var(--text-main);
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  cursor: pointer;
}

body.theme-light .theme-toggle {
  background: rgba(0, 0, 0, 0.02);
}

/* base: hide icons & size them; theme rules show one at a time */
.theme-toggle .theme-icon {
  display: none;
  line-height: 1;
  align-items: center;
  justify-content: center;
}

/* dark mode: sun – slightly larger, nudged UP 1px */
body.theme-dark .theme-icon-sun {
  display: flex;
  font-size: 24px;
  width: 24px;
  height: 24px;
  transform: translateY(-1px);
}

/* light mode: moon (unchanged) */
body.theme-light .theme-icon-moon {
  display: flex;
  font-size: 18px;
  width: 18px;
  height: 18px;
}

.site-footer {
  margin-top: 32px;
  padding-top: 16px;
  border-top: 1px solid var(--border-subtle);
  font-size: 12px;
  color: var(--text-muted);
}

/* Feed */

.feed {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.feed-loading,
.feed-error,
.feed-empty {
  font-size: 13px;
  color: var(--text-muted);
}

.card {
  background-color: var(--bg-elevated);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-soft);
}

/* Day groups */

.day-group {
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  background: radial-gradient(circle at top left, var(--accent-soft), transparent 65%);
  overflow: hidden;
}

.day-header {
  padding: 10px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  cursor: default;
}

body.theme-light .day-header {
  border-bottom: 1px solid rgba(0, 0, 0, 0.04);
}

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

.day-title {
  font-size: 13px;
  font-weight: 500;
  text-transform: lowercase;
}

.day-subtitle {
  font-size: 11px;
  color: var(--text-muted);
}

.day-toggle {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: lowercase;
  display: flex;
  align-items: center;
  gap: 4px;
}

.day-toggle-button {
  border-radius: 99px;
  padding: 4px 10px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: transparent;
  color: inherit;
  font-size: 10px;
  cursor: pointer;
}

body.theme-light .day-toggle-button {
  border: 1px solid rgba(0, 0, 0, 0.12);
}

.day-toggle-button span {
  transition: transform 0.15s ease;
}

.day-toggle-button[aria-expanded="false"] span {
  transform: rotate(-90deg);
}

/* Notes */

.day-body {
  padding: 8px 8px 10px;
}

.note-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.note-card {
  padding: 10px 10px 8px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(0, 0, 0, 0.2);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

body.theme-light .note-card {
  border: 1px solid rgba(0, 0, 0, 0.05);
  background: rgba(255, 255, 255, 0.85);
}

/* Collapsed behaviour for previous days */

.note-card.collapsible {
  cursor: pointer;
  gap: 0;
  justify-content: center; /* centres summary vertically when collapsed */
}

.note-card.collapsible .note-body {
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transform: translateY(-2px);
  transition: max-height 0.4s ease, opacity 0.4s ease, transform 0.4s ease;
  margin-top: 0; /* no extra space at bottom when collapsed */
}

.note-card.collapsible.expanded {
  justify-content: flex-start; /* normal top alignment when expanded */
}

.note-card.collapsible.expanded .note-body {
  max-height: 600px;
  opacity: 1;
  transform: translateY(0);
  margin-top: 8px; /* space between summary and body only when open */
}

.note-card.collapsible .note-card-summary {
  min-height: 36px;
}

/* Summary row */

.note-card-summary {
  display: flex;
  align-items: center;
  gap: 8px;
}

.note-summary-left {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  flex: 1 1 auto;
}

.note-summary-text {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}

.note-type-pill,
.note-status-pill {
  font-size: 10px;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.24);
}

body.theme-light .note-type-pill,
body.theme-light .note-status-pill {
  border: 1px solid rgba(0, 0, 0, 0.14);
}

.note-status-pill {
  font-weight: 500;
}

.note-time {
  font-size: 11px;
  color: var(--text-muted);
  flex-shrink: 0;
  text-align: right;
  white-space: nowrap;
  margin-left: 8px;
  display: flex;
  align-items: center; /* vertically centre digits & am/pm */
}

/* Focus cards: tweak spacing & vertical alignment vs close pill */
.note-card-focus .note-time {
  margin-right: 40px;      /* a bit closer to the × pill */
  position: relative;
  top: 2px;                /* slightly lower so it lines up visually */
}

/* Note body */

.note-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Slightly more breathing room for text in feed only */
.feed .note-text {
  padding: 0 6px;
}

#note-focus-overlay .note-text {
  padding: 0;
}

.note-text {
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-wrap;
}

.note-media img,
.note-media video {
  width: 100%;
  border-radius: 12px;
  display: block;
}

.note-media audio {
  width: 100%;
}

.note-media {
  border-radius: 12px;
  overflow: hidden;
}

/* Admin */

.admin-main {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.admin-form {
  padding: 18px 16px 16px;
  max-width: 480px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 12px;
}

label {
  font-size: 12px;
  text-transform: lowercase;
  color: var(--text-muted);
}

input[type="text"],
input[type="password"],
input[type="date"],
textarea,
select {
  background: #050505;
  color: var(--text-main);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  padding: 8px 10px;
  font-family: var(--font-sans);
  font-size: 13px;
}

body.theme-light input[type="text"],
body.theme-light input[type="password"],
body.theme-light input[type="date"],
body.theme-light textarea,
body.theme-light select {
  background: #ffffff;
  color: var(--text-main);
  border: 1px solid var(--border-subtle);
}

textarea {
  resize: vertical;
}

input[type="file"] {
  font-size: 12px;
  color: var(--text-muted);
}

.hint {
  font-size: 11px;
  color: var(--text-muted);
}

.char-counter {
  font-size: 11px;
  margin-top: 2px;
}

.char-counter-normal {
  color: var(--text-muted);
}

.char-counter-warn {
  color: #f29f58;
}

.char-counter-max {
  color: #ff4b4b;
}

.button-primary {
  margin-top: 8px;
  border: none;
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 13px;
  text-transform: lowercase;
  background: linear-gradient(135deg, #ffffff, #aaaaaa);
  color: #000000;
  cursor: pointer;
  align-self: flex-start;
}

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

.status {
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-muted);
}

/* Focus / lightbox mode (today-only) */

#note-focus-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: none;
}

#note-focus-overlay.active {
  display: flex;
  align-items: center;
  justify-content: center;
}

.note-focus-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.8); /* darker for more focus */
  backdrop-filter: blur(10px);
}

.note-focus-modal {
  position: relative;
  max-width: 640px;
  width: 100%;
  margin: 16px;
  background: var(--bg-elevated);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  padding: 12px 14px 12px;
  max-height: 75vh;          /* never more than ~75% viewport height */
  overflow-y: auto;
}

/* IMAGE FOCUS: full-width image, header separated and not overlapped */
#note-focus-overlay .note-focus-modal:has(.note-media img) {
  max-width: 100vw;
  width: 100vw;
  margin: 16px 0;
  border-radius: 0;
}

/* give a bit more space before the image in image-focus mode */
#note-focus-overlay .note-focus-modal:has(.note-media img) .note-card-summary {
  margin-bottom: 12px;
}

/* make the body with image ignore side padding so the image can hit edges */
#note-focus-overlay .note-focus-modal:has(.note-media img) .note-body:has(.note-media) {
  border: none;
  background: transparent;
  padding: 0;
  margin: 0 -14px 0; /* cancel 14px side padding so image is edge-to-edge */
}

/* full-width image, no rounding in focus mode */
#note-focus-overlay .note-focus-modal:has(.note-media img) .note-media img {
  display: block;
  width: 100vw;
  max-width: 100vw;
  border-radius: 0;
}

/* nuke any old card border in overlay completely */
#note-focus-overlay .note-card {
  border: none !important;
  box-shadow: none !important;
  background: transparent;
}

.note-focus-close {
  position: absolute;
  top: 10px;
  right: 8px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: var(--text-muted);
  font-size: 16px;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transform: translateY(-1px); /* raise the “x” slightly in its pill */
}

/* Light mode: no grey fill, just outline */
body.theme-light .note-focus-close {
  background: transparent;
  border: 1px solid var(--text-muted);
}

.note-focus-close:focus {
  outline: none;
}

/* outer shell for card inside modal */
.note-card-focus {
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 0;
}

/* header row inside modal: small gap before body border */
#note-focus-overlay .note-card-summary {
  margin-bottom: 8px;
}

/* main bordered body box under header (text/audio focus) */
#note-focus-overlay .note-body {
  border-radius: 18px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-elevated);
  padding: 12px 12px 10px;
}

/* light-mode tweak for focus body */
body.theme-light #note-focus-overlay .note-body {
  border: 1px solid rgba(0, 0, 0, 0.07);
  background: #ffffff;
}

/* image notes in focus mode: body styling handled by image-specific rule above */

/* Utility */

@media (max-width: 600px) {
  .page {
    padding: 20px 12px 18px;
  }

  .brand-name {
    font-size: 18px;
  }

  .day-header {
    padding: 8px 12px;
  }

  .day-body {
    padding: 8px 6px 8px;
  }
}
