:root {
  color-scheme: dark;
  --bg: #111316;
  --panel: #1b2026;
  --panel-2: #242b33;
  --text: #f4f7fb;
  --muted: #a9b3c0;
  --line: #333c47;
  --accent: #49c58f;
  --accent-strong: #27a86f;
  --danger: #d95d5d;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}

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

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px clamp(16px, 4vw, 40px);
  background: rgba(17, 19, 22, 0.94);
  border-bottom: 1px solid var(--line);
}

.brand {
  font-weight: 800;
  letter-spacing: 0;
}

nav {
  display: flex;
  gap: 12px;
  color: var(--muted);
  font-size: 14px;
}

nav a:hover,
.movie-card h2 a:hover,
.archive-item a:hover {
  color: var(--accent);
}

.page {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 18px clamp(14px, 4vw, 32px) 48px;
}

.page-with-sidebar {
  display: grid;
  grid-template-columns: minmax(180px, 220px) minmax(0, 1fr);
  align-items: start;
  gap: clamp(20px, 3vw, 36px);
  width: min(1320px, 100%);
}

.content-area {
  min-width: 0;
}

.member-sidebar {
  position: sticky;
  top: 74px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.member-sidebar h2 {
  margin-bottom: 12px;
  font-size: 17px;
}

.member-list {
  display: grid;
  gap: 8px;
}

.member-row {
  display: grid;
  gap: 2px;
  padding: 9px 10px;
  border: 1px solid rgba(51, 60, 71, 0.72);
  border-radius: 8px;
  background: #161a20;
}

.member-row strong {
  overflow-wrap: anywhere;
}

.member-row span {
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.role-badge {
  display: inline-flex;
  width: fit-content;
  padding: 2px 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-2);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.role-owner {
  border-color: rgba(73, 197, 143, 0.45);
  color: #bdf1d7;
}

.role-admin {
  border-color: rgba(124, 168, 255, 0.45);
  color: #cbdcff;
}

.user-strip,
.card-footer,
.stats,
.watchers,
.actions,
.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
}

.user-strip {
  justify-content: space-between;
  margin-bottom: 22px;
  color: var(--muted);
  font-size: 14px;
}

.page-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 4px;
  font-size: clamp(28px, 4vw, 42px);
}

h2 {
  margin-bottom: 10px;
  font-size: 22px;
}

h3 {
  margin-bottom: 6px;
  font-size: 18px;
}

.page-title p,
.muted,
.meta {
  color: var(--muted);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 10px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--text);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.button:hover {
  border-color: var(--accent);
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

.button:disabled:hover {
  border-color: var(--line);
}

.button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #08110d;
}

.button.primary:hover {
  background: var(--accent-strong);
}

.button.danger {
  border-color: rgba(217, 93, 93, 0.6);
  color: #ffd8d8;
}

.button.small {
  min-height: 32px;
  padding: 6px 10px;
  font-size: 13px;
}

.button.delete-button {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}

.button.delete-button:hover {
  background: #c94a4a;
  border-color: #c94a4a;
}

.movie-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

.movie-card,
.panel,
.empty-state,
.archive-item,
.detail,
.search-result,
.comment {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.movie-card {
  position: relative;
  display: grid;
  grid-template-columns: 128px minmax(0, 1fr);
  min-height: 192px;
  overflow: hidden;
}

.movie-rank {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 1;
  min-width: 34px;
  padding: 4px 8px;
  border: 1px solid rgba(73, 197, 143, 0.42);
  border-radius: 999px;
  background: rgba(10, 12, 15, 0.82);
  color: #bdf1d7;
  font-size: 14px;
  font-weight: 900;
  line-height: 1.2;
  text-align: center;
}

.poster-slot,
.result-poster {
  overflow: hidden;
  background: #0a0c0f;
}

.poster-slot {
  width: 128px;
  min-height: 192px;
  height: 100%;
}

.detail-poster-slot {
  width: 100%;
  min-height: 0;
  aspect-ratio: 2 / 3;
}

.poster,
.poster-placeholder,
.result-poster img,
.poster-fallback {
  width: 100%;
  height: 100%;
}

.poster,
.result-poster img {
  display: block;
  object-fit: cover;
}

.poster-placeholder,
.poster-fallback {
  display: grid;
  place-items: center;
  padding: 10px;
  color: var(--muted);
  text-align: center;
  font-size: 12px;
  font-weight: 800;
}

.poster-fallback.small {
  width: 72px;
  min-height: 108px;
}

.movie-card-body,
.archive-body,
.panel,
.empty-state,
.comment {
  padding: 16px;
}

.movie-card-body,
.archive-body {
  display: flex;
  min-width: 0;
  flex-direction: column;
}

.movie-title-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}

.movie-title {
  min-width: 0;
}

.movie-original-title {
  color: var(--muted);
  font-size: 0.78em;
  font-weight: 400;
  overflow-wrap: anywhere;
}

.detail-original-title {
  font-size: 0.62em;
}

.overview {
  color: #d5dbe3;
}

.movie-card .overview,
.archive-item .overview,
.search-result .overview {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.card-footer,
.stats {
  color: var(--muted);
  font-size: 14px;
}

.want-count {
  color: var(--accent);
  font-weight: 900;
}

.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: auto;
  padding-top: 14px;
}

.empty-state {
  padding: 28px;
  text-align: center;
}

.panel {
  margin-bottom: 18px;
}

.auth-screen {
  display: grid;
  min-height: calc(100vh - 150px);
  place-items: center;
  padding: 24px 0;
}

.auth-panel {
  width: min(460px, 100%);
  margin: 0 auto;
  padding: 26px;
  border-color: rgba(73, 197, 143, 0.32);
  background: #171d23;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
}

.auth-heading {
  margin-bottom: 20px;
  text-align: center;
}

.auth-heading h1 {
  margin-bottom: 6px;
  font-size: clamp(32px, 6vw, 46px);
}

.auth-heading p {
  margin-bottom: 0;
  color: #cfe9dc;
}

.auth-panel .stack-form {
  gap: 14px;
}

.auth-panel input[type="text"],
.auth-panel input[type="password"],
.auth-panel input:not([type]) {
  border-color: rgba(73, 197, 143, 0.26);
  background: #0d1115;
}

.auth-panel input:focus {
  outline: 2px solid rgba(73, 197, 143, 0.24);
  border-color: var(--accent);
}

.auth-error {
  margin: 0 0 14px;
  border-color: rgba(217, 93, 93, 0.55);
  background: rgba(217, 93, 93, 0.1);
  color: #ffc9c9;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 9px;
  width: fit-content;
  color: #d5dbe3;
  font-size: 14px;
  font-weight: 600;
}

.checkbox-row input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.primary-panel {
  border-color: rgba(73, 197, 143, 0.55);
  background: #19251f;
  box-shadow: 0 0 0 1px rgba(73, 197, 143, 0.12);
}

.secondary-panel {
  border-color: rgba(51, 60, 71, 0.72);
  background: #171b21;
}

.danger-panel {
  border-color: rgba(217, 93, 93, 0.55);
  background: #241819;
}

.section-heading {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}

.section-heading h2 {
  margin-bottom: 0;
}

.recommend-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(73, 197, 143, 0.18);
  color: #bdf1d7;
  font-size: 13px;
  font-weight: 800;
}

.recommend-copy {
  color: #cfe9dc;
}

.tutorial-list {
  display: grid;
  gap: 10px;
  margin: 16px 0 22px;
}

.tutorial-list p {
  margin-bottom: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #161a20;
}

.group-list {
  display: grid;
  gap: 12px;
}

.group-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #161a20;
}

.group-item h3 {
  margin-bottom: 2px;
}

.group-main {
  min-width: 0;
}

.group-controls,
.nickname-form {
  display: flex;
  align-items: end;
  gap: 10px;
}

.group-controls {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.nickname-form label {
  min-width: 180px;
}

.nickname-save-button.nickname-saved {
  border-color: rgba(51, 60, 71, 0.9);
  background: #14181d;
  color: var(--muted);
}

.manage-member-list {
  display: grid;
  gap: 10px;
}

.manage-member-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #161a20;
}

.manage-member-row p {
  margin-bottom: 0;
}

.manage-actions {
  margin-top: 0;
  padding-top: 0;
}

.stack-form,
.comment-form,
.settings-form {
  display: grid;
  gap: 12px;
}

.settings-form {
  grid-template-columns: repeat(2, minmax(0, 1fr)) auto;
  align-items: end;
}

.search-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

.primary-panel .search-form {
  padding: 12px;
  border: 1px solid rgba(73, 197, 143, 0.35);
  border-radius: 8px;
  background: rgba(8, 17, 13, 0.34);
}

.primary-panel .search-form input {
  border-color: rgba(73, 197, 143, 0.55);
  background: #0c1511;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-weight: 700;
}

.field-hint {
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #101317;
  color: var(--text);
  font: inherit;
  padding: 11px 12px;
}

textarea {
  resize: vertical;
}

.result-note {
  margin: 14px 0 0;
}

.result-list {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.completion-form {
  display: grid;
  gap: 10px;
  margin-top: 10px;
}

.completion-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
}

.search-result {
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 14px;
  padding: 12px;
}

.detail {
  display: grid;
  grid-template-columns: minmax(160px, 260px) 1fr;
  gap: 20px;
  padding: 18px;
  margin-bottom: 18px;
}

.detail-body {
  min-width: 0;
}

.large {
  font-size: 17px;
}

.stats,
.watchers,
.actions {
  margin-top: 16px;
}

.recommendation-panel {
  display: grid;
  gap: 10px;
  padding: 16px;
  border-color: rgba(73, 197, 143, 0.28);
  background: #171f1b;
}

.recommendation-panel h2 {
  margin-bottom: 0;
  font-size: 20px;
}

.recommendation-text {
  margin-bottom: 0;
  color: #dbeee5;
  white-space: pre-wrap;
}

.recommendation-form {
  display: grid;
  gap: 10px;
}

.notice {
  margin: 14px 0 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--muted);
}

.notice.success {
  border-color: rgba(73, 197, 143, 0.5);
  color: #bdf1d7;
}

.watchers span {
  padding: 5px 9px;
  border-radius: 999px;
  background: var(--panel-2);
  color: var(--muted);
  font-size: 14px;
}

.comments {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.comment {
  background: #161a20;
}

.comment-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 14px;
}

.comment p {
  margin-bottom: 0;
  white-space: pre-wrap;
}

.comment-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}

.comment-actions form {
  display: inline;
}

.action-link {
  appearance: none;
  background: transparent;
  border: 0;
  cursor: pointer;
  font: inherit;
  line-height: 1.2;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 3px;
  transition: color 0.15s ease, text-shadow 0.15s ease;
}

.reply-link {
  color: #8ee6bd;
}

.reply-link:hover {
  color: #c4ffe3;
  text-shadow: 0 0 10px rgba(142, 230, 189, 0.38);
}

.delete-link {
  color: #ff8a8a;
}

.delete-link:hover {
  color: #ffc0c0;
  text-shadow: 0 0 10px rgba(255, 138, 138, 0.38);
}

.reply-form {
  display: grid;
  gap: 8px;
  margin-top: 6px;
}

.reply-list {
  display: grid;
  gap: 6px;
  margin-top: 10px;
  padding-left: 12px;
  border-left: 2px solid rgba(73, 197, 143, 0.38);
}

.reply-item {
  padding: 2px 0 4px 10px;
}

.reply-mainline {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.reply-sentence {
  display: inline;
  min-width: 0;
  color: #d5dbe3;
  white-space: normal;
  overflow-wrap: anywhere;
}

.reply-sentence strong {
  display: inline;
}

.reply-time {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 13px;
}

.reply-actions {
  margin-top: 4px;
  gap: 6px;
}

.deleted-comment {
  font-style: italic;
}

.hidden {
  display: none;
}

.archive-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

.archive-item {
  display: grid;
  grid-template-columns: 128px minmax(0, 1fr);
  min-height: 192px;
  overflow: hidden;
}

@media (max-width: 680px) {
  .topbar,
  .page-title,
  .detail {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar {
    display: grid;
  }

  nav {
    justify-content: space-between;
  }

  .movie-card,
  .archive-item,
  .detail,
  .page-with-sidebar {
    grid-template-columns: 1fr;
  }

  .member-sidebar {
    position: static;
  }

  .poster-slot {
    width: 100%;
    height: auto;
    min-height: 0;
    aspect-ratio: 2 / 3;
    max-height: 360px;
  }

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

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

  .reply-mainline {
    align-items: flex-start;
    flex-direction: column;
    gap: 2px;
  }

  .reply-time {
    flex: 0 1 auto;
  }

  .group-item,
  .manage-member-row,
  .group-controls,
  .nickname-form {
    align-items: stretch;
    flex-direction: column;
  }

  .group-controls {
    justify-content: stretch;
  }

  .nickname-form label {
    min-width: 0;
  }

  .button {
    width: 100%;
  }
}
