/* ============================================================
   Design system — clean, airy, forest-green accents
   ============================================================ */

:root {
  color-scheme: light;
  --primary:        #1a1a1a;
  --accent:         #1d6b35;
  --accent-hover:   #257d3f;
  --accent-light:   #e8f2eb;
  --accent-subtle:  rgba(29,107,53,0.07);
  --white:          #ffffff;
  --body-bg:        #f5f3ee;
  --card-bg:        #ffffff;
  --card-bg-hover:  #fcfdfb;
  --border:         #b9c2b2;
  --border-light:   #d7ddd0;
  --text:           #142410;
  --text-secondary: #33402f;
  --text-muted:     #5c6b5c;
  --error:          #c0392b;
  --error-bg:       #fdf0ef;
  --error-border:   #e8bab6;
  --success:        #27ae60;
  --badge-pink-bg:    #fce7f3;
  --badge-pink-text:  #db2777;
  --badge-amber-bg:   #fef3c7;
  --badge-amber-text: #d97706;
  --badge-yellow-bg:  #fef9c3;
  --badge-yellow-text:#a16207;
  --badge-green-bg:   #d1fae5;
  --badge-green-text: #059669;
  --badge-blue-bg:    #dbeafe;
  --badge-blue-text:  #2563eb;
  --badge-purple-bg:      #f5f3ff;
  --badge-purple-text:    #7c3aed;
  --badge-purple-border:  #ddd6fe;
  --radius-sm:      0;
  --radius-md:      0;
  --shadow-sm:      0 1px 2px rgba(0,0,0,0.05);
  --shadow-md:      0 2px 8px rgba(0,0,0,0.06);
  --font:           var(--font-serif);
  --font-serif:     'Source Serif 4', Charter, Georgia, 'Times New Roman', serif;
  --header-h:       56px;
  --max-width:      680px;
}

/* ── Dark mode ──
   Defaults to the OS/browser preference, with zero JS required — the block below applies
   whenever the system prefers dark, unless js/theme.js has stamped an explicit override
   onto <html data-theme="light">. The second block applies dark regardless of the system
   when js/theme.js has stamped data-theme="dark" instead. Both blocks carry the same
   values on purpose (nothing here should ever theme differently depending on which path
   activated it) — keep them in sync by hand if you touch one.
   --white stays fixed (it's used for text-on-accent-button, which needs to read the same
   in both themes, not for surfaces); the four spots that were misusing it as a surface
   colour now use --card-bg instead, above, so they pick up this override correctly. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --accent:         #3ecb7e;
    --accent-hover:   #55dc90;
    --accent-light:   #1b3324;
    --accent-subtle:  rgba(62,203,126,0.14);
    --body-bg:        #111411;
    --card-bg:        #1a1f1a;
    --card-bg-hover:  #212721;
    --border:         #3a453a;
    --border-light:   #2a302a;
    --text:           #e7ede4;
    --text-secondary: #b9c4b4;
    --text-muted:     #838f81;
    --error:          #e2574a;
    --error-bg:       #3a1f1c;
    --error-border:   #5c332e;
    --success:        #46c47f;
    --badge-pink-bg:    #4a1942;
    --badge-pink-text:  #f3a8d4;
    --badge-amber-bg:   #4a3212;
    --badge-amber-text: #fbc873;
    --badge-yellow-bg:  #453910;
    --badge-yellow-text:#f0d878;
    --badge-green-bg:   #0f3d2e;
    --badge-green-text: #7ee0b8;
    --badge-blue-bg:    #1e3a5f;
    --badge-blue-text:  #93c5fd;
    --badge-purple-bg:      #362a56;
    --badge-purple-text:    #c4b5fd;
    --badge-purple-border:  #4d3f78;
    --shadow-sm:      0 1px 2px rgba(0,0,0,0.4);
    --shadow-md:      0 2px 10px rgba(0,0,0,0.5);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --accent:         #3ecb7e;
  --accent-hover:   #55dc90;
  --accent-light:   #1b3324;
  --accent-subtle:  rgba(62,203,126,0.14);
  --body-bg:        #111411;
  --card-bg:        #1a1f1a;
  --card-bg-hover:  #212721;
  --border:         #3a453a;
  --border-light:   #2a302a;
  --text:           #e7ede4;
  --text-secondary: #b9c4b4;
  --text-muted:     #838f81;
  --error:          #e2574a;
  --error-bg:       #3a1f1c;
  --error-border:   #5c332e;
  --success:        #46c47f;
  --badge-pink-bg:    #4a1942;
  --badge-pink-text:  #f3a8d4;
  --badge-amber-bg:   #4a3212;
  --badge-amber-text: #fbc873;
  --badge-yellow-bg:  #453910;
  --badge-yellow-text:#f0d878;
  --badge-green-bg:   #0f3d2e;
  --badge-green-text: #7ee0b8;
  --badge-blue-bg:    #1e3a5f;
  --badge-blue-text:  #93c5fd;
  --badge-purple-bg:      #362a56;
  --badge-purple-text:    #c4b5fd;
  --badge-purple-border:  #4d3f78;
  --shadow-sm:      0 1px 2px rgba(0,0,0,0.4);
  --shadow-md:      0 2px 10px rgba(0,0,0,0.5);
}

/* ── Inline icon (replaces emoji glyphs) ── */
.icon-inline { vertical-align: -2px; margin-right: 4px; flex-shrink: 0; }

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-font-smoothing: antialiased; }
body {
  font-family: var(--font);
  background: var(--body-bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
button { font-family: var(--font); cursor: pointer; }
h1, h2, h3 { font-family: var(--font-serif); font-weight: 500; }

/* ── Site header ── */
.site-header {
  background: var(--card-bg);
  color: var(--text);
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 2px solid var(--accent);
}
.site-header .logo {
  font-family: var(--font-serif);
  font-size: 1.25rem;
  font-weight: 500;
  letter-spacing: 0;
  color: var(--text);
}
.site-logo-img { height: 30px; width: auto; display: block; }

/* ── Breadcrumb (in header) ── */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  overflow: hidden;
}
.breadcrumb-home {
  font-family: var(--font-serif);
  font-size: 1.25rem;
  font-weight: 500;
  letter-spacing: 0;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
  transition: color 0.15s;
}
.breadcrumb-home:hover { color: var(--accent); }
.breadcrumb-home-static {
  font-family: var(--font-serif);
  font-size: 1.25rem;
  font-weight: 500;
  letter-spacing: 0;
  color: var(--text);
  white-space: nowrap;
}
.breadcrumb-sep {
  color: var(--border);
  font-size: 0.85rem;
  flex-shrink: 0;
}
.breadcrumb-parent {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
  transition: color 0.15s;
}
.breadcrumb-parent:hover { color: var(--accent); }
.breadcrumb-current {
  font-family: var(--font-serif);
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Breadcrumb trail dropdown (mobile ancestor navigation) ── */
.breadcrumb-trail-toggle {
  display: none;
  align-items: center;
  gap: 4px;
  min-width: 0;
  flex: 1;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  font-family: var(--font-serif);
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text);
}
.breadcrumb-trail-toggle-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.breadcrumb-trail-toggle svg {
  flex-shrink: 0;
  color: var(--text-muted);
  transition: transform 0.15s;
}
.breadcrumb-trail-toggle[aria-expanded="true"] svg { transform: rotate(180deg); }
.breadcrumb-trail-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  z-index: 300;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.breadcrumb-trail-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}
.breadcrumb-trail-panel {
  position: fixed;
  top: calc(var(--header-h) + 8px);
  left: 12px;
  right: 12px;
  max-width: 340px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  z-index: 301;
  opacity: 0;
  transform: translateY(-6px);
  pointer-events: none;
  transition: opacity 0.15s, transform 0.15s;
  overflow: hidden;
}
.breadcrumb-trail-panel.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
.breadcrumb-trail-link {
  display: block;
  padding: 12px 16px;
  font-size: 0.88rem;
  color: var(--text-secondary);
  text-decoration: none;
  border-bottom: 1px solid var(--border-light);
}
.breadcrumb-trail-link:last-child { border-bottom: none; }
.breadcrumb-trail-link:hover { background: var(--accent-light); color: var(--accent); }
.breadcrumb-trail-link.current {
  color: var(--text);
  font-weight: 600;
  cursor: default;
}
.breadcrumb-trail-link.current:hover { background: none; color: var(--text); }
.header-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}
.btn-logout {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 500;
  transition: all 0.15s;
}
.btn-logout:hover {
  border-color: var(--accent);
  color: var(--accent);
}
/* Personal-corner icon — injected by js/auth.js only for its owner's session. */
.btn-owner {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--text-secondary);
  background: transparent;
  transition: all 0.15s;
}
.btn-owner:hover { border-color: var(--accent); color: var(--accent); }
.btn-settings {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.15s, background 0.15s;
}
.btn-settings:hover {
  color: var(--accent);
  background: var(--accent-light);
}
/* .btn-settings is styled for <a>; the toggle is a <button> and needs its own chrome reset. */
.btn-theme-toggle {
  background: none;
  border: none;
  cursor: pointer;
  font: inherit;
}

.btn-menu {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  background: none;
  border: none;
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}
.btn-menu:hover {
  color: var(--accent);
  background: var(--accent-light);
}

/* ── Nav drawer (site-wide app navigation) ── */
.nav-drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  z-index: 300;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.nav-drawer-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}
.nav-drawer {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 280px;
  max-width: 85vw;
  background: var(--card-bg);
  z-index: 301;
  box-shadow: var(--shadow-md);
  transform: translateX(-100%);
  transition: transform 0.2s;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}
.nav-drawer.visible {
  transform: translateX(0);
}
.nav-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-light);
  flex-shrink: 0;
}
.nav-drawer-title {
  font-family: var(--font-serif);
  font-size: 1.1rem;
  font-weight: 500;
  color: var(--text);
}
.nav-drawer-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  display: flex;
  transition: color 0.15s;
}
.nav-drawer-close:hover {
  color: var(--accent);
}
.nav-drawer-body {
  padding: 12px 12px 24px;
}
.nav-drawer-home-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  margin-bottom: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
  border-radius: var(--radius-sm);
  transition: background 0.15s, color 0.15s;
}
.nav-drawer-home-link:hover {
  background: var(--accent-light);
  color: var(--accent);
}
.nav-drawer-section {
  margin-top: 18px;
}
.nav-drawer-section:first-of-type {
  margin-top: 6px;
}
.nav-drawer-section-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  padding: 0 12px;
  margin-bottom: 6px;
}
.nav-drawer-link {
  display: block;
  padding: 9px 12px;
  font-size: 0.86rem;
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: var(--radius-sm);
  transition: background 0.15s, color 0.15s;
}
.nav-drawer-link:hover {
  background: var(--accent-light);
  color: var(--accent);
}

/* ── Site footer ── */
.site-footer {
  background: var(--card-bg);
  color: var(--text-muted);
  text-align: center;
  font-size: 0.78rem;
  padding: 20px 32px;
  margin-top: auto;
  border-top: 1px solid var(--border);
}

/* ── Page wrapper ── */
.page {
  min-height: calc(100vh - var(--header-h));
  display: flex;
  flex-direction: column;
}

/* ── Section heading bar (page tagline) ── */
.section-bar {
  background: none;
  color: var(--text-secondary);
  padding: 16px 32px;
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 1rem;
  font-weight: 400;
  letter-spacing: 0;
  border-bottom: 1px solid var(--border-light);
}

/* ============================================================
   Homepage — card-based navigation
   ============================================================ */
.home-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 64px 32px 100px;
}
.home-greeting {
  text-align: center;
  margin-bottom: 20px;
}
.home-greeting h1 {
  font-size: 2rem;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 6px;
}
.home-greeting p {
  font-size: 1rem;
  font-style: italic;
  color: var(--text-muted);
  font-weight: 400;
}
.home-sections {
  width: 100%;
  max-width: 960px;
}

.home-section {
  margin-bottom: 60px;
}
.home-section:last-child {
  margin-bottom: 0;
}

.home-section-heading {
  font-family: var(--font-serif);
  font-size: 1.55rem;
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text);
  margin-bottom: 24px;
  padding-bottom: 0;
  border-bottom: none;
}

.nav-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
  width: 100%;
}

.nav-cards-empty {
  padding: 18px 24px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-size: 0.85rem;
}

.nav-card {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 20px 24px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-md);
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
  cursor: pointer;
  text-decoration: none;
}
.nav-card:hover {
  border-left-color: var(--accent-hover);
  box-shadow: var(--shadow-md);
  background: var(--card-bg-hover);
}
.nav-card:active {
  background: var(--accent-light);
}

.nav-card-icon {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.nav-card-icon svg {
  width: 32px;
  height: 32px;
}

.nav-card-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.nav-card-title {
  font-family: var(--font-serif);
  font-size: 1rem;
  font-weight: 500;
  color: var(--text);
  line-height: 1.3;
}

/* ── Expandable nav card (e.g. The Big Art List) ── */
.nav-card-unit {
  display: flex;
  flex-direction: column;
}
.nav-card-expandable {
  user-select: none;
}
.nav-card-chevron {
  margin-left: auto;
  flex-shrink: 0;
  color: var(--border);
  transition: color 0.15s, transform 0.15s;
}
.nav-card-expandable:hover .nav-card-chevron {
  color: var(--accent);
}
.nav-card-unit.expanded .nav-card-chevron {
  transform: rotate(90deg);
  color: var(--accent);
}
.nav-card-submenu {
  display: none;
  flex-direction: column;
  gap: 7px;
  margin-top: 8px;
  margin-left: 24px;
}
.nav-card-unit.expanded .nav-card-submenu {
  display: flex;
}
.nav-card-submenu-item {
  padding: 10px 16px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-left: 2px solid var(--accent-light);
  border-radius: var(--radius-sm);
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}
.nav-card-submenu-item:hover {
  border-color: var(--accent);
  border-left-color: var(--accent);
  background: var(--accent-light);
  color: var(--accent);
}

/* ============================================================
   Login page
   ============================================================ */
.login-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--body-bg);
}
.login-header {
  background: var(--card-bg);
  border-bottom: 2px solid var(--accent);
  padding: 16px 32px;
  display: flex;
  align-items: center;
}
.login-header .logo {
  font-family: var(--font-serif);
  color: var(--text);
  font-size: 1.25rem;
  font-weight: 500;
  letter-spacing: 0;
}

.login-body {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
}
.login-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-top: 3px solid var(--accent);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: 44px 40px;
  width: 100%;
  max-width: 400px;
}
.login-card h2 {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}
.login-card .subtitle {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: 32px;
}

/* ── Form elements ── */
.form-group { margin-bottom: 20px; }
.form-group label {
  display: block;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.form-group input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-family: var(--font);
  color: var(--text);
  background: var(--card-bg);
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
}
.form-group input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(29,107,53,0.12);
}

.btn-primary {
  width: 100%;
  padding: 11px;
  background: var(--accent);
  color: var(--white);
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 600;
  transition: background 0.15s, box-shadow 0.15s;
  margin-top: 8px;
}
.btn-primary:hover { background: var(--accent-hover); box-shadow: var(--shadow-sm); }
.btn-primary:disabled { background: var(--border); color: var(--text-muted); cursor: not-allowed; }

.form-error {
  display: none;
  background: var(--error-bg);
  border: 1px solid var(--error-border);
  color: var(--error);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  margin-bottom: 16px;
}
.form-error.visible { display: block; }

/* ============================================================
   Inner app pages (shared layout)
   ============================================================ */
.app-content {
  padding: 36px 32px;
  max-width: 960px;
  margin: 0 auto;
  width: 100%;
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 600px) {
  .nav-cards {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  .site-header,
  .section-bar,
  .app-content {
    padding-left: 20px;
    padding-right: 20px;
  }
  .home-main {
    padding: 40px 20px 60px;
  }
  .header-actions {
    flex-shrink: 0;
  }
  .breadcrumb:has(.breadcrumb-trail-toggle) .breadcrumb-parent,
  .breadcrumb:has(.breadcrumb-trail-toggle) .breadcrumb-parent + .breadcrumb-sep,
  .breadcrumb:has(.breadcrumb-trail-toggle) .breadcrumb-sep + .breadcrumb-current {
    display: none;
  }
  .breadcrumb-trail-toggle { display: flex; }
}
