:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f2f3f5;
  --card: #ffffff;
  --field: #ffffff;
  --line: #9aa1aa;
  --text: #111318;
  --muted: #3f4550;
  --accent: #d10f1d;
  --primary: #d10f1d;
  --danger: #b3121f;
  --hover: #e6e8ec;
  --hover-line: #6b7380;
  --field-line: #4b525c;
  --tile: #e2e4e8;
  --tile-hover: #d3d6dc;
  --good: #1f8a3b;
  --warn: #8a6200;
  --cell: #eceef1;
}
:root {
  color-scheme: dark;
  --bg: #0a0a0c;
  --card: #141418;
  --field: #1a1a20;
  --line: #9a9aa3;
  --text: #fff;
  --muted: #e8e8ec;
  --accent: #ff2d3b;
  --primary: #d7101d;
  --danger: #ff97a8;
  --hover: #22282d;
  --hover-line: #d0d4d7;
  --field-line: #fff;
  --tile: #34343c;
  --tile-hover: #44444e;
  --good: #6ce971;
  --warn: #ffd84d;
  --cell: #1e1e25;
  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  font-synthesis: none;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.45;
}
button,
input {
  font: inherit;
  color: inherit;
}
[hidden] {
  display: none !important;
}
.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}
.portal {
  width: min(100%, 972px);
  margin: 0 auto;
  padding: max(10px, env(safe-area-inset-top))
    max(16px, env(safe-area-inset-right)) max(20px, env(safe-area-inset-bottom))
    max(16px, env(safe-area-inset-left));
  display: grid;
  gap: 12px;
}
h1,
h2,
p {
  margin: 0;
}
h1 {
  font-size: 22px;
  font-weight: 650;
  letter-spacing: -0.02em;
}
h2 {
  font-size: 19px;
  font-weight: 650;
  letter-spacing: -0.01em;
}
.card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--card);
  padding: 14px;
}
.card > h2 {
  margin-bottom: 18px;
}
.muted,
.hint {
  color: var(--muted);
}
.hint {
  font-size: 13px;
  line-height: 1.5;
}
.hint:not(:empty) {
  margin-top: 12px;
}
input {
  display: block;
  width: 100%;
  min-width: 0;
  height: 44px;
  padding: 0 12px;
  border: 1.5px solid var(--field-line);
  border-radius: 6px;
  background: var(--field);
  font-size: 16px;
  line-height: normal;
  appearance: none;
}
input::placeholder {
  color: var(--muted);
  opacity: 1;
}
input:read-only {
  color: var(--text);
}
button {
  cursor: pointer;
}
input:focus-visible,
button:focus-visible,
a:focus-visible {
  outline: 2px solid #ff2d3b;
  outline-offset: 3px;
}
button:disabled,
input:disabled {
  opacity: 0.5;
  cursor: default;
}
.button {
  min-height: 44px;
  border: 1px solid #b4b4bc;
  border-radius: 6px;
  padding: 9px 18px;
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  touch-action: manipulation;
}
.outline {
  background: transparent;
  color: var(--text);
}
.outline:hover:not(:disabled) {
  background: var(--hover);
  border-color: var(--hover-line);
}
.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.primary:hover:not(:disabled) {
  background: var(--accent);
  border-color: var(--accent);
}
.tile {
  background: var(--tile);
  border-color: var(--tile);
  color: var(--text);
}
.tile:hover:not(:disabled) {
  background: var(--tile-hover);
  border-color: var(--tile-hover);
}
.connect {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
}
.connect .button {
  min-width: 108px;
}
.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-bottom: 1px solid var(--line);
  margin-top: -3px;
}
.tab {
  position: relative;
  min-height: 42px;
  border: 0;
  background: transparent;
  font-size: 16px;
  font-weight: 600;
  color: var(--muted);
  padding: 9px 6px;
}
.tab.active {
  color: var(--text);
}
.tab:disabled {
  opacity: 0.45;
  cursor: default;
}
.tab.active:after {
  content: "";
  position: absolute;
  bottom: -1px;
  left: 0;
  right: 0;
  height: 4px;
  border-radius: 3px;
  background: var(--accent);
}
.editor h1 {
  margin-bottom: 24px;
}
fieldset {
  min-width: 0;
  border: 0;
  margin: 0;
  padding: 0;
}
.column-headings {
  display: none;
}
.drafts {
  display: grid;
  gap: 12px;
}
.draft-row,
.field {
  min-width: 0;
}
.draft-row input {
  padding: 0 10px;
}
.draft-row.m3u,
.draft-row.xtream {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 8px;
  align-items: end;
}
.draft-row .field-label {
  display: block;
  font-size: 12px;
  margin-bottom: 4px;
}
.draft-row .field-name {
  grid-column: 1/5;
  grid-row: 2;
}
.draft-row .field-pin {
  grid-column: 5/7;
  grid-row: 2;
}
.draft-row .remove {
  grid-column: 7;
  grid-row: 2;
}
.draft-row .add-row {
  grid-column: 8;
  grid-row: 2;
}
/* Plus and minus are drawn as bars so they stay centred in every font. */
.draft-row .remove,
.draft-row .add-row {
  position: relative;
  height: 44px;
  min-height: 44px;
  min-width: 0;
  padding: 0;
  align-self: end;
  border-color: var(--tile);
  background: var(--tile);
  color: var(--text);
  font-size: 0;
}
.draft-row .remove:hover:not(:disabled),
.draft-row .add-row:hover:not(:disabled) {
  border-color: var(--tile-hover);
  background: var(--tile-hover);
}
.draft-row .remove::before,
.draft-row .add-row::before,
.draft-row .add-row::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 16px;
  height: 3px;
  border-radius: 2px;
  background: currentColor;
  transform: translate(-50%, -50%);
}
.draft-row .add-row::after {
  width: 3px;
  height: 16px;
}
.draft-row .field-username {
  grid-column: 1/5;
  grid-row: 1;
}
.draft-row .field-password {
  grid-column: 5/9;
  grid-row: 1;
}
.draft-row .field-url {
  grid-column: 1/9;
  grid-row: 3;
}
.draft-row.has-save .field-url {
  grid-column: 1/7;
}
.draft-row #save,
.draft-row #cancel-edit {
  grid-column: 7;
  grid-row: 3;
  min-width: 0;
  padding: 0 8px;
}
.draft-row #cancel-edit {
  grid-column: 8;
}
.draft-row.m3u .field-name,
.draft-row.m3u .field-pin,
.draft-row.m3u .remove,
.draft-row.m3u .add-row {
  grid-row: 1;
}
.draft-row.m3u .field-url,
.draft-row.m3u #save,
.draft-row.m3u #cancel-edit {
  grid-row: 2;
}
.actions {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
}
.actions .button {
  flex: 1;
  max-width: 44%;
}
.actions .button:last-child {
  margin-left: auto;
}
.saved-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
  margin-top: 14px;
}
.saved-heading h2 {
  font-size: 16px;
}
.empty {
  margin-top: 8px;
}
.status {
  font-size: 14px;
  overflow-wrap: anywhere;
}
.status:not(:empty) {
  margin-top: 14px;
}
.error {
  color: var(--danger);
  margin: 12px 0;
  overflow-wrap: anywhere;
}
.input-action {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
}
.input-action .button {
  min-width: 104px;
}
.limit-note {
  margin: 10px 0 0;
  color: var(--warn);
  font-size: 13px;
  font-weight: 600;
}
.check-result {
  margin-top: 14px;
  font-size: 14px;
  min-height: 22px;
  overflow-wrap: anywhere;
}
/* No placeholder text: the result area takes no room until a check runs. */
.check-result:empty {
  display: none;
}
.playlist-tools {
  min-width: 0;
}
.tool-tabs {
  margin-bottom: 18px;
}
.tool-tabs .tab {
  white-space: nowrap;
  font-size: clamp(12px, 3.3vw, 16px);
}
.tool-panel {
  min-width: 0;
}
.check-card {
  border: 1px solid var(--line);
  border-top: 3px solid var(--accent);
  border-radius: 9px;
  background: var(--card);
  padding: 8px 12px;
  color: var(--text);
}
.check-line {
  display: flex;
  align-items: center;
  gap: 0;
  min-width: 0;
  min-height: 34px;
  white-space: nowrap;
}
.check-details {
  border-top: 1px solid var(--line);
  margin-top: 5px;
  padding-top: 5px;
}
.check-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
  border: 1px solid currentColor;
  border-radius: 6px;
  padding: 3px 7px;
  max-width: 58%;
  overflow: hidden;
  text-overflow: ellipsis;
}
.check-badge.online {
  color: #6ce971;
}
.check-badge.offline {
  color: #ff97a8;
}
.check-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}
.check-fact {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 550;
}
.check-fact + .check-fact,
.check-badge + .check-fact {
  border-left: 1px solid var(--line);
  margin-left: 12px;
  padding-left: 12px;
}
.check-fact.username {
  flex: 1;
}
.check-name {
  min-width: 0;
  margin-left: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 21px;
  font-weight: 700;
}
.check-time {
  flex-shrink: 0;
  margin-left: auto;
  padding-left: 10px;
  color: var(--muted);
  font-size: 13px;
}
.check-stats {
  display: grid;
  grid-template-columns: 1.2fr 1.6fr 1fr;
  gap: 6px;
  margin-top: 8px;
}
.check-account {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 6px;
  margin: 6px 0 4px;
}
.check-cell {
  min-width: 0;
  border-radius: 6px;
  background: var(--cell);
  padding: 6px 9px;
}
.check-cell > span {
  display: block;
  color: var(--muted);
  font-size: 10.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.check-cell > b {
  display: block;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 14px;
  font-weight: 600;
  overflow-wrap: anywhere;
}
.check-cell.wide {
  grid-column: 1 / 3;
}
.check-stats .check-cell {
  text-align: center;
}
.check-stats .check-cell > b {
  font-family: inherit;
  font-size: 16px;
  line-height: 24px;
}
.check-stats .days > b {
  color: var(--good);
  font-size: 20px;
}
.check-stats .days.over > b {
  color: var(--danger);
}
.check-note {
  margin: 4px 0 6px;
  font-size: 14px;
}
.check-state {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
  color: var(--text);
}
.check-state > span:not(.check-dot):not(.check-spinner) {
  min-width: 0;
  overflow-wrap: anywhere;
}
.check-dot.warning {
  color: #f2ca45;
}
.check-retry {
  border: 0;
  border-left: 1px solid var(--line);
  padding: 4px 0 4px 12px;
  margin-left: auto;
  background: transparent;
  color: white;
  white-space: nowrap;
  text-decoration: underline;
}
.check-spinner {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  border: 2px solid var(--line);
  border-top-color: white;
  border-radius: 50%;
  animation: check-spin 1s linear infinite;
}
.m3u-result .check-line {
  font-size: 13px;
}
@keyframes check-spin {
  to {
    transform: rotate(360deg);
  }
}
@media (max-width: 360px) {
  .check-card {
    padding: 6px 8px;
    font-size: 13px;
  }
  .check-fact + .check-fact,
  .check-badge + .check-fact {
    margin-left: 8px;
    padding-left: 8px;
  }
  .m3u-result .check-line {
    font-size: 11px;
  }
  .m3u-result .check-badge {
    font-size: 12px;
    padding: 3px 5px;
  }
}
@media (prefers-reduced-motion: reduce) {
  .check-spinner {
    animation: none;
  }
}
.playlist-list {
  margin-top: 12px;
}
.prow {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid #6b6b74;
  min-width: 0;
}
.prow:last-child {
  border-bottom: 0;
}
.prow-main {
  min-width: 0;
  flex: 1;
}
.prow-name {
  font-size: 16px;
  font-weight: 600;
  overflow-wrap: anywhere;
  display: flex;
  align-items: center;
  gap: 6px;
}
.prow-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}
.icon-btn {
  width: 38px;
  height: 40px;
  border: 1px solid var(--line);
  background: transparent;
  border-radius: 5px;
  padding: 8px;
  color: var(--text);
}
.icon-btn:hover {
  background: var(--hover);
}
.icon-btn svg,
.check svg,
.lock svg {
  width: 100%;
  height: 100%;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.lock {
  width: 16px;
  height: 18px;
  flex-shrink: 0;
  color: var(--muted);
}
.lock.open {
  color: #cf8ca1;
}
.check {
  width: 20px;
  height: 20px;
  color: #c66d88;
}
.check.off {
  visibility: hidden;
}
.prow-status {
  color: var(--muted);
  font-size: 12px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  overflow-wrap: anywhere;
  margin-top: 4px;
}
.prow-status i {
  font-style: normal;
  color: #b4b4bc;
}
.sdot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #aeb7be;
  flex-shrink: 0;
}
.sdot.ok {
  background: #82bf9c;
}
.sdot.bad {
  background: #d5798f;
}
.sdot.warn {
  background: #c4a66f;
}
.refreshing {
  opacity: 0.75;
}
footer {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: nowrap;
  gap: 8px;
  padding: 18px 0 8px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--muted);
  white-space: nowrap;
}
footer a,
footer .theme-switch button,
.text-button {
  color: inherit;
  text-decoration: none;
  font: inherit;
  letter-spacing: inherit;
}
.text-button {
  padding: 0;
  background: none;
  border: 0;
  text-decoration: underline;
  text-underline-offset: 3px;
}
footer a:hover,
footer .theme-switch button:hover,
.text-button:hover {
  color: var(--text);
}
.dialog {
  color: var(--text);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 24px;
  width: min(92vw, 440px);
  max-height: 85dvh;
  overflow: auto;
}
.dialog::backdrop {
  background: #000b;
}
.dialog h2 {
  margin-bottom: 16px;
}
.dialog p {
  overflow-wrap: anywhere;
}
.dialog .actions .button {
  max-width: none;
}
.dialog .actions {
  margin-top: 20px;
}
@media (max-width: 700px) {
  .portal {
    gap: 18px;
    padding-top: max(12px, env(safe-area-inset-top));
  }
  .card {
    padding: 16px;
    border-radius: 8px;
  }
  h1 {
    font-size: 20px;
  }
  .card > h2 {
    font-size: 18px;
    margin-bottom: 14px;
  }
  .editor h1 {
    margin-bottom: 18px;
  }
  .draft-row input {
    padding: 0 7px;
  }
  /* Phone: SAVE and CANCEL stay on the URL row, side by side and equal, two narrow columns each. */
  .draft-row.has-save .field-url {
    grid-column: 1/5;
  }
  .draft-row #save {
    grid-column: 5/7;
  }
  .draft-row #cancel-edit {
    grid-column: 7/9;
  }
  .draft-row #save,
  .draft-row #cancel-edit {
    padding: 0 4px;
    font-size: 12px;
    letter-spacing: 0;
  }
  .drafts {
    gap: 10px;
  }
  .button {
    padding: 9px 12px;
    font-size: 14px;
  }
  .connect {
    gap: 10px;
  }
  .connect .button {
    min-width: 88px;
  }
  .actions {
    gap: 12px;
    margin-top: 17px;
  }
  .actions .button {
    max-width: none;
  }
  .input-action {
    gap: 9px;
  }
  .input-action .button {
    min-width: 82px;
  }
  .saved-heading {
    margin-top: 20px;
  }
  .hint {
    font-size: 12px;
  }
  .prow-actions {
    gap: 4px;
  }
  .icon-btn {
    width: 32px;
    padding: 6px;
  }
  .prow {
    gap: 6px;
  }
}
@media (max-width: 350px) {
  .portal {
    padding-left: 10px;
    padding-right: 10px;
  }
  .card {
    padding: 12px;
  }
  .draft-row input {
    padding: 0 5px;
  }
  .tab {
    font-size: 14px;
  }
}
@media (prefers-reduced-motion: reduce) {
  * {
    scroll-behavior: auto !important;
  }
}

.status:empty {
  display: none;
}

.theme-switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
}
.theme-switch button {
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  cursor: pointer;
  white-space: nowrap;
}
.privacy-page {
  width: min(100% - 2rem, 46rem);
  margin: 2rem auto;
  line-height: 1.6;
}

.privacy-page h2 {
  margin-top: 1.5rem;
  font-size: 1.125rem;
}
