:root {
  color-scheme: dark;
  --bg: #0c0d10;
  --surface: #14161b;
  --surface-2: #1c1f26;
  --line: rgba(255, 255, 255, 0.09);
  --text: #f4f5f7;
  --muted: #9aa3b2;
  --soft: #c9d0dc;
  --accent: #e9b96f;
  --accent-strong: #f28f5b;
  --ok: #78d6a3;
  --danger: #d85f5f;
  --radius: 8px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

html {
  scroll-behavior: smooth;
}

html.light {
  color-scheme: light;
  --bg: #fdf8f4;
  --surface: #fffcfa;
  --surface-2: #f5ede6;
  --line: rgba(0, 0, 0, 0.06);
  --text: #3d3830;
  --muted: #a09890;
  --soft: #706860;
  --accent: #f0943a;
  --accent-strong: #e07535;
  --ok: #7abf98;
  --danger: #d47878;
}

html.light .tab:not(.active),
html.light .secondary-btn,
html.light .favorite-btn.add,
html.light .icon-btn {
  background: var(--surface-2);
  color: var(--soft);
}

html.light .settings-top-btn {
  background: var(--accent);
  color: #17130d;
}

html.light .favorite-btn.favorite {
  background: var(--accent);
  color: var(--surface-2);
}

html.light .badge-green {
  color: #1a6640;
  background: rgba(62, 141, 93, 0.18);
}

html.light .badge-orange {
  color: #7a3a10;
  background: rgba(170, 93, 44, 0.18);
}

html.light .badge-purple {
  color: #4a2888;
  background: rgba(112, 84, 170, 0.18);
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 0;
}

.toggle-switch {
  position: relative;
  width: 44px;
  height: 26px;
  background: var(--surface-2);
  border-radius: 999px;
  border: 1px solid var(--line);
  flex-shrink: 0;
  transition: background 220ms var(--ease), border-color 220ms var(--ease);
}

.toggle-switch::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  background: var(--muted);
  border-radius: 50%;
  transition: transform 220ms var(--ease), background 220ms var(--ease);
}

.toggle-switch[aria-checked="true"] {
  background: var(--accent);
  border-color: transparent;
}

.toggle-switch[aria-checked="true"]::after {
  transform: translateX(18px);
  background: #fff;
}

html.light .small-btn:not(.primary-link) {
  background: var(--surface-2);
  color: var(--soft);
}

html.light body {
  background:
    linear-gradient(180deg, rgba(240, 148, 58, 0.08), transparent 280px),
    #fdf8f4;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--text);
  background:
    linear-gradient(180deg, rgba(233, 185, 111, 0.08), transparent 280px),
    #0c0d10;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
}

body.settings-open {
  overflow: hidden;
}

body.settings-open::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(0, 0, 0, 0.46);
  backdrop-filter: blur(2px);
}

body.settings-open .header,
body.settings-open .main-panel,
body.settings-open .status-box {
  pointer-events: none;
}

button,
input,
select {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: transparent;
  cursor: pointer;
}

.app {
  width: min(920px, 100%);
  margin: 0 auto;
  padding: 20px;
}

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

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(26px, 4vw, 42px);
  font-weight: 850;
  line-height: 1.08;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 14px;
  font-size: 18px;
}

h3 {
  margin-bottom: 8px;
  font-size: 14px;
}

.settings-top-btn,
.primary-btn,
.secondary-btn,
.danger-btn,
.small-btn,
.icon-btn,
.favorite-btn,
.tab {
  font-weight: 750;
  transition: background 180ms var(--ease), color 180ms var(--ease), transform 180ms var(--ease), box-shadow 180ms var(--ease);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.tab,
.settings-top-btn {
  min-height: 40px;
  padding: 0 14px;
}

.small-btn {
  min-height: 30px;
  padding: 6px 8px;
}
.secondary-btn:hover,
.danger-btn:hover,
.tab:hover,
.small-btn:hover,
.favorite-btn:hover {
  transform: translateY(-1px);
}

.settings-top-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 14px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.075);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.icon-btn {
  width: 32px;
  height: 32px;
  padding: 0;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.04);
  font-size: 20px;
  line-height: 1;
}

.settings-top-btn[aria-expanded="true"],
.tab.active,
.primary-btn,
.small-btn.primary-link {
  color: #17130d;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
}

.status-box {
  position: fixed;
  top: max(14px, env(safe-area-inset-top));
  right: max(14px, env(safe-area-inset-right));
  z-index: 80;
  width: min(360px, calc(100vw - 28px));
  margin: 0;
  padding: 10px 12px;
  color: var(--soft);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 16px 34px rgba(0, 0, 0, 0.36);
  animation: toast-in 160ms ease-out;
  line-height: 1.35;
}

.status-box.error {
  color: #ffd1d1;
  background: #481414;
  border-color: rgba(216, 95, 95, 0.42);
}

.status-box.success {
  color: #c9f7db;
  background: #103622;
  border-color: rgba(120, 214, 163, 0.35);
}

.status-box.warn {
  color: #ffe1b7;
  background: #462d10;
  border-color: rgba(233, 185, 111, 0.42);
}

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

@keyframes panel-in {
  from {
    opacity: 0;
    transform: translateY(-8px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes list-in {
  from {
    opacity: 0;
    transform: translateX(var(--swipe-shift, 10px));
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes fav-pop {
  0%   { transform: scale(1); }
  35%  { transform: scale(1.4); }
  65%  { transform: scale(0.88); }
  100% { transform: scale(1); }
}

.favorite-btn.pop {
  animation: fav-pop 380ms var(--ease) forwards;
}

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


.hidden {
  display: none !important;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
  align-items: start;
  transition: opacity 180ms var(--ease);
}

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

.next-release {
  display: grid;
  grid-template-columns: 98px minmax(0, 1fr);
  gap: 16px;
  min-height: 150px;
  margin-bottom: 14px;
  padding: 14px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
}

.next-release.empty {
  display: grid;
  grid-template-columns: 1fr;
  place-items: center;
  min-height: 132px;
  text-align: center;
  cursor: default;
}

.next-cover {
  width: 98px;
  height: 140px;
  object-fit: cover;
  background: #242832;
  border-radius: var(--radius);
}

.next-cover.placeholder,
.cover.placeholder {
  display: grid;
  place-items: center;
  color: var(--accent);
  background: #242832;
  font-size: 28px;
  font-weight: 850;
}

.next-content {
  display: flex;
  min-width: 0;
  flex-direction: column;
  justify-content: center;
}

.next-label {
  width: fit-content;
  margin-bottom: 8px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.next-title {
  margin-bottom: 6px;
  font-size: clamp(20px, 3vw, 30px);
  font-weight: 850;
  line-height: 1.12;
  overflow-wrap: anywhere;
}

.next-episode {
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.next-countdown {
  width: fit-content;
  margin-bottom: 8px;
  color: var(--text);
  font-size: clamp(20px, 3vw, 28px);
  font-weight: 850;
  line-height: 1;
}

.next-meta {
  color: var(--muted);
  font-size: 12px;
}

.toolbar {
  display: grid;
    gap: 8px;
    margin-bottom: 14px;
    padding: 6px;
    background: rgba(255, 255, 255, 0.035);
    border: 1px solid var(--line);
    border-radius: var(--radius);
  }

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

.tab {
  position: relative;
  min-height: 38px;
  padding: 0 14px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.04);
  border-radius: var(--radius);
}

.tab::before {
  content: "";
  position: absolute;
  inset: 4px;
  z-index: -1;
  background: rgba(233, 185, 111, 0.12);
  border-radius: calc(var(--radius) - 2px);
  opacity: 0;
  transform: scaleX(0.72);
  transition: opacity 180ms var(--ease), transform 180ms var(--ease);
}

.tab.active::before {
  opacity: 1;
  transform: scaleX(1);
}

.anime-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 10px;
  animation: list-in 360ms var(--ease);
  will-change: opacity, transform;
}

.anime-list.is-switching {
  opacity: 0;
  transform: translateX(var(--swipe-shift, 10px));
  transition: opacity 210ms var(--ease), transform 210ms var(--ease);
}

.section-title,
.empty-message {
  grid-column: 1 / -1;
}

.section-title {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.anime-card {
  display: grid;
  grid-template-columns: 70px minmax(0, 1fr);
  gap: 12px;
  min-height: 128px;
  padding: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
  transform: translateZ(0);
  transition: background 180ms var(--ease), border-color 180ms var(--ease), transform 180ms var(--ease), box-shadow 180ms var(--ease);
  animation: card-in 320ms var(--ease) both;
}

.anime-card:hover {
  background: var(--surface-2);
  border-color: rgba(233, 185, 111, 0.34);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.22);
  transform: translateY(-2px);
}

.anime-card:active {
  transform: translateY(0) scale(0.995);
}

.cover {
  width: 70px;
  height: 104px;
  object-fit: cover;
  background: #242832;
  border-radius: var(--radius);
}

.card-main {
  display: flex;
  min-width: 0;
  flex-direction: column;
}

.card-top {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.anime-title {
  margin-bottom: 4px;
  font-size: 14px;
  font-weight: 820;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.anime-episode {
  color: var(--muted);
  font-size: 12px;
}

.countdown {
  margin-top: 8px;
  color: var(--accent);
  font-size: 16px;
  font-weight: 850;
}

.meta {
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 8px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 19px;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 800;
}

.badge-green {
  color: #c9f7db;
  background: rgba(62, 141, 93, 0.28);
}

.badge-orange {
  color: #ffe1b7;
  background: rgba(170, 93, 44, 0.3);
}

.badge-purple {
  color: #e6d7ff;
  background: rgba(112, 84, 170, 0.28);
}

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

.small-btn {
  min-height: 30px;
  padding: 6px 12px;
  color: var(--soft);
  background: rgba(255, 255, 255, 0.055);
  font-size: 12px;
}

.favorite-btn {
  flex: 0 0 32px;
  width: 32px;
  height: 32px;
  color: var(--accent);
  background: rgba(255, 255, 255, 0.04);
  font-size: 16px;
  line-height: 1;
  overflow: hidden;
  padding-bottom: 4px;
}

.favorite-btn.add {
  padding-bottom: 6px;
}

.favorite-btn.favorite {
  background: var(--accent);
  color: var(--surface-2);
  padding-bottom: 0;
}

@media (pointer: coarse) {
  .favorite-btn.add {
    padding-bottom: 2px;
  }
}

.empty-message {
  padding: 22px 12px;
  color: var(--muted);
  text-align: center;
  background: rgba(255, 255, 255, 0.035);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
}

.today-pill {
  display: inline-flex;
  align-items: center;
  min-height: 18px;
  margin-left: 5px;
  padding: 1px 6px;
  color: #17130d;
  background: var(--accent);
  border-radius: 999px;
  font-size: 9px;
  font-weight: 850;
  vertical-align: middle;
}

.settings {
  position: fixed;
  top: max(16px, env(safe-area-inset-top));
  right: max(20px, env(safe-area-inset-right));
  z-index: 60;
  width: min(360px, calc(100vw - 40px));
  max-height: calc(100vh - 32px - env(safe-area-inset-top));
  overflow: auto;
  padding: 14px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 24px 58px rgba(0, 0, 0, 0.44);
  animation: panel-in 190ms var(--ease);
  overscroll-behavior: contain;
}

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

.settings-head h2 {
  margin-bottom: 0;
}

.settings-group {
  padding: 12px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.hint {
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

hr {
  margin: 14px 0;
  border: 0;
  border-top: 1px solid var(--line);
}

label {
  display: block;
  margin-bottom: 10px;
  color: var(--soft);
  font-size: 12px;
  font-weight: 750;
}

input,
select {
  display: block;
  width: 100%;
  min-height: 38px;
  margin-top: 6px;
  padding: 8px 10px;
  color: var(--text);
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  outline: none;
  transition: border-color 150ms ease, background 150ms ease, box-shadow 150ms ease;
}

input:focus,
select:focus {
  border-color: rgba(233, 185, 111, 0.56);
  box-shadow: 0 0 0 3px rgba(233, 185, 111, 0.1);
  background: rgba(0, 0, 0, 0.35);
}

select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23f4f5f7' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 32px;
}

.primary-btn,
.secondary-btn,
.danger-btn {
  width: 100%;
  min-height: 38px;
  margin-top: 7px;
  padding: 8px 10px;
}

.button-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.button-row .primary-btn,
.button-row .secondary-btn,
.button-row .danger-btn {
  margin-top: 0;
}

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

.secondary-btn {
  color: var(--soft);
  background: rgba(255, 255, 255, 0.055);
}

.danger-btn {
  color: #fff;
  background: #c94444;
  border-color: transparent;
}

.preview {
  display: grid;
  gap: 7px;
  margin-top: 9px;
}

.result-card {
  padding: 9px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.result-title {
  font-size: 12px;
  font-weight: 800;
}

.result-meta {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

@media (max-width: 820px) {
  .content-grid {
    grid-template-columns: 1fr;
  }

  .settings {
    top: max(58px, env(safe-area-inset-top));
    right: 12px;
    width: min(380px, calc(100vw - 24px));
    max-height: calc(100vh - 76px - env(safe-area-inset-top));
  }
}

@media (max-width: 560px) {
  .app {
    padding: 16px 12px 24px;
  }

  .header {
    align-items: flex-start;
    flex-direction: row;
    gap: 10px;
  }

  .status-box {
    left: 12px;
    right: 12px;
    top: max(10px, env(safe-area-inset-top));
    width: auto;
  }

  .settings-top-btn {
    width: auto;
    flex: 0 0 auto;
    margin-left: auto;
    justify-content: space-between;
  }

  .next-release {
    grid-template-columns: 76px minmax(0, 1fr);
    gap: 12px;
    min-height: 122px;
    padding: 10px;
  }

  .next-cover {
    width: 76px;
    height: 110px;
  }

  .next-label {
    display: none;
  }

  .next-title {
    font-size: 18px;
  }

  .next-countdown {
    font-size: 18px;
  }

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

  .tab {
    min-height: 34px;
    padding-inline: 6px;
    font-size: 13px;
  }

  .anime-list {
    grid-template-columns: 1fr;
  }

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

  .small-btn {
    width: 100%;
  }

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

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    transition-duration: 1ms !important;
    scroll-behavior: auto !important;
  }
}
