:root {
  --bg-0: #f5f2e9;
  --bg-1: #ebe4d6;
  --bg-2: #d8ddd2;
  --ink-0: #1f2624;
  --ink-1: #4f5b58;
  --line: rgba(22, 36, 33, 0.12);
  --panel: rgba(255, 253, 247, 0.74);
  --panel-strong: rgba(255, 253, 247, 0.9);
  --accent-a: #be5333;
  --accent-b: #2f7468;
  --radius-lg: 28px;
  --radius-md: 18px;
  --radius-sm: 12px;
  --shadow-lg: 0 24px 52px rgba(20, 31, 29, 0.12);
}

* {
  box-sizing: border-box;
}

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

body {
  font-family: "Space Grotesk", "Segoe UI", sans-serif;
  color: var(--ink-0);
  background:
    radial-gradient(circle at 10% 14%, rgba(190, 83, 51, 0.24), transparent 33%),
    radial-gradient(circle at 84% 8%, rgba(47, 116, 104, 0.28), transparent 34%),
    linear-gradient(144deg, var(--bg-0), var(--bg-1) 42%, var(--bg-2));
}

.noise {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.22;
  background-image: repeating-linear-gradient(
    0deg,
    rgba(20, 35, 30, 0.05) 0,
    rgba(20, 35, 30, 0.05) 1px,
    transparent 1px,
    transparent 3px
  );
}

.orb {
  position: fixed;
  border-radius: 50%;
  pointer-events: none;
  filter: blur(62px);
  opacity: 0.42;
}

.orb-a {
  width: 360px;
  height: 360px;
  background: #d58d67;
  top: 26%;
  right: 8%;
}

.orb-b {
  width: 420px;
  height: 420px;
  background: #70aea3;
  bottom: 14%;
  left: 8%;
}

.app-shell {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 26px;
  min-height: 100vh;
  padding: 24px;
  overflow-x: clip;
  transition: grid-template-columns 240ms ease, gap 240ms ease;
}

.featurebar-toggle {
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 6;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 9px 14px 9px 11px;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink-0);
  cursor: pointer;
  background: var(--panel-strong, rgba(255, 253, 247, 0.96));
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow: 0 2px 10px rgba(0,0,0,0.09), 0 1px 3px rgba(0,0,0,0.05);
  transition: transform 180ms ease, box-shadow 180ms ease,
              background 320ms ease, border-color 320ms ease, color 320ms ease;
}

.featurebar-toggle:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(0,0,0,0.13), 0 1px 4px rgba(0,0,0,0.07);
}

.featurebar-toggle .toggle-icon {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex-shrink: 0;
}

.featurebar-toggle .toggle-icon span {
  display: block;
  width: 16px;
  height: 2px;
  border-radius: 2px;
  background: currentColor;
  transition: transform 260ms cubic-bezier(0.2,0.7,0.2,1),
              opacity 200ms ease, width 260ms ease;
}

.featurebar-collapsed .featurebar-toggle .toggle-icon span:nth-child(1) {
  transform: translateY(6px) rotate(45deg);
}
.featurebar-collapsed .featurebar-toggle .toggle-icon span:nth-child(2) {
  opacity: 0;
  width: 0;
}
.featurebar-collapsed .featurebar-toggle .toggle-icon span:nth-child(3) {
  transform: translateY(-6px) rotate(-45deg);
}

.sidebar-head h2 {
  margin: 0;
  font-size: 0.96rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-1);
}

.sidebar,
.main {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--panel);
  backdrop-filter: blur(14px);
  box-shadow: var(--shadow-lg);
}

.sidebar {
  position: sticky;
  top: 24px;
  height: calc(100vh - 48px);
  width: 320px;
  min-width: 320px;
  max-width: 320px;
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  will-change: transform, opacity;
  transition: opacity 280ms ease, transform 280ms cubic-bezier(0.2, 0.7, 0.2, 1);
}

.app-shell.featurebar-collapsed {
  grid-template-columns: 0 minmax(0, 1fr);
  gap: 0;
}

.app-shell.featurebar-collapsed .sidebar {
  opacity: 0;
  pointer-events: none;
  transform: translateX(calc(-100% - 28px));
}

.eyebrow {
  margin: 0 0 8px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  font-size: 0.72rem;
  color: var(--ink-1);
}

.brand h1,
.hero h2 {
  margin: 0;
  font-family: "Noto Serif SC", serif;
  letter-spacing: 0.03em;
}

.brand p {
  margin: 9px 0 0;
  color: var(--ink-1);
  line-height: 1.5;
}

.filter-group h3 {
  margin: 0 0 9px;
  font-size: 0.92rem;
}

.chips,
.album-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip,
.album-btn {
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 9px 12px;
  background: rgba(255, 255, 255, 0.52);
  color: var(--ink-0);
  cursor: pointer;
  font: inherit;
  font-size: 0.85rem;
  transition: transform 200ms ease, border-color 200ms ease, background 200ms ease, color 200ms ease;
}

.chip:hover,
.album-btn:hover {
  transform: translateY(-2px);
  border-color: rgba(30, 39, 37, 0.2);
}

.chip.active,
.album-btn.active {
  color: #fff;
  border-color: transparent;
  background: linear-gradient(128deg, var(--accent-a), var(--accent-b));
}

.sidebar-foot {
  margin-top: auto;
  border-top: 1px dashed var(--line);
  padding-top: 12px;
  color: var(--ink-1);
  font-size: 0.86rem;
}

.sidebar-foot p {
  margin: 5px 0;
}

.main {
  padding: 24px;
  overflow: hidden;
}

.hero {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
  padding-bottom: 16px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.hero h2 {
  font-size: clamp(1.45rem, 2.8vw, 2.4rem);
  margin-bottom: 8px;
}

#heroMeta {
  margin: 0;
  color: var(--ink-1);
}

.btn {
  border: 0;
  border-radius: 999px;
  padding: 11px 16px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.btn-primary {
  background: linear-gradient(130deg, var(--accent-a), var(--accent-b));
  color: #fff;
}

.btn-secondary {
  background: #e6eee8;
  color: var(--ink-0);
}

.btn-danger {
  background: rgba(180, 50, 40, 0.1);
  color: #b43228;
  border: 1px solid rgba(180, 50, 40, 0.22);
}

.btn-danger:hover {
  background: rgba(180, 50, 40, 0.18);
}

.featurebar-toggle:focus-visible {
  outline: 2px solid var(--accent-b);
  outline-offset: 2px;
}

.timeline-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  grid-auto-flow: dense;
}

.entry-card {
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid rgba(25, 34, 30, 0.1);
  background: var(--panel-strong);
  box-shadow: 0 12px 24px rgba(15, 33, 30, 0.1);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  transform: translateY(20px) scale(0.985);
  opacity: 0;
  transition: transform 360ms cubic-bezier(0.2, 0.7, 0.2, 1), opacity 360ms ease;
  transition-delay: var(--delay, 0ms);
}

.entry-card.show {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.entry-card:hover {
  transform: translateY(-4px);
}

.entry-card.wide {
  grid-column: span 2;
}

/* Image wrap: height driven by actual image aspect ratio via CSS var */
.image-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: var(--img-ratio, 1.6);
  min-height: 140px;
  max-height: 460px;
  overflow: hidden;
  flex-shrink: 0;
}

.image-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  backface-visibility: hidden;
  transform: translateZ(0);
}

.app-shell.featurebar-toggling .entry-card,
.app-shell.featurebar-toggling .entry-card * {
  transition: none !important;
}

.card-badges {
  position: absolute;
  left: 10px;
  bottom: 10px;
  display: flex;
  gap: 6px;
}

.badge {
  font-size: 0.74rem;
  color: #fff;
  background: rgba(15, 24, 22, 0.66);
  padding: 4px 9px;
  border-radius: 999px;
}

.entry-note {
  flex: 1;
  min-height: 108px;
  padding: 13px 14px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  overflow: hidden;
}

.entry-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: baseline;
}

.entry-title {
  margin: 0;
  font-size: 1rem;
}

.entry-date {
  color: var(--ink-1);
  font-size: 0.74rem;
  white-space: nowrap;
}

.entry-meta {
  margin: 0;
  color: var(--ink-1);
  font-size: 0.82rem;
}

.entry-text {
  margin: 0;
  color: #394542;
  line-height: 1.46;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.empty {
  margin: 0;
  border: 1px dashed var(--line);
  border-radius: var(--radius-md);
  padding: 20px;
  color: var(--ink-1);
}

.modal {
  position: fixed;
  inset: 0;
  display: block;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  background: rgba(10, 20, 18, 0.48);
  z-index: 10;
  padding: 20px;
  transition: opacity 220ms ease, visibility 0s linear 220ms;
}

.modal.open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition-delay: 0s;
}

.modal-dialog {
  max-width: 760px;
  max-height: calc(100vh - 40px);
  overflow: auto;
  margin: 0 auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: rgba(255, 253, 248, 0.95);
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow-lg);
  padding: 16px;
  opacity: 0;
  transform: translateY(14px) scale(0.985);
  transition: opacity 220ms ease, transform 240ms cubic-bezier(0.2, 0.7, 0.2, 1);
}

.modal.open .modal-dialog {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.modal-dialog-wide {
  max-width: 1120px;
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.modal-head h3 {
  margin: 0;
  font-family: "Noto Serif SC", serif;
}

.icon-btn {
  border: 0;
  border-radius: 999px;
  padding: 7px 12px;
  cursor: pointer;
  background: #edf0ea;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.form-grid.subtle {
  margin-top: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: rgba(244, 244, 240, 0.65);
}

.form-grid h4 {
  margin: 0;
  grid-column: 1 / -1;
}

.form-tip {
  margin: 0;
  color: var(--ink-1);
  font-size: 0.8rem;
  border: 1px dashed var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  background: rgba(251, 250, 245, 0.8);
}

.form-grid label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 0.88rem;
  color: var(--ink-1);
}

.form-grid input,
.form-grid textarea,
.comment-form input,
.comment-form textarea {
  width: 100%;
  border: 1px solid rgba(21, 32, 30, 0.16);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.76);
  padding: 9px 10px;
  font: inherit;
  color: var(--ink-0);
}

.form-grid textarea,
.comment-form textarea {
  resize: vertical;
}

.full {
  grid-column: 1 / -1;
}

.actions {
  display: flex;
  justify-content: flex-end;
}

.entry-layout {
  display: grid;
  gap: 14px;
  grid-template-columns: minmax(0, 1.45fr) minmax(280px, 1fr);
}

.entry-pane,
.comment-pane {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.56);
  padding: 12px;
}

.detail-image {
  width: 100%;
  height: 300px;
  object-fit: cover;
  border-radius: 12px;
}

.detail-meta {
  margin: 10px 0 6px;
  color: var(--ink-1);
  font-size: 0.88rem;
}

.detail-note {
  margin: 0;
  line-height: 1.52;
}

.comment-pane h4 {
  margin: 0 0 10px;
}

.comment-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 360px;
  overflow: auto;
}

.comment-item {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 9px 10px;
  background: rgba(252, 252, 249, 0.84);
}

.comment-top {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.78rem;
  color: var(--ink-1);
}

.comment-item p {
  margin: 6px 0 0;
  line-height: 1.48;
}

.comment-form {
  margin-top: 10px;
  border-top: 1px dashed var(--line);
  padding-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.comment-form label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 0.85rem;
  color: var(--ink-1);
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 18px;
  border-radius: 12px;
  background: rgba(19, 31, 29, 0.86);
  color: #fff;
  padding: 10px 14px;
  font-size: 0.88rem;
  box-shadow: 0 16px 34px rgba(11, 22, 20, 0.24);
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity 220ms ease, transform 220ms ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: 1fr;
    padding: 14px;
    gap: 14px;
    transition: gap 280ms ease;
  }

  .featurebar-toggle {
    top: 12px;
    left: 12px;
  }

  .sidebar {
    position: static;
    height: auto;
    width: auto;
    min-width: 0;
    max-width: none;
    padding-top: 54px;
    /* Animated collapse on mobile uses max-height */
    overflow: hidden;
    max-height: 1600px;
    transition: max-height 380ms cubic-bezier(0.4, 0, 0.2, 1),
                padding 300ms ease,
                opacity 260ms ease,
                transform 280ms cubic-bezier(0.2, 0.7, 0.2, 1);
  }

  /* Override desktop grid collapse — mobile collapses via max-height instead */
  .app-shell.featurebar-collapsed {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .app-shell.featurebar-collapsed .sidebar {
    display: block; /* keep in DOM for animation */
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
    opacity: 0;
    pointer-events: none;
    transform: translateY(-12px);
  }

  .entry-card.wide {
    grid-column: span 1;
  }

  .timeline-grid {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  }

  .modal {
    padding: 10px;
  }

  .modal-dialog {
    max-height: calc(100dvh - 20px);
    padding: 12px;
  }

  .entry-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .hero {
    flex-direction: column;
    align-items: flex-start;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .detail-image {
    height: 240px;
  }

  .timeline-grid {
    grid-template-columns: 1fr;
  }

  .featurebar-toggle .toggle-label {
    display: none;
  }
}

/* ═══════════════════════════════════════
   Theme switcher component
   ═══════════════════════════════════════ */
.theme-row {
  margin-bottom: 8px;
}

.theme-label {
  margin: 0 0 8px;
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-1);
}

.theme-chips {
  display: flex;
  gap: 8px;
  align-items: center;
}

.theme-chip {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 2.5px solid transparent;
  cursor: pointer;
  padding: 0;
  transition: transform 200ms ease, border-color 200ms ease, box-shadow 200ms ease;
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}

.theme-chip:hover {
  transform: scale(1.12);
}

.theme-chip.active {
  border-color: var(--ink-0);
  box-shadow: 0 0 0 3px rgba(0,0,0,0.08), 0 3px 8px rgba(0,0,0,0.18);
  transform: scale(1.08);
}

/* ═══════════════════════════════════════
   Theme: 浩瀚星辰 (Starry cosmos)
   ═══════════════════════════════════════ */
[data-theme="stars"] {
  --bg-0: #050914;
  --bg-1: #081028;
  --bg-2: #0b1535;
  --ink-0: #dce8ff;
  --ink-1: #6a84b0;
  --line: rgba(100, 160, 255, 0.12);
  --panel: rgba(8, 16, 42, 0.76);
  --panel-strong: rgba(6, 12, 34, 0.94);
  --accent-a: #7c5cfc;
  --accent-b: #38c5f8;
  --shadow-lg: 0 24px 52px rgba(0, 0, 0, 0.6);
  color-scheme: dark;
}

[data-theme="stars"] body {
  background:
    radial-gradient(ellipse at 20% 50%, rgba(124, 92, 252, 0.15) 0%, transparent 55%),
    radial-gradient(ellipse at 80% 20%, rgba(56, 197, 248, 0.12) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 90%, rgba(80, 40, 160, 0.18) 0%, transparent 45%),
    linear-gradient(160deg, #050914, #081028 55%, #0b1535);
}

[data-theme="stars"] .orb-a {
  background: #6030d8;
  opacity: 0.22;
  width: 480px;
  height: 480px;
}

[data-theme="stars"] .orb-b {
  background: #1060b8;
  opacity: 0.2;
  width: 520px;
  height: 520px;
}

[data-theme="stars"] .badge {
  background: rgba(56, 197, 248, 0.22);
}

/* ═══════════════════════════════════════
   Theme: 新海诚 (Shinkai style)
   ═══════════════════════════════════════ */
[data-theme="shinkai"] {
  --bg-0: #b8cee8;
  --bg-1: #a0bedd;
  --bg-2: #ecd8b8;
  --ink-0: #102035;
  --ink-1: #305570;
  --line: rgba(16, 40, 80, 0.11);
  --panel: rgba(255, 255, 255, 0.64);
  --panel-strong: rgba(255, 255, 255, 0.84);
  --accent-a: #c85f08;
  --accent-b: #1a5ea8;
  --shadow-lg: 0 24px 52px rgba(16, 40, 90, 0.2);
}

[data-theme="shinkai"] body {
  background:
    radial-gradient(ellipse at 50% -10%, rgba(255, 200, 100, 0.55) 0%, transparent 45%),
    radial-gradient(ellipse at 80% 100%, rgba(26, 94, 168, 0.35) 0%, transparent 50%),
    linear-gradient(182deg, #2a58b8 0%, #7aaee0 28%, #b8cee8 52%, #d0dcee 70%, #ecdcc8 100%);
}

[data-theme="shinkai"] .orb-a {
  background: #f0a855;
  opacity: 0.5;
  top: 2%;
  right: 15%;
  width: 560px;
  height: 260px;
  filter: blur(72px);
}

[data-theme="shinkai"] .orb-b {
  background: #3070c0;
  opacity: 0.38;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 280px;
  border-radius: 0;
  filter: blur(56px);
}

[data-theme="shinkai"] .badge {
  background: rgba(10, 30, 60, 0.52);
}

.site-footer {
  position: relative;
  margin-top: 32px;
  padding: 20px 24px;
  text-align: center;
  font-size: 15px;
  line-height: 1.6;
  color: var(--ink-0);
  background: var(--panel, rgba(255, 253, 247, 0.74));
  border-top: 1px solid var(--line, rgba(22, 36, 33, 0.12));
}

.beian-link {
  color: var(--ink-0);
  font-weight: 600;
  font-size: 15px;
  letter-spacing: 0.5px;
  text-decoration: underline;
  text-underline-offset: 3px;
  transition: color 0.2s ease;
}

.beian-link:hover {
  color: var(--accent-a);
  text-decoration: underline;
}

[data-theme="stars"] .site-footer {
  color: #ffffff;
  background: rgba(0, 0, 0, 0.35);
  border-top: 1px solid rgba(255, 255, 255, 0.25);
}

[data-theme="stars"] .beian-link {
  color: #ffffff;
}

[data-theme="stars"] .beian-link:hover {
  color: #ffd479;
}
