@font-face { font-family: "Poppins"; src: url("fonts/Poppins-ExtraBold.ttf") format("truetype"); font-weight: 600 900; font-display: swap; }
@font-face { font-family: "Archivo"; src: url("fonts/Archivo.ttf") format("truetype"); font-weight: 100 900; font-display: swap; }
@font-face { font-family: "Archivo Black"; src: url("fonts/ArchivoBlack.ttf") format("truetype"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Bricolage Grotesque"; src: url("fonts/BricolageGrotesque.ttf") format("truetype"); font-weight: 200 800; font-display: swap; }
@font-face { font-family: "JetBrains Mono"; src: url("fonts/JetBrainsMono.ttf") format("truetype"); font-weight: 100 800; font-display: swap; }
@font-face { font-family: "Instrument Serif"; src: url("fonts/InstrumentSerif.ttf") format("truetype"); font-weight: 400; font-display: swap; }

:root {
  --bg: #0B0D10; --panel: #14171C; --panel2: #1B1F26; --line: #272C35;
  --text: #F2F5F7; --mute: #8A93A0; --accent: #FF5A1F; --accent2: #4CE0D2;
  --sat: env(safe-area-inset-top, 0px); --sab: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0;
  height: 100%;
  background: #050608;
  color: var(--text);
  font-family: "Archivo", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: stretch;
}

button, input, select, textarea { font: inherit; color: inherit; }
.hidden { display: none !important; }

/* Phone viewport frame container */
.phone-frame {
  width: 100%;
  max-width: 480px;
  height: 100%;
  background: var(--bg);
  position: relative;
  overflow: hidden;
  box-shadow: 0 0 60px rgba(0, 0, 0, 0.85);
  display: flex;
  flex-direction: column;
}

.screen {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  padding-top: var(--sat);
  padding-bottom: var(--sab);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.screen.active { display: flex; }

/* Home Header */
.home-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  background: rgba(11, 13, 16, 0.95);
  border-bottom: 1px solid var(--line);
  z-index: 10;
}
.logo {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 800;
  font-size: 19px;
  letter-spacing: -0.3px;
}
.logo b {
  color: var(--accent);
}
.logo-img {
  width: 36px;
  height: 36px;
  object-fit: contain;
  filter: drop-shadow(0 0 10px rgba(76, 224, 210, 0.45));
}
.head-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}
.apk-badge-link {
  background: linear-gradient(135deg, #FF5A1F, #FF8A00);
  color: #0B0D10;
  padding: 7px 14px;
  border-radius: 999px;
  font-weight: 800;
  font-size: 12px;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 5px;
  box-shadow: 0 0 15px rgba(255, 90, 31, 0.4);
  transition: transform 0.15s ease;
}
.apk-badge-link:hover {
  transform: scale(1.05);
}

/* Home Main */
.home-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 24px 24px 36px;
  gap: 16px;
}
.home-main h1 {
  font-family: "Archivo Black", "Archivo", sans-serif;
  font-size: 46px;
  line-height: 1.05;
  margin: 0;
  letter-spacing: -1px;
}
.sub {
  color: var(--mute);
  line-height: 1.55;
  margin: 0 0 6px;
  font-size: 15px;
}
.hint {
  color: var(--mute);
  font-size: 12.5px;
  line-height: 1.45;
  margin: 4px 0;
}
.cta {
  background: var(--accent);
  color: #0B0D10;
  border: 0;
  border-radius: 14px;
  padding: 18px;
  font-weight: 800;
  font-size: 17px;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(255, 90, 31, 0.35);
  transition: transform 0.15s ease;
}
.cta:hover, .cta:active {
  transform: scale(0.98);
}
.ghost {
  background: var(--panel2);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 12px;
  padding: 14px 18px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease;
}
.ghost:hover {
  background: var(--line);
}
.primary {
  background: var(--accent);
  color: #0B0D10;
  border: 0;
  border-radius: 12px;
  padding: 13px 18px;
  font-weight: 800;
  cursor: pointer;
}
.primary.sm { padding: 8px 15px; font-size: 13px; }
.icon-btn {
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: 12px;
  width: 42px;
  height: 42px;
  font-size: 18px;
  display: grid;
  place-items: center;
  flex: none;
  cursor: pointer;
}

/* Professional Attribution Footer (No AI Slop) */
.app-credit {
  margin-top: auto;
  padding: 20px 0 8px;
  text-align: center;
  font-size: 12.5px;
  color: var(--mute);
  letter-spacing: 0.2px;
}
.app-credit a {
  color: var(--accent2);
  text-decoration: none;
  font-weight: 700;
  border-bottom: 1px dotted var(--accent2);
  transition: color 0.15s ease;
}
.app-credit a:hover {
  color: #FFFFFF;
}

/* Editor Screen */
.bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.bar .title {
  flex: 1;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 14px;
}

/* 9:16 Video Stage */
.stage-wrap {
  flex: none;
  height: 42vh;
  display: grid;
  place-items: center;
  background: #050607;
  position: relative;
  overflow: hidden;
}
.stage {
  position: relative;
  max-width: 100%;
  max-height: 100%;
  background: linear-gradient(160deg, #1b2230, #0b0d10 60%, #2a1710);
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.7);
}
.stage video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}
.stage canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.busy {
  position: absolute;
  inset: 0;
  background: rgba(5,6,7,.85);
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  text-align: center;
  padding: 20px;
  font-weight: 600;
  z-index: 50;
}
.busy.on { display: flex; }
.spinner {
  width: 34px;
  height: 34px;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Video Transport */
.transport {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.transport input[type=range] {
  flex: 1;
  accent-color: var(--accent);
  cursor: pointer;
}
.time {
  font-variant-numeric: tabular-nums;
  color: var(--mute);
  font-size: 12px;
  min-width: 78px;
  text-align: right;
}

/* Tabs */
.tabs {
  display: flex;
  gap: 6px;
  padding: 0 14px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.tabs button {
  flex: 1;
  background: none;
  border: 0;
  padding: 12px 0;
  color: var(--mute);
  font-weight: 700;
  font-size: 13px;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: color 0.15s ease;
}
.tabs button.on {
  color: var(--text);
  border-bottom-color: var(--accent);
}

/* Panels */
.panel {
  flex: 1;
  overflow-y: auto;
  padding: 12px 14px 30px;
  -webkit-overflow-scrolling: touch;
}
.chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 12px;
  scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none;
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 12.5px;
  color: var(--mute);
  cursor: pointer;
}
.chip.on {
  background: var(--accent);
  border-color: var(--accent);
  color: #0B0D10;
  font-weight: 700;
}
.grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
.card {
  background: var(--panel);
  border: 1.5px solid var(--line);
  border-radius: 12px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  cursor: pointer;
  text-align: left;
  transition: border-color .15s ease, transform .15s ease;
}
.card:hover {
  border-color: var(--mute);
}
.card.on {
  border-color: var(--accent);
  background: var(--panel2);
}
.card canvas {
  width: 100%;
  aspect-ratio: 16/9;
  border-radius: 8px;
  background: #050607;
  display: block;
}
.card .meta b {
  display: block;
  font-size: 12.5px;
  margin-bottom: 2px;
}
.card .meta span {
  font-size: 11px;
  color: var(--mute);
  line-height: 1.25;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Style Panel */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}
.field label {
  display: flex;
  justify-content: space-between;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--mute);
}
.field label .v {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.field input[type=range] {
  accent-color: var(--accent);
  width: 100%;
  cursor: pointer;
}
.field input[type=color] {
  width: 100%;
  height: 38px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel2);
  cursor: pointer;
  padding: 0 4px;
}
.field select {
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  color: var(--text);
  font-size: 13px;
  outline: none;
}
.two {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.toggle {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  font-size: 13px;
  font-weight: 700;
  border-bottom: 1px solid var(--line);
  margin-bottom: 10px;
}
.toggle input {
  accent-color: var(--accent);
  width: 20px;
  height: 20px;
  cursor: pointer;
}

/* Text Panel */
.seg {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  margin-bottom: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.seg .top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  color: var(--mute);
}
.seg .del {
  background: none;
  border: 0;
  color: #ff6b6b;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  padding: 2px 6px;
}
.seg textarea {
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  padding: 8px;
  font-size: 13px;
  resize: vertical;
  line-height: 1.35;
  outline: none;
}
.seg textarea:focus {
  border-color: var(--accent);
}

/* Sheets (Settings & Export) */
.sheet-bg {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: flex-end;
  z-index: 100;
}
.sheet {
  width: 100%;
  background: var(--panel);
  border-top: 1px solid var(--line);
  border-radius: 20px 20px 0 0;
  padding: 24px 20px 32px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.7);
  max-height: 85vh;
  overflow-y: auto;
}
.sheet h2 {
  margin: 0 0 4px;
  font-size: 20px;
  font-weight: 800;
}
.sheet h3 {
  margin: 8px 0 2px;
  font-size: 13px;
  color: var(--mute);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.sheet label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--mute);
}
.sheet input, .sheet select {
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  color: var(--text);
  font-size: 13.5px;
  outline: none;
}
.sheet input:focus, .sheet select:focus {
  border-color: var(--accent);
}
.sheet .row {
  display: flex;
  gap: 10px;
  margin-top: 6px;
}
.sheet .row button {
  flex: 1;
}
.progress {
  width: 100%;
  height: 8px;
  background: var(--panel2);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 4px;
}
.progress div {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  width: 0%;
  transition: width 0.1s linear;
}

/* Toast Notification */
.toast {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--panel2);
  border: 1px solid var(--accent);
  color: var(--text);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 700;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.7);
  z-index: 200;
  white-space: nowrap;
  pointer-events: none;
  animation: toastIn 0.2s ease;
}
@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, 10px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}
