:root {
  --background: #070d19;
  --surface: #101827;
  --surface-deep: #09111f;
  --border: #243249;
  --border-soft: #1b2a40;
  --text: #f7f9fc;
  --muted: #78a0da;
  --aqua: #42d9d2;
  --aqua-deep: #102d35;
  --danger: #ff7d86;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { min-width: 320px; background: var(--background); }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  color: var(--text);
  background: radial-gradient(circle at 50% 22%, rgba(19, 46, 70, .18), transparent 33rem), var(--background);
  font-family: "Inter", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.page-shell {
  width: 100%;
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: clamp(62px, 7vh, 88px) 24px 36px;
}

.converter { width: min(750px, calc(100vw - 48px)); min-width: 0; text-align: center; }

.tv-mark {
  width: 84px;
  height: 84px;
  margin: 0 auto 32px;
  display: grid;
  place-items: center;
  border: 1px solid #17535a;
  border-radius: 21px;
  background: rgba(16, 45, 53, .82);
  box-shadow: 0 16px 40px rgba(0, 0, 0, .14);
}

.tv-mark svg {
  width: 52px;
  height: 52px;
  fill: none;
  stroke: var(--aqua);
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

h1 {
  margin: 0;
  font-size: clamp(30px, 3.1vw, 40px);
  line-height: 1.18;
  letter-spacing: -.035em;
  font-weight: 700;
}

.subtitle {
  margin: 23px 0 44px;
  color: var(--muted);
  font-size: 19px;
  line-height: 1.55;
}

.card {
  width: 100%;
  min-width: 0;
  padding: 38px 32px 30px;
  text-align: left;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: rgba(16, 24, 39, .96);
  box-shadow: 0 26px 70px rgba(0, 0, 0, .18);
}

.mode-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin-bottom: 30px;
  padding: 4px;
  border: 1px solid var(--border-soft);
  border-radius: 13px;
  background: var(--surface-deep);
}

.mode-button {
  min-height: 44px;
  border: 0;
  border-radius: 9px;
  color: #7898ca;
  background: transparent;
  font: 600 14px "Inter", sans-serif;
  cursor: pointer;
  transition: color .18s ease, background .18s ease, box-shadow .18s ease;
}

.mode-button.active {
  color: #06151a;
  background: var(--aqua);
  box-shadow: 0 5px 15px rgba(66, 217, 210, .14);
}

label { display: block; margin-bottom: 14px; font-size: 16px; font-weight: 700; }

input {
  width: 100%;
  height: 52px;
  padding: 0 16px;
  border: 1px solid var(--border-soft);
  border-radius: 13px;
  outline: 0;
  color: #dce7f7;
  background: var(--surface-deep);
  font: 400 15px "Roboto Mono", monospace;
  transition: border-color .18s ease, box-shadow .18s ease;
}

input::placeholder { color: #7898ca; opacity: 1; }
input:focus { border-color: var(--aqua); box-shadow: 0 0 0 4px rgba(66, 217, 210, .1); }
input.invalid { border-color: var(--danger); }

.field-note {
  margin: 8px 0 0;
  color: #6f8eae;
  font-size: 11px;
}

.hotplayer-option {
  margin-top: 22px;
  padding: 17px;
  border: 1px solid var(--border-soft);
  border-radius: 13px;
  background: rgba(7, 13, 25, .42);
}

.check-row {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
}

.check-row input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  opacity: 0;
  pointer-events: none;
}

.check-box {
  width: 22px;
  height: 22px;
  flex: 0 0 22px;
  display: grid;
  place-items: center;
  border: 1px solid #35516b;
  border-radius: 6px;
  color: #06151a;
  background: var(--surface-deep);
  transition: background .18s ease, border-color .18s ease, box-shadow .18s ease;
}

.check-box svg { width: 15px; fill: none; stroke: currentColor; stroke-width: 2; opacity: 0; }
.check-row input:checked + .check-box { border-color: var(--aqua); background: var(--aqua); }
.check-row input:checked + .check-box svg { opacity: 1; }
.check-row input:focus-visible + .check-box { box-shadow: 0 0 0 3px rgba(66, 217, 210, .22); }
.check-row strong, .check-row small { display: block; }
.check-row strong { color: #eaf0f8; font-size: 13px; }
.check-row small { margin-top: 3px; color: #6f8eae; font-size: 10px; font-weight: 400; }

.hotplayer-fields {
  margin-top: 17px;
  padding-top: 17px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  border-top: 1px solid var(--border-soft);
}

.hotplayer-fields label { margin-bottom: 8px; color: #a9bad0; font-size: 11px; }
.hotplayer-fields input { height: 46px; font-size: 12px; }

.error-message {
  min-height: 18px;
  margin: 7px 0 2px;
  color: var(--danger);
  font-size: 12px;
  line-height: 1.4;
}

.error-message:empty { visibility: hidden; }

.generate-button {
  width: 100%;
  min-height: 74px;
  margin-top: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 15px;
  border: 0;
  border-radius: 15px;
  color: #031319;
  background: var(--aqua);
  font: 600 18px "Inter", sans-serif;
  cursor: pointer;
  box-shadow: 0 10px 28px rgba(66, 217, 210, .15);
  transition: transform .18s ease, background .18s ease, box-shadow .18s ease;
}

.generate-button svg {
  width: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform .18s ease;
}

.generate-button:hover { background: #58e6df; box-shadow: 0 13px 32px rgba(66, 217, 210, .21); transform: translateY(-1px); }
.generate-button:hover svg { transform: translateX(3px); }
.generate-button:active { transform: translateY(0); }
.generate-button:disabled { opacity: .68; cursor: wait; transform: none; box-shadow: none; }

.result {
  margin-top: 24px;
  padding-top: 25px;
  border-top: 1px solid var(--border);
  animation: reveal .28s ease both;
}

@keyframes reveal {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

.result-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 13px; }

.result-status {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 5px;
  color: var(--aqua);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
}

.result-status i { width: 7px; height: 7px; border-radius: 50%; background: var(--aqua); }
.result h2 { margin: 0; font-size: 16px; }

.copy-button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 12px;
  border: 1px solid #2d4d61;
  border-radius: 9px;
  color: var(--aqua);
  background: #0d202d;
  font: 600 12px "Inter", sans-serif;
  cursor: pointer;
}

.copy-button svg { width: 15px; fill: none; stroke: currentColor; stroke-width: 1.8; }

#resultLink,
#resultMac {
  display: block;
  max-height: 110px;
  overflow: auto;
  padding: 15px;
  border: 1px solid var(--border-soft);
  border-radius: 11px;
  color: #9fc4ef;
  background: var(--surface-deep);
  overflow-wrap: anywhere;
  font: 400 13px/1.65 "Roboto Mono", monospace;
}

.mac-result { margin-top: 16px; }

.upload-status {
  margin: 13px 0 0;
  padding: 11px 13px;
  border-radius: 9px;
  color: #78e3c4;
  background: rgba(38, 123, 101, .16);
  font-size: 12px;
  font-weight: 600;
}

.upload-status.error { color: #ff9ca3; background: rgba(170, 48, 60, .15); }

.mac-result-label {
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  color: #a9bad0;
  font-size: 12px;
  font-weight: 600;
}

.copy-mac-button {
  padding: 5px 8px;
  border: 0;
  color: var(--aqua);
  background: transparent;
  font: 600 11px "Inter", sans-serif;
  cursor: pointer;
}

footer { padding: 22px 24px 48px; color: var(--muted); text-align: center; font-size: 14px; }

.toast {
  position: fixed;
  z-index: 10;
  left: 50%;
  bottom: 22px;
  padding: 11px 16px;
  border: 1px solid #28505c;
  border-radius: 30px;
  color: var(--text);
  background: #10252d;
  font-size: 12px;
  opacity: 0;
  transform: translate(-50%, 12px);
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
}

.toast.show { opacity: 1; transform: translate(-50%, 0); }
button:focus-visible { outline: 3px solid rgba(66, 217, 210, .42); outline-offset: 3px; }

@media (max-width: 600px) {
  .page-shell { padding: 38px 16px 28px; }
  .converter { width: calc(100vw - 32px); }
  .tv-mark { width: 70px; height: 70px; margin-bottom: 25px; border-radius: 18px; }
  .tv-mark svg { width: 43px; height: 43px; }
  h1 { max-width: 330px; margin-inline: auto; font-size: clamp(26px, 8vw, 34px); }
  .subtitle { max-width: 310px; margin: 17px auto 30px; font-size: 15px; }
  .card { padding: 25px 18px 20px; border-radius: 14px; }
  .mode-switch { margin-bottom: 24px; }
  .mode-button { min-height: 42px; }
  .hotplayer-option { padding: 15px; }
  .hotplayer-fields { grid-template-columns: 1fr; }
  label { margin-bottom: 11px; font-size: 14px; }
  input { height: 50px; padding-inline: 13px; font-size: 12px; }
  .generate-button { min-height: 58px; border-radius: 12px; font-size: 16px; }
  .result-head { align-items: center; }
  #resultLink, #resultMac { font-size: 11px; }
  footer { padding: 14px 18px 30px; font-size: 11px; }
}

@media (max-height: 720px) and (min-width: 601px) {
  .page-shell { padding-top: 38px; }
  .tv-mark { width: 68px; height: 68px; margin-bottom: 20px; }
  .tv-mark svg { width: 42px; height: 42px; }
  .subtitle { margin: 15px 0 26px; }
  .card { padding-top: 28px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* Result dialog: deliberately larger and simpler for older users. */
body.modal-open { overflow: hidden; }

.modal-backdrop {
  position: fixed;
  z-index: 20;
  inset: 0;
  padding: 24px;
  display: grid;
  place-items: center;
  background: rgba(2, 7, 15, .86);
  backdrop-filter: blur(8px);
}

.result-dialog {
  width: min(100%, 780px);
  max-height: calc(100svh - 48px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  border: 1px solid #344765;
  border-radius: 20px;
  color: var(--text);
  background: #101827;
  box-shadow: 0 30px 90px rgba(0, 0, 0, .5);
  animation: dialog-in .22s ease both;
}

@keyframes dialog-in {
  from { opacity: 0; transform: translateY(12px) scale(.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.dialog-header {
  padding: 22px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 1px solid var(--border);
}

.dialog-heading { display: flex; align-items: center; gap: 14px; }
.dialog-check { width: 48px; height: 48px; flex: 0 0 48px; display: grid; place-items: center; border-radius: 50%; color: #06221d; background: #68e1bd; font-size: 24px; font-weight: 800; }
.dialog-heading span:not(.dialog-check) { display: block; margin-bottom: 3px; color: #68e1bd; font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; }
.dialog-heading h2 { margin: 0; font-size: 25px; line-height: 1.2; }

.close-button {
  width: 52px;
  height: 52px;
  flex: 0 0 52px;
  border: 1px solid #40506a;
  border-radius: 50%;
  color: white;
  background: #172238;
  font: 400 34px/1 "Inter", sans-serif;
  cursor: pointer;
}

.dialog-body { padding: 24px; overflow-y: auto; overscroll-behavior: contain; }

.result-choice {
  padding: 22px;
  border: 1px solid #2b3b55;
  border-radius: 16px;
  background: #0b1322;
}

.result-choice + .result-choice { margin-top: 18px; }
.choice-heading { display: flex; align-items: flex-start; gap: 14px; margin-bottom: 16px; }
.choice-heading > span { width: 34px; height: 34px; flex: 0 0 34px; display: grid; place-items: center; border-radius: 50%; color: #072027; background: var(--aqua); font-size: 16px; font-weight: 800; }
.choice-heading h3 { margin: 0 0 4px; font-size: 19px; line-height: 1.25; }
.choice-heading p { margin: 0; color: #a9bad0; font-size: 14px; line-height: 1.5; }

.credential-list {
  margin: 0 0 20px;
  border: 1px solid #2b3c56;
  border-radius: 12px;
  overflow: hidden;
}

.credential-list > div {
  min-height: 48px;
  padding: 11px 14px;
  display: grid;
  grid-template-columns: 155px minmax(0, 1fr);
  align-items: center;
  gap: 14px;
  background: #0e192a;
}

.credential-list > div + div { border-top: 1px solid #263750; }
.credential-list dt { color: #91a8c4; font-size: 13px; font-weight: 600; }
.credential-list dd { margin: 0; color: #f4f8ff; overflow-wrap: anywhere; font: 600 15px/1.45 "Roboto Mono", monospace; }

.result-label {
  margin: 0 0 9px;
  color: #eaf2ff;
  font-size: 15px;
  font-weight: 700;
}

.epg-label { margin-top: 21px; }

.result-choice code {
  display: block;
  max-height: 116px;
  overflow: auto;
  padding: 16px;
  border: 1px solid #2b3c56;
  border-radius: 11px;
  color: #bdd8fb;
  background: #060c17;
  overflow-wrap: anywhere;
  font: 400 14px/1.65 "Roboto Mono", monospace;
}

.dialog-copy-button,
.hotplayer-upload-button {
  width: 100%;
  min-height: 58px;
  margin-top: 14px;
  border: 0;
  border-radius: 11px;
  color: #05191e;
  background: var(--aqua);
  font: 700 16px "Inter", sans-serif;
  cursor: pointer;
}

.dialog-copy-button.secondary { color: #e8f0fb; background: #243653; }
.dialog-copy-button:disabled { color: #718096; background: #1b2739; cursor: not-allowed; }

.hotplayer-choice label { margin: 0 0 10px; font-size: 16px; }
.hotplayer-choice input { height: 58px; font-size: 17px; }
.hotplayer-choice .field-note { font-size: 13px; }
.hotplayer-error { min-height: 22px; margin: 9px 0 0; color: #ff9ca3; font-size: 14px; font-weight: 600; }
.hotplayer-upload-button { min-height: 64px; font-size: 17px; }
.hotplayer-upload-button:disabled { opacity: .7; cursor: wait; }

.hotplayer-success {
  padding: 26px 18px;
  border: 2px solid #57d9b3;
  border-radius: 14px;
  text-align: center;
  background: rgba(59, 177, 143, .12);
  outline: 0;
}

.hotplayer-success > span { width: 58px; height: 58px; margin: 0 auto 14px; display: grid; place-items: center; border-radius: 50%; color: #05241d; background: #68e1bd; font-size: 28px; font-weight: 900; }
.hotplayer-success h3 { margin: 0 0 14px; font-size: 25px; }
.hotplayer-success p { margin: 0 0 9px; color: #c8d3e2; font-size: 17px; }
.hotplayer-success strong { display: inline-block; padding: 10px 15px; border-radius: 9px; color: #061b20; background: var(--aqua); font-size: 21px; }

@media (max-width: 600px) {
  label { font-size: 16px; }
  input { height: 56px; font-size: 15px; }
  .mode-button { font-size: 16px; }
  .modal-backdrop { padding: 0; place-items: end center; }
  .result-dialog { width: 100%; max-height: 96svh; border-radius: 20px 20px 0 0; }
  .dialog-header { padding: 17px 16px; }
  .dialog-heading h2 { font-size: 21px; }
  .dialog-check { width: 42px; height: 42px; flex-basis: 42px; font-size: 21px; }
  .close-button { width: 48px; height: 48px; flex-basis: 48px; }
  .dialog-body { padding: 16px; }
  .result-choice { padding: 18px 15px; }
  .choice-heading h3 { font-size: 18px; }
  .choice-heading p { font-size: 14px; }
  .credential-list > div { grid-template-columns: 1fr; gap: 4px; }
  .credential-list dt { font-size: 12px; }
  .credential-list dd { font-size: 14px; }
  .result-choice code { padding: 14px; font-size: 12px; }
  .dialog-copy-button, .hotplayer-upload-button { min-height: 60px; font-size: 16px; }
}
