:root {
  --bg: #f5f5f5;
  --text: #111111;
  --line: #d1d5db;
  --green: #0f766e;
  --green-dark: #115e59;
  --panel: #ffffff;
  --danger: #c31d3f;
  --warning: #a16207;
  --ok: #15803d;
  --info: #1d4ed8;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "Manrope", sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
}

.topbar {
  height: 78px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 26px;
}

.brand {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  color: #111111;
  white-space: nowrap;
}

.brand span {
  color: var(--green);
}

.menu {
  display: flex;
  gap: 24px;
  margin-left: 26px;
}

.menu a {
  text-decoration: none;
  color: #111827;
  font-weight: 700;
  font-size: 1.04rem;
  white-space: nowrap;
}

.chrome-btn,
.home-link {
  margin-left: auto;
  border: 0;
  border-radius: 999px;
  background: var(--green);
  color: #ffffff;
  font-weight: 700;
  font-size: 1rem;
  padding: 13px 20px;
  text-decoration: none;
}

.hero-wrap,
.viewer-wrap {
  width: min(1100px, calc(100% - 36px));
  margin: 0 auto;
}

.hero {
  text-align: center;
  padding: 90px 0 34px;
}

.hero h1 {
  margin: 0;
  font-size: clamp(2rem, 5vw, 4rem);
  letter-spacing: -0.03em;
}

.subtitle {
  margin: 20px auto 0;
  max-width: 760px;
  color: #1f2937;
  font-size: clamp(1rem, 2vw, 1.5rem);
  line-height: 1.42;
}

.extract-form {
  margin-top: 26px;
}

.input-shell {
  width: min(680px, 100%);
  margin: 0 auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 999px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding: 8px;
}

.input-shell input {
  border: 0;
  font-size: 1.15rem;
  padding: 10px 16px;
  background: transparent;
  color: #111827;
}

.input-shell input:focus {
  outline: none;
}

.paste-btn {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--green);
  color: #ffffff;
  font-weight: 700;
  font-size: 1.01rem;
  padding: 0 22px;
}

.actions-row {
  margin-top: 18px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.start-btn,
.download-main-btn {
  border: 0;
  border-radius: 999px;
  background: var(--green);
  color: #ffffff;
  font-weight: 800;
  font-size: 1.2rem;
  padding: 12px 28px;
  cursor: pointer;
}

.start-btn:hover,
.download-main-btn:hover {
  background: var(--green-dark);
}

.start-btn:disabled,
.download-main-btn:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.clear-btn,
.back-link {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: #111827;
  font-weight: 700;
  font-size: 1rem;
  padding: 10px 18px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.time-note {
  margin: 15px 0 0;
  color: #4b5563;
  font-size: 0.95rem;
}

.status {
  display: none;
  width: min(720px, 100%);
  margin: 14px auto 0;
  border-radius: 12px;
  padding: 10px 12px;
  border: 1px solid;
  text-align: left;
}

.status.show {
  display: block;
}

.status.info {
  background: #eff6ff;
  border-color: #bfdbfe;
  color: var(--info);
}

.status.success {
  background: #f0fdf4;
  border-color: #86efac;
  color: var(--ok);
}

.status.warning {
  background: #fffbeb;
  border-color: #fde68a;
  color: var(--warning);
}

.status.error {
  background: #fef2f2;
  border-color: #fca5a5;
  color: var(--danger);
}

.processing-modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: grid;
  place-items: center;
  z-index: 1000;
}

.processing-modal[hidden] {
  display: none !important;
}

.processing-card {
  width: min(420px, calc(100% - 36px));
  background: #fff;
  border-radius: 18px;
  border: 1px solid var(--line);
  padding: 26px 20px;
  text-align: center;
}

.processing-card h2 {
  margin: 10px 0 8px;
  font-size: 1.35rem;
}

.processing-card p {
  margin: 0;
  color: #4b5563;
}

.spinner {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 4px solid #e5e7eb;
  border-top-color: var(--green);
  margin: 0 auto;
  animation: spin 0.9s linear infinite;
}

.viewer-wrap {
  padding: 28px 0 42px;
}

.viewer-empty,
.viewer-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 20px;
}

.viewer-empty {
  text-align: center;
}

.start-link {
  margin-top: 14px;
  display: inline-flex;
}

.viewer-panel h1 {
  margin: 0;
  font-size: clamp(1.4rem, 3vw, 2rem);
}

.viewer-meta {
  margin: 8px 0 16px;
  color: #4b5563;
}

.preview-frame {
  width: 100%;
  aspect-ratio: 16/9;
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  background: #0b1220;
  position: relative;
}

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

.preview-fallback {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #e5e7eb;
}

.viewer-actions {
  margin-top: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  align-items: center;
}

.quality-chip-row {
  margin-top: 14px;
  display: flex;
  justify-content: center;
}

.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.quality-chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: #111827;
  font-weight: 700;
  font-size: 0.82rem;
  padding: 7px 12px;
  text-align: center;
  cursor: pointer;
}

.quality-chip.active {
  border-color: var(--green);
  background: var(--green);
  color: #ffffff;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 980px) {
  .menu,
  .chrome-btn:not(.home-link) {
    display: none;
  }

  .topbar {
    height: auto;
    justify-content: space-between;
    padding: 12px 16px;
    gap: 12px;
  }

  .hero-wrap,
  .viewer-wrap {
    width: min(100%, calc(100% - 24px));
  }

  .home-link {
    margin-left: auto;
    padding: 10px 14px;
    font-size: 0.9rem;
  }

  .hero {
    padding-top: 44px;
  }
}

@media (max-width: 720px) {
  .topbar {
    padding: 10px 12px;
  }

  .brand {
    font-size: 1.6rem;
  }

  .hero {
    padding: 32px 0 20px;
  }

  .subtitle {
    margin-top: 14px;
    font-size: 1rem;
  }

  .input-shell {
    border-radius: 16px;
    grid-template-columns: 1fr;
    padding: 10px;
  }

  .input-shell input {
    font-size: 1rem;
    padding: 12px 10px;
  }

  .paste-btn {
    height: 44px;
    width: 100%;
  }

  .actions-row {
    flex-direction: column;
    align-items: stretch;
  }

  .start-btn,
  .download-main-btn,
  .back-link,
  .clear-btn {
    width: 100%;
    font-size: 1.05rem;
  }

  .viewer-wrap {
    padding: 14px 0 24px;
  }

  .viewer-empty,
  .viewer-panel {
    border-radius: 16px;
    padding: 14px;
  }

  .viewer-meta {
    margin: 4px 0 12px;
    font-size: 0.92rem;
  }

  .preview-frame {
    border-radius: 12px;
  }

  .viewer-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .quality-chip-row {
    margin-top: 12px;
  }

  .quality-chip {
    font-size: 0.8rem;
    padding: 8px 11px;
  }

  .processing-card {
    width: min(420px, calc(100% - 20px));
    padding: 22px 14px;
  }
}

@media (max-width: 480px) {
  .hero-wrap,
  .viewer-wrap {
    width: min(100%, calc(100% - 16px));
  }

  .brand {
    font-size: 1.42rem;
  }

  .home-link {
    padding: 8px 11px;
    font-size: 0.82rem;
  }

  .hero h1 {
    font-size: clamp(1.65rem, 8vw, 2rem);
  }

  .subtitle {
    font-size: 0.95rem;
    line-height: 1.35;
  }

  .time-note {
    font-size: 0.86rem;
  }
}
