:root {
  color-scheme: light;
  --bg: #f7f5ef;
  --ink: #1d2528;
  --muted: #69777c;
  --line: #d8ddd9;
  --panel: #fffdf7;
  --panel-strong: #eef5ef;
  --accent: #0f766e;
  --accent-dark: #0a4f4a;
  --warn: #b45309;
  --danger: #b42318;
  --ok: #15803d;
  --shadow: 0 18px 45px rgba(32, 42, 36, 0.12);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(15, 118, 110, 0.08), transparent 320px),
    var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

body.app-locked {
  overflow: hidden;
}

body.auth-loading {
  overflow: hidden;
}

body.app-locked .app-shell,
body.app-locked dialog,
body.auth-loading .app-shell,
body.auth-loading dialog {
  visibility: hidden;
}

.lock-screen {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 20px;
  background:
    linear-gradient(180deg, rgba(15, 118, 110, 0.14), transparent 360px),
    var(--bg);
}

.lock-screen[hidden] {
  display: none !important;
}

.lock-card {
  display: grid;
  gap: 15px;
  width: min(420px, 100%);
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.lock-card h1,
.lock-card p {
  margin: 0;
}

.lock-card label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-weight: 800;
}

.lock-card input {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink);
  padding: 10px 12px;
}

.password-field {
  position: relative;
  display: block;
}

.password-field input {
  padding-right: 52px;
}

.password-toggle {
  position: absolute;
  top: 50%;
  right: 8px;
  min-height: 30px;
  padding: 0 8px;
  border: 0;
  border-radius: 6px;
  background: var(--panel-strong);
  color: var(--accent-dark);
  font-size: 16px;
  font-weight: 900;
  line-height: 1;
  transform: translateY(-50%);
}

.lock-links {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.link-button {
  border: 0;
  background: transparent;
  color: var(--accent-dark);
  font-weight: 900;
}

.lock-error {
  min-height: 20px;
  color: var(--danger);
  font-weight: 800;
}

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 34px 0 56px;
}

.topbar,
.section-heading,
.control-row,
.dialog-header,
.dialog-actions {
  display: flex;
  align-items: center;
}

.topbar {
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 24px;
}

.topbar h1,
.section-heading h2,
.dialog-header h2,
.empty-state h3 {
  margin: 0;
  letter-spacing: 0;
}

.topbar h1 {
  font-size: clamp(32px, 5vw, 56px);
  line-height: 1;
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

.topbar-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
  align-items: center;
}

.primary-button,
.ghost-button,
.icon-button,
.segment,
.chip-button {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 8px;
  transition:
    transform 0.16s ease,
    border-color 0.16s ease,
    background 0.16s ease;
}

.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 16px;
  background: var(--accent);
  color: white;
  font-weight: 800;
  box-shadow: 0 10px 22px rgba(15, 118, 110, 0.22);
}

.ghost-button {
  padding: 0 14px;
  background: white;
  color: var(--ink);
  border-color: var(--line);
}

.ghost-button.danger {
  color: var(--danger);
}

.icon-button {
  width: 44px;
  flex: 0 0 44px;
  background: white;
  color: var(--ink);
  border-color: var(--line);
  font-size: 22px;
}

.backup-status,
.save-status {
  min-width: 120px;
  max-width: 260px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.save-status {
  min-width: 132px;
}

.backup-status[data-status="busy"] {
  color: var(--warn);
}

.backup-status[data-status="success"] {
  color: var(--accent-dark);
}

.backup-status[data-status="error"] {
  color: var(--danger);
}

.save-status[data-status="busy"] {
  color: var(--warn);
}

.save-status[data-status="saved"] {
  color: var(--accent-dark);
}

.save-status[data-status="pending"] {
  color: var(--danger);
}

.save-status[data-status="local"] {
  color: var(--muted);
}

.primary-button:hover,
.ghost-button:hover,
.icon-button:hover,
.segment:hover,
.chip-button:hover {
  transform: translateY(-1px);
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.summary-item {
  appearance: none;
  text-align: left;
  min-height: 104px;
  padding: 18px;
  border: 1px solid rgba(15, 118, 110, 0.18);
  border-radius: 8px;
  background: var(--panel);
  color: inherit;
  box-shadow: 0 12px 28px rgba(32, 42, 36, 0.08);
}

.summary-button {
  cursor: pointer;
}

.summary-button:hover,
.summary-button.active {
  border-color: rgba(15, 118, 110, 0.56);
  box-shadow: 0 14px 30px rgba(15, 118, 110, 0.15);
}

.summary-button.active {
  background: #eef8f5;
}

.summary-label {
  display: block;
  color: var(--muted);
  font-weight: 700;
}

.summary-item strong {
  display: block;
  margin-top: 12px;
  font-size: 30px;
  line-height: 1;
}

.summary-detail {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  line-height: 1.2;
}

.control-row {
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 22px;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1 1 320px;
  min-height: 48px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

.search-box span {
  color: var(--muted);
  font-size: 22px;
}

.search-box input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
}

.region-filter {
  flex: 0 0 150px;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink);
  padding: 0 12px;
  font-weight: 800;
}

.segmented-control {
  display: flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.76);
}

.segment {
  min-width: 70px;
  padding: 0 12px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
}

.segment.active {
  background: var(--ink);
  color: white;
}

.timeline-band,
.calendar-section,
.shows-section {
  margin-top: 20px;
}

.section-heading {
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.section-heading h2 {
  font-size: 22px;
}

.section-heading span {
  color: var(--muted);
  font-weight: 700;
}

.bulk-toolbar {
  display: grid;
  grid-template-columns: 1fr minmax(130px, 170px) auto auto auto;
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
}

.bulk-toolbar span {
  color: var(--muted);
  font-weight: 800;
}

.timeline-list {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(220px, 1fr);
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 4px;
}

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

.timeline-card,
.calendar-row,
.show-card,
.empty-state {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 14px 30px rgba(32, 42, 36, 0.08);
}

.timeline-card {
  padding: 15px;
}

.timeline-card.overdue {
  border-color: rgba(180, 35, 24, 0.28);
  background: #fff8f4;
}

.timeline-card.returning {
  border-color: rgba(15, 118, 110, 0.3);
  background: #f3fbf7;
}

.calendar-row {
  display: grid;
  grid-template-columns: 120px 1fr auto;
  align-items: center;
  gap: 12px;
  min-height: 58px;
  padding: 12px 14px;
}

.calendar-row strong,
.calendar-row span {
  display: block;
}

.calendar-row span {
  color: var(--muted);
  margin-top: 2px;
}

.calendar-empty {
  color: var(--muted);
  padding: 14px;
}

.date-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 9px;
  border-radius: 999px;
  background: var(--panel-strong);
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 900;
}

.date-pill.today {
  background: #fff1d6;
  color: var(--warn);
}

.date-pill.overdue {
  background: #ffe7e2;
  color: var(--danger);
}

.date-pill.returning {
  background: #dff5ec;
  color: var(--teal-dark);
}

.timeline-card h3,
.show-card h3 {
  margin: 12px 0 6px;
  font-size: 18px;
  line-height: 1.18;
}

.timeline-title-button {
  border: 0;
  background: transparent;
  color: inherit;
  padding: 0;
  font: inherit;
  font-weight: 900;
  text-align: left;
}

.timeline-title-button:hover {
  color: var(--accent-dark);
}

.timeline-card p,
.show-meta,
.show-notes,
.empty-state p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.shows-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}

.show-card {
  display: flex;
  flex-direction: column;
  min-height: 250px;
  padding: 18px;
}

.show-card.selected {
  border-color: rgba(15, 118, 110, 0.55);
  box-shadow: 0 14px 34px rgba(15, 118, 110, 0.15);
}

.show-card.duplicate {
  border-color: rgba(180, 35, 24, 0.28);
}

.show-card-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.show-title-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.show-select {
  display: grid;
  place-items: center;
  width: 24px;
  min-width: 24px;
  min-height: 24px;
}

.show-select input {
  width: 18px;
  min-height: 18px;
}

.poster-thumb {
  width: 48px;
  height: 66px;
  flex: 0 0 auto;
  border-radius: 6px;
  background: linear-gradient(135deg, #dce8df, #f8f5eb);
  object-fit: cover;
}

.sync-note {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
}

.progress-meter {
  height: 8px;
  margin: 3px 0 12px;
  overflow: hidden;
  border-radius: 999px;
  background: #e4e9e5;
}

.progress-meter span {
  display: block;
  height: 100%;
  width: var(--progress, 0%);
  border-radius: inherit;
  background: var(--accent);
}

.backlog-note {
  color: var(--danger);
  font-weight: 800;
}

.status-badge {
  flex: 0 0 auto;
  align-self: flex-start;
  min-height: 28px;
  padding: 5px 9px;
  border-radius: 999px;
  background: #e7f3ef;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 900;
}

.status-badge.want {
  background: #eef0ff;
  color: #3f4b97;
}

.status-badge.paused {
  background: #f4eee4;
  color: #7c4a03;
}

.status-badge.dropped {
  background: #f7e8e8;
  color: #9b1c1c;
}

.status-badge.archived {
  background: #eceff1;
  color: #526166;
}

.progress-line {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 16px 0 12px;
}

.progress-line strong {
  font-size: 28px;
}

.show-notes {
  min-height: 48px;
}

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

.chip-button {
  min-height: 36px;
  padding: 0 10px;
  background: white;
  border-color: var(--line);
  color: var(--ink);
  font-weight: 800;
}

.chip-button.done {
  background: var(--ink);
  color: white;
}

.empty-state {
  grid-column: 1 / -1;
  display: grid;
  place-items: center;
  min-height: 300px;
  padding: 34px 20px;
  text-align: center;
}

.empty-mark {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  margin-bottom: 14px;
  border-radius: 50%;
  background: var(--panel-strong);
  color: var(--accent-dark);
  font-size: 38px;
  font-weight: 500;
}

.empty-state p {
  max-width: 360px;
  margin: 8px 0 18px;
}

.update-toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 80;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 18px 42px rgba(32, 42, 36, 0.18);
}

.update-toast span {
  color: var(--ink);
  font-weight: 900;
}

.show-dialog,
.detail-dialog,
.actor-dialog,
.settings-dialog,
.batch-dialog {
  width: min(560px, calc(100% - 28px));
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
}

.show-dialog {
  width: min(980px, calc(100% - 28px));
}

.detail-dialog,
.actor-dialog {
  width: min(820px, calc(100% - 28px));
}

.show-dialog::backdrop,
.detail-dialog::backdrop,
.actor-dialog::backdrop,
.settings-dialog::backdrop,
.batch-dialog::backdrop {
  background: rgba(17, 24, 24, 0.42);
}

.show-form,
.detail-panel,
.actor-panel {
  display: grid;
  gap: 16px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

#showForm {
  max-height: min(86dvh, 780px);
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
}

.add-workspace {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(310px, 0.95fr) minmax(360px, 1.05fr);
  gap: 16px;
  align-items: start;
  overflow: hidden;
}

.add-search-column,
.add-fields-column {
  min-height: 0;
  display: grid;
  gap: 14px;
}

.add-search-column {
  max-height: 100%;
  overflow: hidden;
}

.add-fields-column {
  max-height: 100%;
  overflow: auto;
  padding-right: 2px;
}

.detail-hero {
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 16px;
  align-items: center;
}

.detail-hero img,
.detail-poster-placeholder {
  width: 92px;
  height: 128px;
  border-radius: 8px;
  background: linear-gradient(135deg, #dce8df, #f8f5eb);
  object-fit: cover;
}

.detail-stats {
  display: grid;
  gap: 8px;
}

.detail-stats strong {
  font-size: 30px;
}

.genre-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.genre-list span {
  padding: 4px 8px;
  border-radius: 999px;
  background: #e8f3ef;
  color: var(--teal-dark);
  font-size: 12px;
  font-weight: 800;
}

.detail-info {
  display: grid;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf8;
}

.detail-info p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.cast-header {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 8px;
  align-items: center;
}

.cast-header strong {
  font-size: 14px;
}

.cast-header span {
  color: var(--muted);
  font-size: 13px;
}

.cast-strip {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
  gap: 10px;
}

.cast-card {
  min-width: 0;
  display: grid;
  gap: 5px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.cast-card img,
.cast-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, #dce8df, #f8f5eb);
  object-fit: cover;
}

.cast-card strong {
  overflow-wrap: anywhere;
  font-size: 13px;
}

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

.actor-match-list {
  display: grid;
  gap: 10px;
}

.actor-match-row {
  min-height: 72px;
  display: grid;
  grid-template-columns: 48px 1fr;
  gap: 12px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.actor-match-row img,
.actor-show-placeholder {
  width: 48px;
  height: 64px;
  border-radius: 6px;
  background: linear-gradient(135deg, #dce8df, #f8f5eb);
  object-fit: cover;
}

.actor-match-row > span {
  display: grid;
  gap: 3px;
}

.actor-match-row span span {
  color: var(--muted);
  font-size: 13px;
}

.episode-toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.episode-toolbar select {
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink);
}

.season-state-panel {
  display: grid;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(248, 245, 235, 0.72);
}

.season-state-heading {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: baseline;
  justify-content: space-between;
}

.season-state-heading span {
  color: var(--muted);
  font-size: 13px;
}

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

.season-state-row {
  display: grid;
  grid-template-columns: 46px 74px 130px 1fr;
  gap: 8px;
  align-items: center;
}

.season-state-poster {
  width: 42px;
  height: 56px;
  border-radius: 6px;
  background: linear-gradient(135deg, #dce8df, #f8f5eb);
  object-fit: cover;
}

.season-state-row select,
.season-state-row input {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink);
  padding: 0 10px;
}

.episode-list {
  display: grid;
  gap: 8px;
  max-height: 420px;
  overflow: auto;
  padding-right: 2px;
}

.episode-row {
  display: grid;
  grid-template-columns: 86px 1fr auto;
  gap: 10px;
  align-items: center;
  min-height: 54px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

.episode-row.watched {
  background: #f1f7f2;
}

.episode-row.current {
  border-color: rgba(15, 118, 110, 0.42);
}

.episode-row.future {
  opacity: 0.66;
}

.episode-code {
  font-weight: 900;
}

.episode-title {
  display: block;
  font-weight: 800;
}

.episode-date {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-top: 2px;
}

.history-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.history-pill,
.batch-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 9px;
  border-radius: 999px;
  background: var(--panel-strong);
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 900;
}

.batch-results {
  display: grid;
  gap: 8px;
}

.batch-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

.batch-row.fail {
  border-color: rgba(180, 35, 24, 0.3);
  background: #fff8f4;
}

.dialog-header,
.dialog-actions {
  justify-content: space-between;
  gap: 12px;
}

.show-form label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-weight: 800;
}

.show-form input,
.show-form select,
.show-form textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink);
  padding: 10px 12px;
  outline: 0;
}

.lookup-panel,
.season-panel {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: rgba(238, 245, 239, 0.54);
}

.lookup-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.lookup-row span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

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

.admin-user-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
}

.admin-user-row span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-align: right;
}

.lookup-results {
  display: grid;
  gap: 8px;
  max-height: min(54dvh, 520px);
  overflow: auto;
  padding-right: 2px;
}

.lookup-result {
  display: grid;
  grid-template-columns: 72px 1fr auto;
  gap: 12px;
  align-items: center;
  min-height: 108px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  text-align: left;
}

.lookup-result.duplicate {
  border-color: rgba(220, 38, 38, 0.32);
  background: #fff7f6;
  cursor: not-allowed;
  opacity: 1;
}

.lookup-result.duplicate b {
  color: var(--danger);
}

.lookup-result img,
.lookup-poster-placeholder {
  width: 72px;
  height: 96px;
  border-radius: 6px;
  background: var(--panel-strong);
  object-fit: cover;
}

.lookup-result strong,
.lookup-result span {
  display: block;
}

.lookup-result span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
}

.lookup-result b {
  color: var(--accent-dark);
  font-size: 13px;
}

.season-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.season-button {
  min-height: 36px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink);
  font-weight: 800;
}

.season-button.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.show-form textarea {
  resize: vertical;
}

.show-form input:focus,
.show-form select:focus,
.show-form textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.13);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.toggle-row {
  display: flex !important;
  grid-template-columns: none;
  align-items: center;
  gap: 10px !important;
}

.toggle-row input {
  width: 18px;
  min-height: 18px;
}

.dialog-actions {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  padding-top: 4px;
  border-top: 1px solid var(--line);
}

@media (max-width: 820px) {
  .app-shell {
    width: min(100% - 22px, 720px);
    padding-top: 20px;
  }

  .topbar,
  .control-row {
    align-items: stretch;
    flex-direction: column;
  }

  .search-box {
    flex: 0 0 auto;
  }

  .region-filter {
    flex: 0 0 auto;
    width: 100%;
  }

  .topbar-actions {
    justify-content: space-between;
  }

  .summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .segmented-control {
    overflow-x: auto;
  }

  .segment {
    flex: 0 0 auto;
  }

  .timeline-list {
    grid-auto-columns: minmax(240px, 86%);
  }

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

@media (min-width: 821px) and (max-width: 1100px) {
  .app-shell {
    width: min(100% - 36px, 960px);
  }

  .summary-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .shows-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .control-row {
    align-items: stretch;
    flex-wrap: wrap;
  }

  .search-box {
    flex-basis: calc(100% - 170px);
  }

  .segmented-control {
    flex: 1 1 100%;
    justify-content: space-between;
  }

  .segment {
    flex: 1 1 auto;
  }
}

@media (max-width: 560px) {
  body {
    background:
      linear-gradient(180deg, rgba(15, 118, 110, 0.1), transparent 240px),
      var(--bg);
  }

  .app-shell {
    width: calc(100% - 18px);
    padding: 16px 0 32px;
  }

  .topbar {
    gap: 14px;
    margin-bottom: 16px;
  }

  .topbar h1 {
    font-size: 40px;
    line-height: 0.98;
  }

  .eyebrow {
    font-size: 12px;
  }

  .summary-grid,
  .form-grid,
  .detail-hero,
  .episode-row,
  .season-state-row {
    grid-template-columns: 1fr;
  }

  .summary-grid {
    gap: 10px;
    margin-bottom: 14px;
  }

  .summary-item {
    min-height: 82px;
    padding: 14px;
  }

  .summary-item strong {
    margin-top: 8px;
    font-size: 28px;
  }

  .topbar-actions,
  .dialog-actions {
    display: grid;
    grid-template-columns: repeat(4, minmax(44px, 1fr));
    width: 100%;
  }

  .topbar-actions .primary-button {
    grid-column: 1 / -1;
    width: 100%;
  }

  .icon-button {
    width: 100%;
    min-width: 44px;
  }

  .backup-status,
  .save-status {
    grid-column: 1 / -1;
    min-width: 0;
    max-width: none;
  }

  .control-row {
    gap: 10px;
    margin-bottom: 16px;
  }

  .segmented-control {
    width: 100%;
    padding: 4px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
  }

  .segment {
    min-width: 74px;
    scroll-snap-align: start;
  }

  .bulk-toolbar {
    grid-template-columns: 1fr 1fr;
  }

  .bulk-toolbar span {
    grid-column: 1 / -1;
  }

  .timeline-list {
    grid-auto-columns: minmax(252px, 88%);
  }

  .show-dialog {
    width: min(720px, calc(100% - 22px));
  }

  #showForm {
    max-height: 88dvh;
    overflow: auto;
  }

  .add-workspace {
    grid-template-columns: 1fr;
    overflow: visible;
  }

  .add-search-column,
  .add-fields-column {
    max-height: none;
    overflow: visible;
  }

  .lookup-results {
    max-height: 360px;
  }

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

  .show-card {
    min-height: 0;
    padding: 16px;
  }

  .show-card-header {
    gap: 10px;
  }

  .show-title-row {
    min-width: 0;
  }

  .show-card h3 {
    overflow-wrap: anywhere;
  }

  .progress-line {
    display: grid;
    gap: 4px;
  }

  .card-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .chip-button {
    width: 100%;
  }

  .lookup-row,
  .lookup-result {
    grid-template-columns: 1fr;
  }

  .lookup-result {
    grid-template-columns: 72px 1fr;
    min-height: 108px;
  }

  .lookup-row {
    display: grid;
  }

  .lookup-result img,
  .lookup-poster-placeholder {
    display: block;
    width: 72px;
    height: 96px;
  }

  .show-dialog,
  .detail-dialog,
  .actor-dialog,
  .settings-dialog,
  .batch-dialog {
    width: 100vw;
    max-width: none;
    max-height: 100dvh;
    margin: 0;
  }

  .show-form,
  .detail-panel,
  .actor-panel {
    min-height: 100dvh;
    max-height: 100dvh;
    overflow: auto;
    border-radius: 0;
    padding: 18px;
  }

  .detail-hero {
    align-items: start;
  }

  .detail-hero img,
  .detail-poster-placeholder {
    width: 112px;
    height: 150px;
  }

  .episode-toolbar {
    display: grid;
    grid-template-columns: 1fr;
  }

  .dialog-actions {
    grid-template-columns: 1fr 1fr;
  }

  .dialog-actions span {
    display: none;
  }
}

@media (max-width: 380px) {
  .topbar h1 {
    font-size: 34px;
  }

  .summary-item strong {
    font-size: 25px;
  }

  .poster-thumb {
    width: 42px;
    height: 58px;
  }
}
