:root {
  --page-bg: linear-gradient(180deg, #f7f1e6 0%, #f2efe8 42%, #eceae1 100%);
  --panel-bg: rgba(255, 255, 255, 0.78);
  --panel-border: rgba(34, 28, 19, 0.12);
  --ink: #1f1a14;
  --muted: #645a4d;
  --accent: #8c5d1d;
  --accent-soft: #f1dfbf;
  --selected: #d7852f;
  --partial: #3e81c6;
  --planned: #4f9b4a;
  --card-bg: #fffdf8;
  --card-hover: #f4efe5;
  --empty: #ebe7df;
  --shadow: 0 18px 40px rgba(60, 43, 22, 0.09);
  --radius-xl: 28px;
  --radius-lg: 18px;
  --radius-md: 12px;
  --cell-size: 96px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: "Segoe UI", "Noto Sans TC", "Hiragino Sans", sans-serif;
  color: var(--ink);
  background: var(--page-bg);
}

body::before {
  content: none;
}

button,
select {
  font: inherit;
}

.page-shell {
  position: relative;
  max-width: 1355px;
  margin: 0 auto;
  padding: 32px 20px 56px;
}

.hero,
.control-panel,
.board-panel,
.legend-panel,
.site-footer {
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-xl);
  background: var(--panel-bg);
  box-shadow: var(--shadow);
}

.hero {
  position: relative;
  padding: 28px;
}

.hero-content {
  max-width: 760px;
  min-width: 0;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.hero h1 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 3.5rem);
  line-height: 1.02;
}

.hero-copy {
  max-width: 52rem;
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 1rem;
}

.threads-link {
  position: absolute;
  right: 22px;
  bottom: 18px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  border: 1px solid rgba(31, 26, 20, 0.12);
  border-radius: 999px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.82);
  text-decoration: none;
  box-shadow: 0 10px 22px rgba(60, 43, 22, 0.08);
  transition:
    transform 0.18s ease,
    background-color 0.18s ease,
    border-color 0.18s ease;
}

.threads-link:hover {
  transform: translateY(-1px);
  background: #fff;
  border-color: rgba(31, 26, 20, 0.2);
}

.threads-link__logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  color: #fff;
  background: #111;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1;
}

.threads-link__label {
  font-size: 0.92rem;
  font-weight: 600;
}

.sun-widget-card {
  flex: 0 0 340px;
  max-width: 100%;
  padding: 12px;
  border: 1px solid rgba(31, 26, 20, 0.1);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.52);
}

.sun-widget-card iframe {
  display: block;
  width: 100%;
  max-width: 340px;
  margin: 0 auto;
  border: 0;
  border-radius: 14px;
}

.sun-widget-credit {
  margin-top: 8px;
  font-size: 12px;
  text-align: center;
}

.sun-widget-credit a {
  color: var(--muted);
  text-decoration: none;
}

.sun-widget-credit a:hover {
  text-decoration: underline;
}

.hero-links {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin-top: 18px;
}

.hero-link,
.hero-note {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0 14px;
  border-radius: 999px;
}

.hero-link {
  color: #fff;
  background: var(--accent);
  text-decoration: none;
}

.hero-note {
  color: var(--muted);
  background: rgba(140, 93, 29, 0.08);
}

.control-panel {
  display: flex;
  flex-wrap: wrap;
  gap: 16px 24px;
  align-items: end;
  margin-top: 18px;
  padding: 20px 22px;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.control-group label,
.control-group span {
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 600;
}

#range-filter {
  min-width: 190px;
  padding: 11px 14px;
  border: 1px solid rgba(31, 26, 20, 0.14);
  border-radius: 12px;
  background: #fff;
}

.segmented-control {
  display: inline-flex;
  gap: 8px;
  padding: 6px;
  border-radius: 999px;
  background: rgba(140, 93, 29, 0.08);
}

.lang-button,
.action-button {
  cursor: pointer;
  transition:
    transform 0.18s ease,
    background-color 0.18s ease,
    color 0.18s ease,
    border-color 0.18s ease;
}

.lang-button {
  min-width: 86px;
  padding: 10px 16px;
  border: 0;
  border-radius: 999px;
  color: var(--muted);
  background: transparent;
}

.lang-button.is-active {
  color: #fff;
  background: #3e81c6;
}

.status-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.status-button {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 46px;
  padding: 0 16px;
  border: 1px solid rgba(31, 26, 20, 0.14);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.72);
  cursor: pointer;
  transition:
    transform 0.18s ease,
    background-color 0.18s ease,
    color 0.18s ease,
    border-color 0.18s ease,
    box-shadow 0.18s ease;
}

.status-button:hover {
  transform: translateY(-1px);
  background: #fff;
}

.status-button.is-active {
  color: var(--ink);
  border-color: rgba(31, 26, 20, 0.22);
  box-shadow: 0 8px 18px rgba(60, 43, 22, 0.08);
}

.status-button__swatch {
  width: 16px;
  height: 16px;
  border: 1px solid rgba(31, 26, 20, 0.14);
  border-radius: 5px;
  flex: 0 0 auto;
}

.status-button--no-swatch {
  justify-content: center;
}

.board-title-row {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 16px;
  width: 100%;
}

.board-status-group {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  width: 100%;
}

.board-status-label {
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 600;
}

.board-panel {
  margin-top: 18px;
  padding: 18px;
}

.board-header {
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 14px;
  padding: 4px 8px 14px;
  border-bottom: 1px solid rgba(31, 26, 20, 0.1);
}

.board-header h2,
.watch-count {
  margin: 0;
}

.board-header h2 {
  font-size: 1.2rem;
}

.board-description {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.watch-count {
  color: var(--muted);
  white-space: nowrap;
}

.board-header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: space-between;
  width: 100%;
}

.board-inline-actions {
  display: inline-flex;
  gap: 8px;
  flex-wrap: wrap;
}

.board-scroll {
  overflow-x: auto;
  padding-bottom: 4px;
}

.board {
  display: inline-flex;
  flex-direction: column;
  width: max-content;
  min-width: fit-content;
  border: 1px solid rgba(31, 26, 20, 0.12);
  background: rgba(255, 255, 255, 0.74);
}

.board-row {
  display: flex;
  border-bottom: 1px solid rgba(31, 26, 20, 0.12);
}

.board-row:last-child {
  border-bottom: 0;
}

.year-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 120px;
  min-width: 120px;
  padding: 12px;
  min-height: var(--cell-size);
  text-align: center;
  line-height: 1.2;
  color: #fff;
  background: var(--accent);
  font-weight: 700;
  letter-spacing: 0.04em;
}

.anime-grid {
  display: grid;
  grid-template-columns: repeat(12, var(--cell-size));
}

.anime-cell {
  width: var(--cell-size);
  min-width: var(--cell-size);
  height: var(--cell-size);
  border: 0;
  border-left: 1px solid rgba(31, 26, 20, 0.12);
  border-radius: 0;
}

.anime-cell {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
  color: var(--ink);
  background: var(--card-bg);
  text-align: center;
}

.anime-cell:hover {
  background: var(--card-hover);
  transform: translateY(-1px);
}

.anime-cell.is-selected {
  color: #fff;
  background: var(--selected);
}

.anime-cell.is-partial {
  color: #fff;
  background: var(--partial);
}

.anime-cell.is-planned {
  color: #fff;
  background: var(--planned);
}

.anime-cell span {
  display: -webkit-box;
  overflow: hidden;
  font-size: 0.86rem;
  line-height: 1.2;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.action-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
  margin-top: 20px;
}

.action-button {
  min-height: 46px;
  padding: 0 18px;
  border: 1px solid rgba(31, 26, 20, 0.16);
  border-radius: 14px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.7);
}

.action-button:hover {
  transform: translateY(-1px);
  background: #fff;
}

.action-button.primary {
  color: #fff;
  border-color: transparent;
  background: #3e81c6;
}

.action-button--compact {
  min-height: 38px;
  padding: 0 14px;
  border-radius: 999px;
}

#export-button {
  border-color: rgba(140, 93, 29, 0.2);
}

.legend-panel {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  justify-content: center;
  margin-top: 18px;
  padding: 16px 18px;
}

.legend-item {
  display: inline-flex;
  gap: 10px;
  align-items: center;
  color: var(--muted);
}

.legend-swatch {
  width: 18px;
  height: 18px;
  border: 1px solid rgba(31, 26, 20, 0.14);
  border-radius: 5px;
}

.swatch-selected {
  border-color: transparent;
  background: var(--selected);
}

.swatch-partial {
  border-color: transparent;
  background: var(--partial);
}

.swatch-planned {
  border-color: transparent;
  background: var(--planned);
}

.swatch-default {
  background: var(--card-bg);
}

.site-footer {
  margin-top: 18px;
  padding: 22px;
  text-align: center;
  color: var(--muted);
}

.footer-lead {
  margin: 0 0 14px;
  color: var(--ink);
  font-size: 1rem;
  font-weight: 600;
}

.footer-widget-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: 14px;
}

@media (max-width: 820px) {
  .board-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .board-header-actions {
    width: 100%;
    justify-content: space-between;
  }

  .board-title-row {
    width: 100%;
    align-items: flex-start;
  }

  .board-status-group {
    width: 100%;
  }

  .status-picker {
    width: 100%;
  }
}

@media (max-width: 640px) {
  :root {
    --cell-size: 78px;
  }

  .page-shell {
    padding: 20px 14px 40px;
  }

  .hero,
  .control-panel,
  .board-panel,
  .legend-panel,
  .site-footer {
    border-radius: 22px;
  }

  .hero,
  .control-panel,
  .board-panel,
  .site-footer {
    padding-left: 16px;
    padding-right: 16px;
  }

  .hero {
    padding-bottom: 74px;
  }

  .threads-link {
    right: 16px;
    bottom: 14px;
    padding: 7px 12px;
  }

  .sun-widget-card {
    flex-basis: 100%;
    width: 100%;
    padding: 10px;
  }

  .year-cell {
    width: 98px;
    min-width: 98px;
    font-size: 0.9rem;
  }

  .anime-cell span {
    font-size: 0.76rem;
  }

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