:root {
  --bg: #0f1115;
  --bg-elevated: #161920;
  --bg-card: #1b1f27;
  --bg-card-hover: #232836;
  --text: #e8e6e1;
  --text-muted: #9aa0a8;
  --text-subtle: #6b7280;
  --accent: #c9a227;
  --accent-soft: rgba(201, 162, 39, 0.12);
  --border: rgba(255, 255, 255, 0.08);
  --radius: 14px;
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
  --font-serif: "Noto Serif SC", "Songti SC", "STSong", serif;
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg);
  color: var(--text);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

img {
  max-width: 100%;
  display: block;
}

.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(14px);
  background: rgba(15, 17, 21, 0.82);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
  height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-serif);
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.logo-icon {
  color: var(--accent);
  font-size: 1.1rem;
}

.site-nav {
  display: flex;
  gap: 28px;
  font-size: 0.95rem;
  color: var(--text-muted);
}

.site-nav a:hover {
  color: var(--text);
}

/* Main */
.main {
  flex: 1;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 48px 24px 80px;
}

/* Views */
.view {
  display: none;
  animation: fadeIn 0.35s ease-out;
}

.view--active {
  display: block;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Hero */
.hero {
  text-align: center;
  margin-bottom: 48px;
}

.hero-title {
  font-family: var(--font-serif);
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 700;
  margin-bottom: 12px;
  letter-spacing: 0.06em;
}

.hero-subtitle {
  color: var(--text-muted);
  font-size: 1.05rem;
  font-weight: 300;
}

/* Toolbar */
.toolbar {
  margin-bottom: 28px;
}

.search-box {
  position: relative;
  max-width: 560px;
  margin: 0 auto 24px;
}

.search-icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-subtle);
  pointer-events: none;
}

.search-box input {
  width: 100%;
  padding: 14px 18px 14px 46px;
  font-size: 0.95rem;
  color: var(--text);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 999px;
  outline: none;
  transition: border-color 0.2s, background 0.2s;
}

.search-box input::placeholder {
  color: var(--text-subtle);
}

.search-box input:focus {
  background: var(--bg-elevated);
  border-color: rgba(201, 162, 39, 0.4);
}

.filter-tags {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.filter-tag {
  padding: 7px 16px;
  font-size: 0.85rem;
  color: var(--text-muted);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 999px;
  transition: all 0.2s;
}

.filter-tag:hover {
  color: var(--text);
  background: var(--bg-card-hover);
}

.filter-tag.active {
  color: var(--accent);
  background: var(--accent-soft);
  border-color: rgba(201, 162, 39, 0.35);
}

.results-info {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 18px;
  min-height: 1.5em;
}

/* Grid */
.reviews-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 28px;
}

.review-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.25s ease, box-shadow 0.25s ease, background 0.25s;
}

.review-card:hover {
  transform: translateY(-6px);
  background: var(--bg-card-hover);
  box-shadow: var(--shadow);
}

.card-poster {
  position: relative;
  aspect-ratio: 2 / 3;
  overflow: hidden;
}

.card-poster img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.4s ease;
}

.review-card:hover .card-poster img {
  transform: scale(1.04);
}

.card-rating {
  position: absolute;
  top: 12px;
  right: 12px;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 5px 10px;
  font-size: 0.85rem;
  font-weight: 600;
  color: #1a150a;
  background: var(--accent);
  border-radius: 999px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

.card-delete {
  position: absolute;
  top: 12px;
  left: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  color: var(--text);
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(4px);
  border-radius: 50%;
  opacity: 0;
  transition: opacity 0.2s, background 0.2s, transform 0.2s;
  z-index: 2;
}

.review-card:hover .card-delete {
  opacity: 1;
}

.card-delete:hover {
  background: rgba(224, 122, 122, 0.9);
  transform: scale(1.08);
}

@media (hover: none) {
  .card-delete {
    opacity: 0.75;
  }
}

.card-body {
  padding: 20px;
}

.card-title {
  font-family: var(--font-serif);
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 6px;
  line-height: 1.35;
}

.card-meta {
  color: var(--text-subtle);
  font-size: 0.82rem;
  margin-bottom: 12px;
}

.card-summary {
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1.65;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 14px;
}

.card-tag {
  font-size: 0.75rem;
  color: var(--text-muted);
  padding: 3px 9px;
  background: var(--bg-elevated);
  border-radius: 999px;
}

.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 80px 20px;
  color: var(--text-muted);
}

.empty-state p {
  font-size: 1.1rem;
}

/* Detail */
.back-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 28px;
  padding: 8px 14px;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  transition: all 0.2s;
}

.back-button:hover {
  color: var(--text);
  background: var(--bg-card);
}

.review-detail {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.detail-hero {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 36px;
  padding: 40px;
}

.detail-poster {
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.detail-poster img {
  width: 100%;
  height: auto;
  aspect-ratio: 2 / 3;
  object-fit: cover;
}

.detail-info {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.detail-title {
  font-family: var(--font-serif);
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  font-weight: 700;
  margin-bottom: 8px;
  line-height: 1.25;
}

.detail-original-title {
  color: var(--text-subtle);
  font-size: 1rem;
  font-style: italic;
  margin-bottom: 18px;
}

.detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 22px;
  color: var(--text-muted);
  font-size: 0.92rem;
}

.detail-meta span {
  display: flex;
  align-items: center;
  gap: 6px;
}

.detail-rating {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 18px;
}

.detail-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.detail-tag {
  padding: 6px 14px;
  font-size: 0.85rem;
  color: var(--text-muted);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 999px;
}

.detail-content {
  padding: 0 40px 48px;
  max-width: 760px;
}

.detail-content h2 {
  font-family: var(--font-serif);
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 16px;
  color: var(--text);
}

.detail-content p {
  font-size: 1.05rem;
  color: var(--text-muted);
  margin-bottom: 20px;
  text-align: justify;
}

.detail-content p:last-child {
  margin-bottom: 0;
}

.detail-divider {
  height: 1px;
  background: var(--border);
  margin: 0 40px 40px;
}

/* Footer */
.site-footer {
  text-align: center;
  padding: 32px 24px;
  color: var(--text-subtle);
  font-size: 0.85rem;
  border-top: 1px solid var(--border);
}

.toolbar-top {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}

.add-review-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 13px 20px;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--bg);
  background: var(--accent);
  border-radius: 999px;
  transition: transform 0.2s, box-shadow 0.2s;
  white-space: nowrap;
}

.add-review-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 22px rgba(201, 162, 39, 0.25);
}

.add-review-btn svg {
  color: currentColor;
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

.modal.active {
  opacity: 1;
  visibility: visible;
}

.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
}

.modal-content {
  position: relative;
  width: 100%;
  max-width: 540px;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transform: translateY(12px);
  transition: transform 0.25s ease;
}

.modal.active .modal-content {
  transform: translateY(0);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 24px 16px;
  border-bottom: 1px solid var(--border);
}

.modal-header h2 {
  font-family: var(--font-serif);
  font-size: 1.35rem;
  font-weight: 700;
}

.modal-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  color: var(--text-muted);
  border-radius: 50%;
  transition: color 0.2s, background 0.2s;
}

.modal-close:hover {
  color: var(--text);
  background: var(--bg-elevated);
}

.add-form {
  padding: 24px;
}

.form-field {
  display: block;
  margin-bottom: 18px;
}

.form-label {
  display: block;
  margin-bottom: 8px;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.form-hint {
  display: block;
  margin-top: 6px;
  font-size: 0.8rem;
  color: var(--text-subtle);
  line-height: 1.5;
}

.form-field input,
.form-field textarea {
  width: 100%;
  padding: 12px 14px;
  font-size: 0.95rem;
  color: var(--text);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 10px;
  outline: none;
  transition: border-color 0.2s, background 0.2s;
}

.form-field input::placeholder,
.form-field textarea::placeholder {
  color: var(--text-subtle);
}

.form-field input:focus,
.form-field textarea:focus {
  background: var(--bg);
  border-color: rgba(201, 162, 39, 0.4);
}

.form-field textarea {
  resize: vertical;
  line-height: 1.7;
}

.form-row {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 14px;
}

.poster-field {
  margin-bottom: 18px;
}

.poster-preview {
  width: 120px;
  aspect-ratio: 2 / 3;
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  margin-bottom: 10px;
}

.poster-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.poster-preview img[src=""],
.poster-preview img:not([src]) {
  display: none;
}

.poster-preview:has(img[src=""]),
.poster-preview:has(img:not([src])) {
  background: var(--bg-elevated);
}

.fetch-poster-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  font-size: 0.85rem;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid rgba(201, 162, 39, 0.35);
  border-radius: 999px;
  transition: all 0.2s;
}

.fetch-poster-btn:hover {
  background: rgba(201, 162, 39, 0.2);
}

.fetch-poster-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.poster-status {
  display: block;
  margin-top: 8px;
  font-size: 0.82rem;
  color: var(--text-subtle);
  min-height: 1.4em;
}

.poster-status.success {
  color: #6fc97c;
}

.poster-status.error {
  color: #e07a7a;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 8px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

.btn {
  padding: 11px 20px;
  font-size: 0.95rem;
  font-weight: 500;
  border-radius: 999px;
  transition: all 0.2s;
}

.btn-primary {
  color: var(--bg);
  background: var(--accent);
}

.btn-primary:hover {
  box-shadow: 0 6px 18px rgba(201, 162, 39, 0.25);
}

.btn-secondary {
  color: var(--text-muted);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  color: var(--text);
  background: var(--bg-card-hover);
}

/* Comments */
.comments-section {
  margin-top: 40px;
  padding: 32px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.comments-title {
  font-family: var(--font-serif);
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 24px;
}

.comment-form {
  margin-bottom: 28px;
}

.comment-form-row {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 14px;
}

.comment-input {
  width: 100%;
  padding: 12px 14px;
  font-size: 0.95rem;
  color: var(--text);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 10px;
  outline: none;
  transition: border-color 0.2s, background 0.2s;
}

.comment-input::placeholder {
  color: var(--text-subtle);
}

.comment-input:focus {
  background: var(--bg);
  border-color: rgba(201, 162, 39, 0.4);
}

.comment-nickname {
  max-width: 260px;
}

.comment-textarea {
  resize: vertical;
  line-height: 1.7;
}

.comment-form-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.comment-hint {
  font-size: 0.85rem;
  color: var(--text-subtle);
}

.comment-status {
  margin-top: 12px;
  font-size: 0.9rem;
  min-height: 1.4em;
}

.comment-status.success {
  color: #6fc97c;
}

.comment-status.error {
  color: #e07a7a;
}

.cf-turnstile {
  margin-bottom: 12px;
}

.comments-list {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.comments-empty {
  padding: 28px 0;
  text-align: center;
  color: var(--text-subtle);
  font-size: 0.95rem;
}

.comment-item {
  padding: 18px 20px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 12px;
}

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

.comment-author {
  font-weight: 600;
  color: var(--accent);
}

.comment-time {
  font-size: 0.82rem;
  color: var(--text-subtle);
}

.comment-body {
  font-size: 0.95rem;
  color: var(--text-muted);
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
}

.detail-loading {
  padding: 80px 20px;
  text-align: center;
  color: var(--text-muted);
}

/* Responsive */
@media (max-width: 768px) {
  .main {
    padding-top: 32px;
  }

  .hero {
    margin-bottom: 36px;
  }

  .reviews-grid {
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 20px;
  }

  .detail-hero {
    grid-template-columns: 1fr;
    padding: 28px;
    gap: 24px;
  }

  .detail-poster {
    max-width: 260px;
    margin: 0 auto;
  }

  .detail-content,
  .detail-divider {
    padding-left: 28px;
    padding-right: 28px;
    margin-left: 28px;
    margin-right: 28px;
  }

  .detail-content {
    padding-bottom: 36px;
  }

  .toolbar-top {
    flex-direction: column;
    align-items: stretch;
  }

  .search-box {
    max-width: none;
  }

  .add-review-btn {
    justify-content: center;
  }

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

  .comments-section {
    padding: 24px;
  }

  .comment-form-actions {
    flex-direction: column-reverse;
    align-items: stretch;
  }

  .comment-nickname {
    max-width: none;
  }
}

@media (max-width: 480px) {
  .header-inner {
    height: 60px;
  }

  .site-nav {
    gap: 18px;
    font-size: 0.9rem;
  }

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

  .detail-hero,
  .detail-content,
  .detail-divider {
    padding-left: 20px;
    padding-right: 20px;
  }

  .detail-divider {
    margin-left: 20px;
    margin-right: 20px;
  }

  .modal {
    padding: 0;
    align-items: flex-end;
  }

  .modal-content {
    max-height: 92vh;
    border-radius: var(--radius) var(--radius) 0 0;
  }

  .form-actions {
    flex-direction: column-reverse;
  }

  .btn {
    width: 100%;
    justify-content: center;
  }

  .comments-section {
    padding: 20px;
  }

  .comment-item {
    padding: 14px 16px;
  }

  .comment-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }
}
