:root {
  --primary: #262b33;
  --primary-dark: #15191f;
  --font: #0d0d0d;
  --muted: #606060;
  --bg: #fafafa;
  --panel: #ffffff;
  --line: #d7d7d7;
  --input-bg: #ffffff;
  --input-font: #111111;
  --thumb-bg: #dedede;
  --toggle-bg: #0d0d0d;
  --toggle-font: #ffffff;
}

[data-theme="dark"] {
  --primary: #20242b;
  --primary-dark: #12161b;
  --font: #ffffff;
  --muted: #aaaaaa;
  --bg: #1f1f1f;
  --panel: #242424;
  --line: #3d3d3d;
  --input-bg: #151515;
  --input-font: #ffffff;
  --thumb-bg: #333333;
  --toggle-bg: #ffffff;
  --toggle-font: #111111;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: Roboto, Arial, sans-serif;
  color: var(--font);
  background: var(--bg);
}

body {
  font-size: 16px;
}

.app {
  min-height: 100vh;
  background: var(--bg);
}

.hero {
  min-height: 92vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 20px 56px;
  color: #fff;
  background: var(--primary);
}

.hero-inner {
  width: min(760px, 100%);
  text-align: center;
}

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

h1 {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.24em;
  margin-bottom: 14px;
  font-size: clamp(3.8rem, 8vw, 6.2rem);
  line-height: 0.96;
  font-weight: 700;
  text-transform: uppercase;
}

.youtube-mark {
  width: 0.72em;
  height: 0.5em;
  border-radius: 0.12em;
  display: inline-grid;
  place-items: center;
  background: #ff0033;
  flex: 0 0 auto;
}

.youtube-mark::before {
  content: "";
  width: 0;
  height: 0;
  margin-left: 0.04em;
  border-top: 0.13em solid transparent;
  border-bottom: 0.13em solid transparent;
  border-left: 0.2em solid #fff;
}

.hero p {
  width: min(560px, 100%);
  margin: 0 auto 24px;
  font-size: 1.12rem;
  line-height: 1.48;
}

.upload-shell {
  position: relative;
  min-height: 174px;
  margin: 0 auto 22px;
  padding: 26px 22px;
  border: 3px dashed rgba(255, 255, 255, 0.92);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  font-size: 1rem;
  cursor: pointer;
  transition: background 160ms ease, border-color 160ms ease;
}

.upload-shell.dragging {
  border-color: #0d0d0d;
  background: rgba(0, 0, 0, 0.18);
}

.upload-action {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  color: #fff;
  font-size: 1.12rem;
  line-height: 1.25;
}

.btn {
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 9px 16px;
  font: inherit;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
}

.primary {
  color: #fff;
  background: var(--primary-dark);
  border-color: var(--primary-dark);
}

.ghost {
  color: #fff;
  background: transparent;
  border-color: #fff;
}

#fileInput {
  display: none;
}

.title-input {
  display: block;
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 10px 13px;
  font-size: 1rem;
  color: var(--input-font);
  background: var(--input-bg);
}

.workspace {
  padding: 20px 0 72px;
}

.toolbar,
.section-title,
.preview-block,
.original,
.competitor-strip {
  width: min(760px, calc(100% - 32px));
  margin-left: auto;
  margin-right: auto;
}

.toolbar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
  font-size: 0.95rem;
}

.safe-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--font);
  cursor: pointer;
}

.safe-toggle input {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
}

.switch {
  position: relative;
  display: inline-block;
  width: 60px;
  height: 34px;
}

.switch input {
  opacity: 0;
}

.slider {
  position: absolute;
  inset: 0;
  border-radius: 34px;
  background: #c9c9c9;
  cursor: pointer;
  transition: 0.2s;
}

.slider::before {
  content: "";
  position: absolute;
  width: 26px;
  height: 26px;
  left: 4px;
  bottom: 4px;
  border-radius: 50%;
  background: #fff;
  transition: 0.2s;
}

.switch input:checked + .slider {
  background: var(--primary);
}

.switch input:checked + .slider::before {
  transform: translateX(26px);
}

.section-title h2 {
  color: var(--font);
  margin: 30px 0 18px;
  font-size: 1.45rem;
  line-height: 1.15;
  letter-spacing: 0;
  text-transform: uppercase;
}

.competitor-section {
  margin-bottom: 18px;
}

.competitor-strip {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 220px;
  gap: 14px;
  overflow-x: auto;
  padding-bottom: 12px;
}

.competitor-card {
  min-width: 0;
}

.competitor-card img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 8px;
  background: #ddd;
}

.competitor-card h3 {
  display: -webkit-box;
  min-height: 2.6rem;
  margin: 10px 0 4px;
  color: var(--font);
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  font-size: 0.95rem;
  line-height: 1.3rem;
  text-transform: none;
}

.competitor-card p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.2rem;
}

.user-card img {
  outline: 3px solid var(--primary);
  outline-offset: 3px;
}

.analysis-toggle {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 14;
  border: 0;
  border-radius: 6px;
  padding: 10px 14px;
  color: var(--toggle-font);
  background: var(--toggle-bg);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.24);
  font: inherit;
  font-size: 0.92rem;
  font-weight: 700;
  cursor: pointer;
}

.analysis-scrim {
  position: fixed;
  inset: 0;
  z-index: 11;
  background: rgba(0, 0, 0, 0.28);
}

.analysis-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 12;
  width: min(400px, 92vw);
  padding: 22px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-right: 0;
  border-radius: 0;
  background: var(--panel);
  box-shadow: -18px 0 36px rgba(0, 0, 0, 0.24);
  transform: translateX(100%);
  transition: transform 180ms ease;
}

.analysis-panel.open {
  transform: translateX(0);
}

.analysis-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: start;
  margin-bottom: 16px;
}

.analysis-head h2 {
  color: var(--font);
  margin-bottom: 5px;
  font-size: 1.45rem;
  line-height: 1.15;
  text-transform: uppercase;
}

.analysis-head p,
.analysis-notes p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.35rem;
}

.score-card {
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  margin-bottom: 16px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
}

.score-ring {
  width: 74px;
  height: 74px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  align-content: center;
  background:
    radial-gradient(circle at center, var(--panel) 58%, transparent 59%),
    conic-gradient(var(--score-color) calc(var(--score) * 1%), #d6d6d6 0);
}

.score-card.excellent,
.score-card.strong {
  --score-color: #2f9e67;
}

.score-card.fair {
  --score-color: #d69c2f;
}

.score-card.weak {
  --score-color: #c84d4d;
}

.score-ring strong {
  font-size: 1.7rem;
  line-height: 1.7rem;
}

.score-ring span {
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 0.8rem;
}

.score-card h3 {
  color: var(--font);
  margin-bottom: 5px;
  font-size: 1.12rem;
  line-height: 1.25rem;
}

.score-card p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.22rem;
}

.score-breakdown {
  display: grid;
  gap: 7px;
  margin-bottom: 16px;
}

.score-breakdown h3,
.text-analysis h3 {
  color: var(--font);
  margin-bottom: 4px;
  font-size: 1rem;
  line-height: 1.2rem;
}

.text-analysis {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
}

.text-score {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-left-width: 5px;
  border-radius: 6px;
  background: var(--bg);
}

.text-score.good {
  border-left-color: #2f9e67;
}

.text-score.warn {
  border-left-color: #d69c2f;
}

.text-score.bad {
  border-left-color: #c84d4d;
}

.text-score.neutral {
  border-left-color: var(--muted);
}

.text-score strong {
  font-size: 0.82rem;
}

.text-score span,
.text-notes p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.12rem;
}

.detected-text {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--font);
  background: var(--bg);
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.3rem;
}

.text-notes {
  display: grid;
  gap: 6px;
}

.breakdown-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-left-width: 5px;
  border-radius: 6px;
  background: var(--bg);
}

.breakdown-row span {
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.12rem;
}

.breakdown-row strong {
  font-size: 0.82rem;
}

.breakdown-row.good {
  border-left-color: #2f9e67;
}

.breakdown-row.warn {
  border-left-color: #d69c2f;
}

.breakdown-row.bad {
  border-left-color: #c84d4d;
}

.close-panel {
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--font);
  background: var(--bg);
  font-size: 1.7rem;
  line-height: 1;
  cursor: pointer;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
  margin-bottom: 16px;
}

.metric {
  min-height: 64px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
}

.metric span,
.layout-risk p {
  display: block;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.08rem;
}

.metric strong {
  display: block;
  color: var(--font);
  margin-top: 7px;
  font-size: 1.12rem;
  line-height: 1.3rem;
}

.layout-grid {
  display: grid;
  gap: 9px;
  margin-bottom: 16px;
}

.layout-risk {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 11px;
  border: 1px solid var(--line);
  border-left-width: 6px;
  border-radius: 6px;
  background: var(--bg);
}

.layout-risk h3 {
  color: var(--font);
  margin-bottom: 4px;
  font-size: 0.92rem;
  line-height: 1.15rem;
  text-transform: none;
}

.layout-risk p {
  margin-bottom: 0;
}

.layout-risk strong {
  min-width: 58px;
  text-align: right;
  font-size: 0.82rem;
}

.layout-risk.good {
  border-left-color: #2f9e67;
}

.layout-risk.check {
  border-left-color: #d69c2f;
}

.layout-risk.risk {
  border-left-color: #c84d4d;
}

.analysis-notes {
  display: grid;
  gap: 8px;
}

.preview-block {
  margin-bottom: 26px;
  overflow-x: auto;
}

.preview-block h3,
.original h3 {
  color: var(--font);
  margin-bottom: 14px;
  font-size: 0.98rem;
  line-height: 1.2rem;
  text-transform: uppercase;
}

.video-card {
  display: inline-block;
  min-width: var(--card-min, auto);
  margin-bottom: 4px;
  vertical-align: top;
}

.video-card.beside {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.thumb-wrap {
  position: relative;
  width: var(--thumb-width);
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: 12px;
  background: var(--thumb-bg);
  flex: 0 0 auto;
}

.sidebar .thumb-wrap,
.watch-list .thumb-wrap,
.mobile-column .thumb-wrap {
  border-radius: 8px;
}

.mobile-home .thumb-wrap,
.original .thumb-wrap {
  border-radius: 0;
}

.thumb {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.safe-zone-overlay {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: none;
  pointer-events: none;
}

.show-safe-zones .safe-zone-overlay {
  display: block;
}

.safe-edge {
  position: absolute;
  inset: 8%;
  border: 2px dashed rgba(255, 255, 255, 0.9);
  box-shadow: 0 0 0 999px rgba(0, 0, 0, 0.22);
}

.safe-center {
  position: absolute;
  left: 25%;
  top: 18%;
  width: 50%;
  height: 64%;
  border: 2px solid rgba(47, 158, 103, 0.95);
  background: rgba(47, 158, 103, 0.12);
}

.safe-duration {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 31%;
  height: 24%;
  border: 2px solid rgba(255, 214, 102, 0.95);
  background: rgba(255, 214, 102, 0.2);
}

.duration {
  position: absolute;
  z-index: 4;
  right: 4px;
  bottom: 4px;
  padding: 2px 4px;
  border-radius: 4px;
  color: #fff;
  background: rgba(0, 0, 0, 0.8);
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 0.8rem;
}

.watch-overlay {
  position: absolute;
  inset: auto 0 0;
  height: 40px;
  display: grid;
  place-items: center;
  color: rgba(255, 255, 255, 0.88);
  background: rgba(18, 18, 18, 0.82);
  font-size: 1rem;
}

.avatar {
  width: 36px;
  height: 36px;
  float: left;
  margin-top: 10px;
  margin-right: 12px;
  border-radius: 50%;
  background: #d4d4d4;
}

.text-block {
  width: var(--title-width, var(--thumb-width));
  padding-top: 8px;
  font-size: 0.88rem;
  line-height: 1.25rem;
}

.beside .text-block {
  padding-top: 0;
}

.text-block.wide {
  width: min(460px, 52vw);
}

.video-title {
  display: -webkit-box;
  max-height: 2.6rem;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  font-size: 0.88rem;
  font-weight: 500;
  line-height: 1.3rem;
}

.details,
.description {
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.28rem;
}

.details span {
  display: block;
}

.sidebar .details,
.watch-list .details,
.channel-small .details,
.history .details {
  font-size: 0.76rem;
  line-height: 1.1rem;
}

.description {
  margin: 8px 0 0;
  color: var(--font);
}

.clamp {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.mobile-previews {
  width: min(760px, calc(100% - 32px));
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 512px);
  gap: 24px;
  align-items: start;
}

.mobile-previews .preview-block {
  width: 100%;
}

.phone-feed {
  width: min(512px, 100%);
  overflow: hidden;
}

.appletv {
  margin-top: 38px;
  padding: 34px max(16px, calc((100% - 760px) / 2));
  color: #fff;
  background: #151515;
}

.appletv .section-title,
.appletv .video-card {
  width: min(760px, 100%);
}

.appletv .thumb-wrap {
  border-radius: 16px;
}

.appletv .duration {
  margin: 8px;
  padding: 10px 8px;
  border-radius: 8px;
  font-size: 1.3rem;
  line-height: 1.3rem;
  background: rgba(0, 0, 0, 0.6);
}

.appletv .video-title {
  opacity: 0.78;
  font-size: 1.5rem;
  font-weight: 300;
  line-height: 2.2rem;
}

.appletv .details {
  color: #fff;
  font-size: 1.35rem;
  line-height: 2rem;
}

.original img {
  width: 100%;
  height: auto;
  cursor: zoom-in;
}

footer {
  min-height: 80px;
  padding: 24px 20px;
  color: #fff;
  background: #000;
}

footer p {
  width: min(760px, 100%);
  margin: 0 auto;
  font-size: 0.95rem;
}

.warning {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.5);
}

.warning[hidden],
.fullscreen[hidden],
.workspace[hidden] {
  display: none;
}

.warning-box {
  width: min(600px, 100%);
  padding: 30px;
  text-align: center;
  color: #fff;
  background: #9a2e2e;
  font-size: 0.95rem;
}

.warning-box h4 {
  font-size: 1.3rem;
  margin-bottom: 20px;
}

.warning-box p {
  margin-bottom: 12px;
}

.fullscreen {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  overflow: auto;
  background: #fff;
  cursor: zoom-out;
}

.fullscreen div {
  position: fixed;
  inset: 0 0 auto;
  z-index: 2;
  padding: 12px;
  text-align: center;
  color: #fff;
  background: rgba(0, 0, 0, 0.52);
  font-size: 1rem;
}

.fullscreen img {
  max-width: none;
  max-height: none;
}

@media (max-width: 760px) {
  .hero {
    min-height: 100vh;
    padding: 28px 16px 44px;
  }

  .hero p {
    font-size: 1rem;
  }

  .upload-shell {
    min-height: 156px;
    flex-wrap: wrap;
    align-content: center;
    padding: 20px;
  }

  .title-input {
    font-size: 0.95rem;
  }

  .mobile-previews {
    display: block;
  }

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

  .text-block.wide {
    width: 320px;
  }

  .channel-large .description {
    display: none;
  }

  .appletv .video-title,
  .appletv .details {
    font-size: 1.15rem;
    line-height: 1.65rem;
  }
}
