*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: "archivo-semi-condensed", sans-serif;
  background: #e6e4e5;
  color: #111;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.page-wrap {
  width: 100%;
  padding: 10px 20px;
  margin: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
}
@media (max-width: 600px) {
  .page-wrap { padding-top: 5px; padding-bottom: 5px; padding-left: 0; padding-right: 0; }
}
#version-footer { font-size: 9px; letter-spacing: 2px; color: #8e8e8e; text-align: center; padding: 8px 0; width: 100%; }
header { text-align: center; margin-bottom: 20px; transition: opacity 0.4s ease, transform 0.4s ease; }
header .fan-ed { font-size: 10px; letter-spacing: 4px; color: #999; text-transform: uppercase; margin-bottom: 8px; }
#kylie-logo { width: 100%; max-width: 300px; display: block; margin: 0 auto; }
#album-select { width: 100%; max-width: 480px; margin-bottom: 40px; }
#album-select h2 { font-size: 10px; letter-spacing: 4px; text-transform: uppercase; color: #aaa; margin-bottom: 24px; padding-bottom: 16px; border-bottom: 1px solid #eee; text-align: center; }
.album-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.album-card { background: #fff; border: 1px solid #e0ddd8; cursor: pointer; transition: border-color 0.2s, box-shadow 0.2s; }
.album-card:hover { border-color: #999; box-shadow: 0 2px 12px rgba(0,0,0,0.08); }
.album-card img { width: 100%; display: block; aspect-ratio: 1; object-fit: cover; }
.album-card-label { padding: 14px 16px; }
.album-card-title { font-size: 11px; letter-spacing: 3px; text-transform: uppercase; color: #111; margin-bottom: 4px; }
.album-card-sub { font-size: 9px; letter-spacing: 2px; text-transform: uppercase; color: #aaa; }
.form-card { background: #fff; border: 1px solid #e0ddd8; padding: 36px 15px; width: 100%; max-width: 480px; }
.form-card h2 { font-size: 10px; letter-spacing: 2px; text-transform: uppercase; color: #aaa; margin-bottom: 28px; padding-bottom: 16px; border-bottom: 1px solid #eee; }
.field { margin-bottom: 20px; }
.field label { display: block; font-size: 9px; letter-spacing: 2px; text-transform: uppercase; color: #aaa; margin-bottom: 8px; }
.field input, .field textarea { width: 100%; border: none; border-bottom: 1px solid #ddd; padding: 8px 0; font-size: 18px; color: #111; background: transparent; outline: none; resize: none; transition: border-color 0.2s; }
.field textarea { font-family: "archivo-semi-condensed", sans-serif; font-weight: 400; font-style: normal; height: 100px; line-height: 1.5; }
.field textarea::placeholder { font-style: normal; }
.field input { font-family: "archivo-semi-condensed", sans-serif; font-weight: 400; font-style: normal; }
.upload-btn-row { display: flex; gap: 10px; margin-top: 4px; }
.upload-btn { flex: 1; display: inline-block; padding: 10px; border: 1px solid #ddd; font-family: "archivo-semi-condensed", sans-serif; font-size: 9px; letter-spacing: 3px; text-transform: uppercase; color: #aaa; text-align: center; cursor: pointer; transition: border-color 0.2s, color 0.2s; }
.upload-btn:hover { border-color: #999; color: #111; }
#upload-preview-wrap { margin-top: 12px; position: relative; display: inline-block; width: 100%; }
#upload-preview { width: 100%; display: block; aspect-ratio: 1; object-fit: cover; }
#upload-clear { position: absolute; top: 8px; right: 8px; background: rgba(0,0,0,0.5); color: #fff; border: none; font-size: 9px; letter-spacing: 2px; padding: 4px 8px; cursor: pointer; font-family: "archivo-semi-condensed", sans-serif; }
.field input:focus, .field textarea:focus { border-color: #999; }
.album-dropdown { width: 100%; border: none; border-bottom: 1px solid #ddd; padding: 8px 0; padding-right: 20px; font-size: 18px; color: #111; background: transparent; outline: none; font-family: "archivo-semi-condensed", sans-serif; font-weight: 400; cursor: pointer; -webkit-appearance: none; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='%23aaa' d='M0 0l5 6 5-6z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 4px center; transition: border-color 0.2s; }
.album-dropdown:focus { border-color: #999; }
.char-count { font-size: 9px; color: #bbb; text-align: right; margin-top: 4px; }
.char-count.warn { color: #c0392b; }
.btn-generate { width: 100%; padding: 14px; background: #111; color: #f5f4f0; border: none; font-family: "archivo-semi-condensed", sans-serif; font-size: 10px; letter-spacing: 4px; text-transform: uppercase; cursor: pointer; transition: background 0.2s; margin-top: 8px; }
.btn-generate:hover { background: #333; }
.btn-generate:disabled { background: #ccc; color: #999; cursor: not-allowed; }
#result-section { display: none; width: 100%; max-width: 480px; flex-direction: column; align-items: center; gap: 16px; }
#result-section.visible { display: flex; }
#result-header { position: relative; display: flex; align-items: center; width: 100%; max-width: 360px; min-height: 36px; transition: opacity 0.4s ease, transform 0.4s ease; }
#result-label { flex: 1; overflow: hidden; }
#canvas-overlay { display: none; position: absolute; inset: 0; background: rgba(255,255,255,0.85); z-index: 2; }
#render-state { display: none; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 3; text-align: center; width: 75%; background: #fff; padding: 14px 24px 24px 24px; border-radius: 6px; }
#result-label span { display: inline-block; position: relative; left: 50%; transform: translateX(-50%); font-size: 10px; letter-spacing: 4px; text-transform: uppercase; color: #aaa; white-space: nowrap; transition: left 0.6s cubic-bezier(0.4, 0, 0.2, 1), transform 0.6s cubic-bezier(0.4, 0, 0.2, 1); }
#result-header.playing #result-label span { left: 0; transform: translateX(0); }
#pause-btn { position: absolute; right: 0; top: 50%; transform: translateY(-50%) translateX(6px); display: none; background: none; border: none; cursor: pointer; padding: 0; line-height: 1; opacity: 0; transition: opacity 0.6s cubic-bezier(0.4, 0, 0.2, 1), transform 0.6s cubic-bezier(0.4, 0, 0.2, 1); pointer-events: none; }
#result-header.playing #pause-btn { opacity: 1; transform: translateY(-50%) translateX(0); pointer-events: auto; }
#pause-btn svg { width: 18px; height: 18px; fill: #aaa; display: block; }
#canvas-wrap { position: relative; width: 100%; max-width: 360px; background: url('https://kylie-server.b-cdn.net/story/story-bg.jpg') center / cover no-repeat; }
#output-canvas { width: 100%; display: block; border: 1px solid #e0ddd8; }
#video-pause-btn { display: none; position: absolute; top: 10px; right: 10px; width: 36px; height: 36px; background: rgba(0,0,0,0.45); backdrop-filter: blur(6px); border: 1.5px solid rgba(255,255,255,0.6); border-radius: 50%; cursor: pointer; align-items: center; justify-content: center; z-index: 10; opacity: 0; transition: opacity 0.3s ease; pointer-events: none; }
#video-pause-btn.visible { opacity: 1; pointer-events: auto; }
#video-pause-btn svg { width: 14px; height: 14px; fill: #fff; display: block; }
#mute-btn { display: none; position: absolute; top: 10px; right: 10px; width: 36px; height: 36px; background: rgba(0,0,0,0.45); backdrop-filter: blur(6px); border: 1.5px solid rgba(255,255,255,0.6); border-radius: 50%; cursor: pointer; align-items: center; justify-content: center; z-index: 4; }
#mute-btn svg { width: 16px; height: 16px; fill: #fff; display: block; }
.progress-wrap { width: 100%; max-width: 360px; }
.progress-bar { height: 2px; background: #e0ddd8; width: 100%; }
.progress-fill { height: 2px; background: #111; width: 0%; transition: width 0.15s; }
.status-msg { display: inline-block; font-size: 10px; letter-spacing: 4px; text-transform: uppercase; color: #aaa; white-space: nowrap; min-height: 20px; margin-bottom: 8px; }
.action-row { display: flex; gap: 12px; width: 100%; max-width: 360px; }
@media (max-width: 600px) {
  .action-row { position: fixed; bottom: 0; left: 0; right: 0; max-width: 100%; padding: 12px 16px 28px; background: #e6e4e5; border-top: 1px solid #e0ddd8; z-index: 100; }
}
.btn-action { flex: 1; padding: 14px; border: none; font-family: "archivo-semi-condensed", sans-serif; font-size: 10px; letter-spacing: 3px; text-transform: uppercase; cursor: pointer; transition: all 0.2s; -webkit-appearance: none; appearance: none; }
.btn-primary { background: #111; color: #f5f4f0; }
.btn-secondary { background: transparent; color: #111; border: 1px solid #ccc; }
.btn-primary:hover { background: #333; }
.btn-secondary:hover { background: #f0eeea; }
.reset-link { font-size: 9px; letter-spacing: 3px; text-transform: uppercase; color: #aaa; cursor: pointer; text-decoration: underline; }
.share-nudge { font-size: 11px; letter-spacing: 1px; color: #666; text-align: center; max-width: 360px; line-height: 1.6; width: 100%; }
.note { font-size: 9px; color: #bbb; text-align: center; max-width: 360px; line-height: 1.6; letter-spacing: 1px; }
#video-player { display: none; width: 100%; max-width: 360px; border: 1px solid #e0ddd8; background: transparent; }

/* ── Stories-style player ── */
#player-wrap {
  display: none;
  position: relative;
  width: 100%;
  max-width: 360px;
  border: 1px solid #e0ddd8;
  background: transparent;
  cursor: pointer;
  user-select: none;
}
#player-wrap video {
  display: block;
  width: 100%;
}
/* progress bar at top */
#story-progress {
  position: absolute;
  top: 10px;
  left: 10px;
  right: 10px;
  height: 2px;
  background: rgba(255,255,255,0.3);
  border-radius: 2px;
  z-index: 10;
}
#story-progress-fill {
  height: 100%;
  width: 0%;
  background: #fff;
  border-radius: 2px;
  transition: width 0.1s linear;
}
/* centre play/pause overlay */
#play-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  pointer-events: none;
  opacity: 1;
}
#play-overlay.hidden { opacity: 0; }
#play-icon {
  width: 72px;
  height: 72px;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(8px);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2.5px solid rgba(255,255,255,0.9);
  box-shadow: 0 4px 24px rgba(0,0,0,0.5);
}
#play-icon svg { width: 32px; height: 32px; fill: #fff; filter: drop-shadow(0 1px 3px rgba(0,0,0,0.4)); }
/* time stamp bottom left */
#story-time {
  position: absolute;
  bottom: 10px;
  left: 12px;
  font-size: 9px;
  letter-spacing: 2px;
  color: rgba(255,255,255,0.7);
  font-family: "archivo-semi-condensed", sans-serif;
  z-index: 10;
}
