@import url("https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500&family=IBM+Plex+Sans+Thai:wght@400;500;600;700&family=Outfit:wght@600;700;800&display=swap");
@import "./tokens.css";
@import "./responsive.css";

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  color-scheme: light;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-ui);
  font-size: 17px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--canvas);
  -webkit-font-smoothing: antialiased;
  position: relative;
  overflow-x: hidden;
}

.bg-fun {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
}

.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(40px);
  opacity: 0.55;
  animation: drift 14s var(--ease) infinite alternate;
}

.orb-a {
  width: 42vw;
  height: 42vw;
  top: -12%;
  left: -8%;
  background: radial-gradient(circle, var(--sky), transparent 70%);
}

.orb-b {
  width: 28vw;
  height: 28vw;
  top: 8%;
  right: -6%;
  background: radial-gradient(circle, rgba(255, 59, 31, 0.18), transparent 70%);
  animation-delay: -4s;
}

.orb-c {
  width: 36vw;
  height: 36vw;
  bottom: -10%;
  left: 30%;
  background: radial-gradient(circle, var(--mint), transparent 70%);
  animation-delay: -8s;
}

@keyframes drift {
  from {
    transform: translate3d(0, 0, 0) scale(1);
  }
  to {
    transform: translate3d(3%, 4%, 0) scale(1.08);
  }
}

a {
  color: var(--ink);
  text-underline-offset: 3px;
}
a:hover {
  color: var(--rush);
}

img {
  max-width: 100%;
  display: block;
}

button,
input,
select {
  font: inherit;
}

:focus-visible {
  outline: 2px solid var(--rush);
  outline-offset: 2px;
}

.skip {
  position: absolute;
  left: -999px;
}
.skip:focus {
  left: 16px;
  top: 16px;
  z-index: 100;
  background: var(--rush);
  color: #fff;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
}

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  border: 0 !important;
  white-space: nowrap !important;
}

.site-header,
.stage,
.site-footer {
  position: relative;
  z-index: 1;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  max-width: var(--max);
  margin: 0 auto;
  padding: 18px 20px;
}

.brand {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.35rem;
  letter-spacing: -0.03em;
  color: var(--ink);
  text-decoration: none;
}
.brand span {
  color: var(--rush);
}

.nav {
  display: flex;
  align-items: center;
  gap: 12px;
}

.credits-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.75);
  border: 1px solid var(--line);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--mute);
}
.credits-pill strong {
  color: var(--ink);
}
.btn-credit {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 0;
  background: var(--rush);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
  line-height: 1;
}
.btn-credit:hover {
  background: var(--rush-deep);
}

.btn-login {
  border: 1.5px solid var(--line);
  background: rgba(255, 255, 255, 0.9);
  color: var(--ink);
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 700;
  padding: 7px 14px;
  border-radius: 999px;
  cursor: pointer;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.btn-login:hover {
  border-color: var(--rush);
  color: var(--rush);
}
.btn-login.is-in {
  border-color: transparent;
  background: var(--ink);
  color: #fff;
}

.chrome-live {
  border: 0;
  padding: 0;
  width: min(980px, 96vw);
  max-height: min(92vh, 900px);
  border-radius: var(--radius-lg);
  background: #0c0e12;
  color: #f4f6f8;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.chrome-live::backdrop {
  background: rgba(8, 10, 14, 0.72);
  backdrop-filter: blur(6px);
}
.chrome-live-bar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  background: #151922;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.chrome-live-kicker {
  margin: 0;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #8ab4f8;
}
.chrome-live-msg {
  margin: 4px 0 0;
  font-size: 0.95rem;
  font-weight: 600;
}
.chrome-live-stage {
  position: relative;
  background: #000;
  min-height: 280px;
  max-height: min(70vh, 720px);
  overflow: auto;
  display: grid;
  place-items: center;
}
.chrome-live-stage img {
  display: block;
  width: 100%;
  height: auto;
  cursor: crosshair;
  user-select: none;
}
.chrome-live-stage img:not([src]),
.chrome-live-stage img[src=""] {
  display: none;
}
.chrome-live-wait {
  margin: 0;
  padding: 48px 20px;
  color: rgba(255, 255, 255, 0.55);
  font-size: 0.95rem;
}
.chrome-live-hint {
  margin: 0;
  padding: 12px 16px 16px;
  font-size: 0.82rem;
  color: rgba(255, 255, 255, 0.55);
  background: #151922;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.auth-modal {
  border: 0;
  padding: 0;
  width: min(420px, 94vw);
  border-radius: var(--radius-lg);
  background: #fff;
  box-shadow: var(--shadow-lg);
}
.auth-modal::backdrop {
  background: rgba(12, 14, 18, 0.55);
  backdrop-filter: blur(5px);
}
.auth-close-row {
  display: flex;
  justify-content: flex-end;
  margin: 0;
  padding: 10px 12px 0;
}
.auth-x {
  border: 0;
  background: transparent;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  color: var(--mute);
}
.auth-body {
  padding: 4px 24px 26px;
  text-align: center;
}
.auth-body h2 {
  margin: 0 0 6px;
  font-family: var(--font-display);
  font-size: 1.45rem;
  letter-spacing: -0.02em;
}
.auth-lede {
  margin: 0 0 18px;
  color: var(--mute);
  font-size: 0.95rem;
}
.auth-confirm-link {
  display: inline-block;
  margin: 4px 0 8px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--rush);
  word-break: break-all;
}
.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 18px 0 14px;
  color: var(--mute);
  font-size: 0.8rem;
}
.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}
.auth-name-label {
  display: block;
  text-align: left;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--mute);
  margin-bottom: 6px;
}
#auth-name,
#auth-email,
#auth-password {
  width: 100%;
  min-height: 46px;
  margin-bottom: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1.5px solid var(--line);
  font-size: 16px;
}
#auth-email-btn,
#auth-guest {
  width: 100%;
}
.btn-magic {
  width: 100%;
  min-height: 46px;
  margin-top: 8px;
  border-radius: 14px;
  border: 1.5px solid var(--line);
  background: #fff;
  color: var(--ink);
  font-weight: 700;
  cursor: pointer;
}
.btn-magic:hover {
  border-color: var(--rush);
  color: var(--rush);
}
.btn-ghost-dark {
  width: 100%;
  min-height: 46px;
  border-radius: 14px;
  border: 1.5px solid var(--line);
  background: transparent;
  color: var(--mute);
  font-weight: 600;
  cursor: pointer;
}
.btn-ghost-dark:hover {
  color: var(--ink);
  border-color: var(--ink);
}


.api-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--mute);
  font-size: 0;
  display: inline-block;
}
.api-dot.is-on {
  background: var(--ok);
  box-shadow: 0 0 0 4px rgba(27, 143, 90, 0.15);
}
.api-dot.is-off {
  background: var(--danger);
}

.chrome-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 4px 9px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.75);
  color: var(--mute);
}
.chrome-pill.is-on {
  color: #1a73e8;
  border-color: rgba(26, 115, 232, 0.35);
  background: rgba(26, 115, 232, 0.08);
}
.chrome-pill.is-off {
  color: var(--danger);
  border-color: rgba(200, 40, 40, 0.3);
}

.locale {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 999px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.8);
}
.locale button {
  border: 0;
  background: transparent;
  padding: 6px 10px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--mute);
  cursor: pointer;
}
.locale button[aria-pressed="true"] {
  background: var(--ink);
  color: #fff;
}

.stage {
  max-width: var(--max);
  margin: 0 auto;
  padding: 12px 20px 64px;
}

.hero-block {
  text-align: center;
  padding: 28px 0 18px;
  animation: rise 500ms var(--bounce) both;
}

.brand-lockup {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(2.6rem, 7vw, 4.2rem);
  letter-spacing: -0.045em;
  line-height: 0.95;
}
.brand-lockup span {
  color: var(--rush);
}

.lede {
  margin: 14px auto 0;
  max-width: 28ch;
  color: var(--mute);
  font-size: 1.05rem;
  font-weight: 500;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin: 18px 0 0;
}
.chips span {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--mute);
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid var(--line);
  padding: 5px 10px;
  border-radius: 999px;
  animation: pop 480ms var(--bounce) both;
}
.chips {
  max-width: min(920px, 100%);
  margin-left: auto;
  margin-right: auto;
}
.chips span:nth-child(odd) {
  animation-delay: 40ms;
}
.chips span:nth-child(3n) {
  animation-delay: 80ms;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
@keyframes pop {
  from {
    opacity: 0;
    transform: scale(0.86);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.tool-stage {
  max-width: var(--tool);
  margin: 18px auto 0;
  padding: 16px;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(225, 229, 234, 0.9);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  animation: rise 560ms var(--bounce) 80ms both;
}

.tool-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

#url {
  width: 100%;
  min-height: 52px;
  padding: 12px 16px;
  border-radius: 14px;
  border: 1.5px solid var(--line);
  background: #fff;
  font-size: 16px;
}
#url:focus {
  border-color: var(--rush);
  box-shadow: 0 0 0 4px rgba(255, 59, 31, 0.12);
  outline: none;
}

.btn {
  min-height: 52px;
  padding: 0 22px;
  border-radius: 14px;
  border: 0;
  font-weight: 700;
  cursor: pointer;
  transition: transform 160ms var(--ease), background 160ms var(--ease);
}
.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.btn-rush {
  background: var(--rush);
  color: #fff;
  box-shadow: 0 10px 24px rgba(255, 59, 31, 0.28);
}
.btn-rush:hover:not(:disabled) {
  background: var(--rush-deep);
  transform: translateY(-1px);
}
.btn-rush:active:not(:disabled) {
  transform: translateY(1px) scale(0.98);
}
.btn-ghost {
  border: 0;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  padding: 8px 14px;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 600;
}

.helper {
  margin: 10px 4px 0;
  font-size: 0.875rem;
  color: var(--mute);
  text-align: left;
}
.helper.is-error {
  color: var(--danger);
}

.pickers {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
  margin-top: 14px;
}
.pickers[hidden] {
  display: none;
}
.field label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--mute);
  margin-bottom: 4px;
}
.field select {
  width: 100%;
  min-height: 44px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--line);
  background: #fff;
  padding: 0 10px;
}

.alert {
  max-width: var(--tool);
  margin: 16px auto 0;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  background: #fff1ef;
  border: 1px solid #ffd4ce;
  color: var(--danger);
  text-align: left;
  animation: rise 280ms var(--ease) both;
}
.alert code {
  font-family: var(--font-mono);
  font-size: 0.8rem;
}

/* Result studio */
.studio {
  max-width: min(960px, 100%);
  margin: 28px auto 0;
  padding: 20px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  animation: rise 420ms var(--bounce) both;
}
.studio[hidden] {
  display: none;
}

.studio-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}
.studio-kicker {
  margin: 0 0 4px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--mute);
}
.studio-head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.15rem, 3vw, 1.55rem);
  letter-spacing: -0.02em;
  line-height: 1.25;
}
.studio-actions {
  flex-shrink: 0;
}
.studio-actions .btn {
  min-height: 44px;
}

.progress {
  margin-bottom: 16px;
}
.progress-track {
  height: 8px;
  border-radius: 999px;
  background: var(--line);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--rush), #ff7a4d);
  border-radius: inherit;
  transition: width 280ms var(--ease);
}
.progress-label {
  margin: 8px 0 0;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--mute);
}

.player-stage {
  position: relative;
  border-radius: 18px;
  overflow: hidden;
  background: #0d0f14;
  margin-bottom: 18px;
  min-height: 180px;
  display: grid;
  place-items: center;
}
.player-stage[hidden] {
  display: none;
}
#player-video,
#player-audio,
.player-image {
  width: 100%;
  display: none;
}
.player-stage.is-video #player-video {
  display: block;
  max-height: min(62vh, 560px);
  background: #000;
}
.player-stage.is-audio #player-audio {
  display: block;
  width: min(100%, 520px);
  margin: 28px auto;
}
.player-stage.is-image .player-image {
  display: grid;
  place-items: center;
  margin: 0;
  padding: 12px;
  background: #111;
}
.player-stage.is-image .player-image img {
  max-height: min(62vh, 560px);
  width: auto;
  max-width: 100%;
  border-radius: 8px;
  cursor: zoom-in;
}

.gallery {
  margin-top: 4px;
}
.gallery[hidden] {
  display: none;
}
.gallery-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.gallery-head h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.05rem;
}
.gallery-count {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--mute);
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
}

.tile {
  position: relative;
  border: 0;
  padding: 0;
  border-radius: 14px;
  overflow: hidden;
  background: #eceff3;
  cursor: pointer;
  aspect-ratio: 1;
  box-shadow: 0 1px 0 rgba(18, 20, 26, 0.04);
  transition: transform 180ms var(--bounce), box-shadow 180ms var(--ease);
}
.tile:hover,
.tile.is-active {
  transform: translateY(-3px) scale(1.02);
  box-shadow: 0 12px 28px rgba(18, 20, 26, 0.12);
}
.tile.is-active {
  outline: 2px solid var(--rush);
  outline-offset: 2px;
}
.tile img,
.tile video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.tile-badge {
  position: absolute;
  left: 8px;
  bottom: 8px;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #fff;
  background: rgba(18, 20, 26, 0.72);
  padding: 3px 7px;
  border-radius: 999px;
}
.tile-play {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: linear-gradient(transparent 40%, rgba(0, 0, 0, 0.35));
}
.tile-play::before {
  content: "";
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: rgba(255, 59, 31, 0.95);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.25);
  clip-path: polygon(38% 28%, 38% 72%, 72% 50%);
}

.lightbox {
  border: 0;
  padding: 0;
  max-width: min(96vw, 1100px);
  max-height: 92vh;
  background: transparent;
}
.lightbox::backdrop {
  background: rgba(10, 12, 16, 0.82);
  backdrop-filter: blur(6px);
}
.lightbox-bar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 8px;
}
.lightbox img {
  max-width: 96vw;
  max-height: 84vh;
  margin: 0 auto;
  border-radius: 12px;
}

.site-footer {
  text-align: center;
  padding: 28px 16px 40px;
  color: var(--mute);
  font-size: 0.85rem;
}

@media (max-width: 720px) {
  .tool-row {
    grid-template-columns: 1fr;
  }
  .btn-rush {
    width: 100%;
  }
  .pickers {
    grid-template-columns: 1fr;
  }
  .studio-head {
    flex-direction: column;
  }
  .studio-actions .btn {
    width: 100%;
  }
  .gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(108px, 1fr));
  }
}
