:root {
  /* Dark navy + blue — matches the ECTV app and logo. */
  --bg: #0a1122;
  --surface: #111a30;
  --surface2: #1b2742;
  --line: #26324d;
  --text: #eef2fb;
  --muted: #9aa6c0;
  --primary: #2f9be0;
  --primary-soft: #12314c;
  --primary-dark: #2384c4;
  --danger: #ef5a5a;
  --radius: 12px;
  --font: "DM Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --max: 960px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
html, body { margin: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Header: logo left, actions right (TiviMate-style) */
.site-header {
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 40;
}
/* Keep the header row aligned with the page container instead of full width. */
.header-inner {
  max-width: var(--max);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px clamp(16px, 4vw, 40px);
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--primary);
  font-weight: 700;
  font-size: 22px;
  letter-spacing: -0.02em;
  text-transform: lowercase;
  flex-shrink: 0;
}
.brand:hover { text-decoration: none; }
.logo {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  display: block;
  object-fit: cover;
}
.wordmark { line-height: 1; }

.site-nav {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: nowrap;
}
.site-nav .nav-link {
  color: var(--muted);
  font-size: 15px;
  font-weight: 500;
  white-space: nowrap;
  padding: 8px 4px;
}
.site-nav .nav-link:hover,
.site-nav .nav-link.is-active {
  color: var(--text);
  text-decoration: none;
}
.nav-burger,
.nav-toggle { display: none; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 20px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 15px;
  border: none;
  cursor: pointer;
  background: var(--primary);
  color: #fff;
  font-family: inherit;
  white-space: nowrap;
  text-decoration: none;
}
.btn:hover { text-decoration: none; background: var(--primary-dark); }
.btn-sm { padding: 8px 16px; font-size: 14px; }
.btn.ghost {
  background: transparent;
  color: var(--primary);
  border: 1.5px solid var(--primary);
}
.btn.ghost:hover { background: var(--primary-soft); }
.btn.accent { background: var(--primary); color: #fff; }
.btn.danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid rgba(239, 90, 90, .5);
}
.btn.is-disabled,
a.btn.is-disabled {
  opacity: .45;
  pointer-events: none;
}
.btn-row { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 20px; }
.btn-row .btn { width: auto; }

/* Forms / account pages keep full-width submit buttons */
.card .btn,
form .btn:not(.btn-sm):not(.ghost):not(.btn-row .btn) { width: 100%; border-radius: 10px; }
.btn-row .btn { width: auto; border-radius: 999px; }

/* Layout */
.site-main {
  max-width: var(--max);
  margin: 0 auto;
  padding: 40px clamp(16px, 4vw, 40px) 64px;
}
body.landing .site-main {
  max-width: none;
  padding: 0;
}
.narrow { max-width: 420px; margin: 0 auto; }
.legal { max-width: 680px; margin: 0 auto; }
.legal h1 { margin: 0 0 6px; font-size: 28px; }
.legal h2 { margin: 28px 0 8px; font-size: 18px; }
.legal h3 { margin: 18px 0 6px; font-size: 16px; }
.legal p, .legal li { color: var(--muted); font-size: 15px; }
.legal ul, .legal ol { padding-left: 1.2em; }
.legal li { margin: 6px 0; }
.legal strong { color: var(--text); }

/* Footer: one simple row */
.site-footer {
  border-top: 1px solid var(--line);
  padding: 28px clamp(16px, 4vw, 40px);
  color: var(--muted);
  font-size: 14px;
  background: var(--bg);
}
.footer-bar {
  max-width: var(--max);
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 10px 22px;
  justify-content: center;
  align-items: center;
  text-align: center;
}
.footer-bar a { color: var(--muted); }
.footer-bar a:hover { color: var(--primary); }

/* Cards / type */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 26px;
}
.card + .card { margin-top: 20px; }
h1 { font-size: clamp(26px, 4vw, 34px); margin: 0 0 8px; letter-spacing: -0.02em; }
h2 { font-size: 19px; margin: 0 0 14px; }
.lead { color: var(--muted); font-size: 16px; margin: 0 0 24px; }

label { display: block; font-size: 13px; color: var(--muted); margin: 16px 0 6px; }
input, select {
  width: 100%;
  padding: 12px 13px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
}
input::placeholder { color: var(--muted); }
input:focus, select:focus { outline: none; border-color: var(--primary); }
.hide { display: none; }

.alert { padding: 12px 15px; border-radius: 11px; margin-bottom: 18px; font-size: 14px; }
.alert.err { background: rgba(239, 90, 90, .12); border: 1px solid rgba(239, 90, 90, .4); color: #f4a5a5; }
.alert.ok  { background: rgba(52, 199, 120, .12); border: 1px solid rgba(52, 199, 120, .4); color: #8fe0b0; }
.alert.info{ background: var(--primary-soft); border: 1px solid rgba(47, 155, 224, .45); color: #bfe0f5; }

.tag {
  display: inline-block;
  padding: 3px 11px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  background: var(--surface2);
  color: var(--muted);
}
.tag.premium { background: rgba(52, 199, 120, .16); color: #7fdca6; }
.tag.free { background: rgba(240, 180, 40, .16); color: #e6c168; }
.muted { color: var(--muted); }
.mac { font-family: ui-monospace, monospace; letter-spacing: 1px; color: var(--primary); }

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}
.row:last-child { border-bottom: none; }
.row .k { color: var(--muted); font-size: 14px; }
.row .v { font-weight: 600; }
.auth-switch { text-align: center; color: var(--muted); margin-top: 18px; font-size: 14px; }

.eclink { text-align: center; }
.eclink .qr {
  width: 180px;
  height: 180px;
  margin: 20px auto;
  background: #fff;
  border-radius: 14px;
  padding: 12px;
  border: 1px solid var(--line);
}
.eclink .qr img,
.eclink .qr canvas { width: 100%; height: 100%; image-rendering: pixelated; }

/* Pricing */
.plans { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 620px) { .plans { grid-template-columns: 1fr; } }
.plan {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 26px;
}
.plan.featured { border-color: var(--primary); }
.plan h3 { margin: 0 0 4px; font-size: 20px; }
.plan .price { font-size: 28px; font-weight: 700; margin: 8px 0 4px; letter-spacing: -0.02em; }
.plan .price span { font-size: 15px; font-weight: 500; color: var(--muted); }
.plan ul { list-style: none; padding: 0; margin: 18px 0 0; }
.plan li {
  padding: 8px 0 8px 22px;
  position: relative;
  color: var(--text);
  font-size: 15px;
}
.plan li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 15px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary);
}
.plan li.off { color: var(--muted); }
.plan li.off::before { background: #45506a; }

/* ========== Landing (TiviMate-like) ========== */
.hero {
  text-align: center;
  padding: 56px clamp(16px, 4vw, 40px) 28px;
  max-width: 800px;
  margin: 0 auto;
}
.hero h1 {
  font-size: clamp(28px, 5vw, 42px);
  font-weight: 700;
  letter-spacing: -0.03em;
  margin: 0 0 22px;
  color: var(--text);
  line-height: 1.2;
}

.notice {
  max-width: 720px;
  margin: 0 auto;
  padding: 18px 20px;
  border-radius: 12px;
  background: var(--surface);
  text-align: left;
}
.notice p {
  margin: 0;
  color: var(--text);
  font-size: 14px;
  line-height: 1.55;
}
.notice strong { font-weight: 700; }

.section {
  padding: 48px clamp(16px, 4vw, 40px);
  max-width: var(--max);
  margin: 0 auto;
}
.section-title {
  text-align: center;
  font-size: clamp(24px, 3.5vw, 32px);
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 36px;
}

.why-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 22px 36px;
}
@media (max-width: 700px) {
  .why-grid { grid-template-columns: 1fr; gap: 18px; }
}
.why-item {
  display: grid;
  grid-template-columns: 32px 1fr;
  gap: 12px;
  align-items: start;
}
.why-icon {
  width: 32px;
  height: 32px;
  max-width: 32px;
  max-height: 32px;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary);
  display: grid;
  place-items: center;
  flex-shrink: 0;
  overflow: hidden;
}
.why-icon svg {
  width: 16px !important;
  height: 16px !important;
  max-width: 16px;
  max-height: 16px;
  display: block;
}
.why-item h3 {
  margin: 0 0 2px;
  font-size: 16px;
  font-weight: 700;
  color: var(--primary);
  line-height: 1.3;
}
.why-item p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.download-block {
  text-align: center;
  padding-bottom: 64px;
}
.download-block .section-title { margin-bottom: 12px; }
.download-block > p {
  color: var(--muted);
  max-width: 480px;
  margin: 0 auto 28px;
  font-size: 15px;
}
.download-options {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
  text-align: left;
}
@media (max-width: 800px) {
  .download-options { grid-template-columns: 1fr; }
}
.download-opt {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 20px;
  background: var(--surface);
}
.download-opt h3 {
  margin: 0 0 6px;
  font-size: 16px;
}
.download-opt p {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 14px;
  min-height: 0;
}
.download-opt .btn { width: auto; }
.download-opt .soon {
  display: inline-block;
  color: var(--muted);
  font-size: 13px;
  padding: 8px 0;
}

@media (max-width: 560px) {
  .site-nav .nav-link:not(.nav-cta):not([href="/login.php"]):not([href="/logout.php"]):not([href="/account.php"]) {
    display: none;
  }
}

/* ========== Authenticated app shell ========== */
.header-inner--app {
  max-width: 1200px;
}
.site-nav--app {
  gap: 8px 14px;
}
.site-nav--app .user-section {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-left: 4px;
}
.user-credits {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  background: var(--primary-soft);
  border: 1px solid rgba(47, 155, 224, 0.35);
  text-decoration: none;
  white-space: nowrap;
}
.user-credits:hover {
  text-decoration: none;
  border-color: var(--primary);
  color: var(--text);
}
.credits-value {
  color: var(--primary);
  margin-left: 4px;
}
.nav-burger {
  display: none;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
}
.mobile-menu {
  display: none;
  flex-direction: column;
  gap: 10px;
  padding: 16px clamp(16px, 4vw, 40px) 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.mobile-menu.is-open {
  display: flex;
}
.mobile-menu .nav-link,
.mobile-menu .user-credits,
.mobile-menu .btn {
  width: 100%;
  justify-content: center;
  text-align: center;
}
.mobile-menu[hidden] {
  display: none !important;
}
@media (max-width: 768px) {
  .site-nav--app { display: none; }
  .nav-burger { display: inline-flex; }
}
body.app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
body.app-shell > .site-footer {
  margin-top: auto;
}
body.auth-page .site-main {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 200px);
  padding-top: 24px;
  padding-bottom: 24px;
}
.download-opt .btn + .btn {
  margin-left: 8px;
}
.download-opt .btn-row {
  margin-top: 0;
  justify-content: flex-start;
}
