:root {
  color-scheme: dark;
  --bg: #090912;
  --panel: #151526;
  --line: #302c47;
  --text: #f4f0ff;
  --dim: #aaa6c1;
  --lilac: #c7b5ff;
  --aqua: #76e0e6;
  --top: env(safe-area-inset-top, 0px);
  --bottom: env(safe-area-inset-bottom, 0px);
  --left: env(safe-area-inset-left, 0px);
  --right: env(safe-area-inset-right, 0px);
  font-family: "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", system-ui, sans-serif;
}
*, *::before, *::after { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--text); }
body { overscroll-behavior: none; -webkit-touch-callout: none; }
input, textarea { -webkit-touch-callout: default; }
button, input, textarea { font: inherit; }
button { color: inherit; cursor: pointer; touch-action: manipulation; }
button:disabled { cursor: default; opacity: .55; }
button:focus-visible, input:focus-visible, textarea:focus-visible, summary:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--aqua);
  outline-offset: -2px;
}
video, img { display: block; max-width: 100%; -webkit-user-drag: none; }
h1, h2, h3, p { margin: 0; overflow-wrap: anywhere; }

.shell, .sheet { width: min(100%, 480px); }
.shell { height: 100vh; height: 100dvh; margin-inline: auto; background: var(--bg); }
.gate {
  height: 100%; display: grid; align-content: center; justify-items: center; gap: 16px;
  padding: 24px; text-align: center; background: radial-gradient(ellipse at 50% 42%, #221837, var(--bg) 68%);
}
.gate > p { font-weight: 750; }
.nick-card {
  width: min(100%, 335px); display: grid; gap: 12px; padding: 24px; text-align: left;
  background: var(--panel); border: 1px solid var(--line); border-radius: 22px;
}
.nick-card h1 { margin-bottom: 8px; font-size: 23px; }

.app { height: 100%; display: grid; grid-template-rows: minmax(0, 1fr) auto; }
.screen { min-width: 0; min-height: 0; }
.nav {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
  padding: 0 var(--right) var(--bottom) var(--left); border-top: 1px solid var(--line);
  background: #10101c;
}
.nav button {
  position: relative; min-height: 56px; padding: 0 4px; border: 0; background: none;
  color: var(--dim); font-size: 13px; font-weight: 700;
}
.nav [aria-current="page"] { color: var(--lilac); }
.nav [aria-current="page"]::before {
  content: ""; position: absolute; inset: 0 33% auto; height: 2px; border-radius: 2px; background: var(--lilac);
}

.feed { position: relative; isolation: isolate; background: radial-gradient(ellipse at 50% 46%, #19142a, #07070e 72%); }
.feed-header {
  position: absolute; z-index: 2; inset: 0 0 auto; display: flex; gap: 8px;
  justify-content: space-between; align-items: center; pointer-events: none;
  padding: calc(var(--top) + 8px) max(12px, var(--right)) 15px max(15px, var(--left));
  background: linear-gradient(#080812bf, transparent);
}
.feed-header h1 { color: white; font-size: 19px; letter-spacing: -.045em; text-shadow: 0 1px 8px #000; }
.feed-tools { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 5px; }
.feed-tools button { pointer-events: auto; }
.feed-scroll {
  height: 100%; overflow-y: auto; overscroll-behavior-y: contain; scroll-snap-type: y mandatory;
  scrollbar-width: none; touch-action: pan-y;
}
.feed-scroll::-webkit-scrollbar { display: none; }
.clip {
  position: relative; isolation: isolate; height: 100%; scroll-snap-align: start; scroll-snap-stop: always;
  overflow: hidden; background: #050508;
}
.clip video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.film-tap {
  position: absolute; inset: 0; width: 100%; border: 0; background: transparent;
  touch-action: pan-y;
}
.film-tap[data-paused]::after {
  content: "▶"; display: grid; place-items: center; width: 56px; height: 56px; padding-left: 3px;
  position: absolute; inset: 0; margin: auto; border: 1px solid #ffffff33; border-radius: 50%; background: #0d0c19bd;
}
.clip-foot {
  position: absolute; inset: auto 0 0; display: flex; align-items: flex-end; justify-content: space-between;
  gap: 12px; padding: 52px max(12px, var(--right)) 20px max(15px, var(--left));
  pointer-events: none; background: linear-gradient(transparent, #05050cd9);
}
.clip-meta { min-width: 0; color: white; text-shadow: 0 2px 8px #000; }
.clip-meta p { color: #e0d4ff; font-size: 13px; font-weight: 750; }
.clip-meta h2 { margin-top: 4px; font-size: clamp(16px, 5vw, 22px); }
.clip-foot button { pointer-events: auto; flex: none; }
.clip-actions { display: flex; gap: 5px; }
.heart[aria-pressed="true"] { color: #ff9ebb; border-color: #ff9ebb; }
.clip-progress { position: absolute; inset: auto 0 0; height: 3px; border-radius: 0; pointer-events: none; }
.clip-error, .feed-message {
  position: absolute; inset: 50% 12px auto; transform: translateY(-50%); text-align: center;
  color: var(--dim); pointer-events: none;
}
.feed-message:empty { display: none; }
.pill {
  min-height: 42px; padding: 0 11px; border: 1px solid #d8caff38; border-radius: 999px;
  background: #171328e8; color: var(--text); font-size: 12px; font-weight: 750; white-space: nowrap;
}
.sound-hint { position: absolute; z-index: 3; top: calc(var(--top) + 65px); left: 50%; transform: translateX(-50%); }

.page {
  overflow: auto; overscroll-behavior-y: contain;
  padding: calc(var(--top) + 22px) max(16px, var(--right)) 24px max(16px, var(--left));
  background: radial-gradient(ellipse at 25% 0%, #1b1530, var(--bg) 42%);
}
.page-header { margin-bottom: 20px; }
.page-header h1 { font-size: 27px; letter-spacing: -.05em; }
.panel { padding: 16px; border: 1px solid var(--line); border-radius: 17px; background: var(--panel); }
.stack { display: grid; gap: 13px; }
label { font-size: 13px; font-weight: 750; }
input:not([type="file"]), textarea {
  width: 100%; min-height: 44px; padding: 9px 11px; border: 1px solid var(--line);
  border-radius: 10px; background: #0d0c19; color: var(--text); font-size: 16px;
}
textarea { resize: vertical; }
.file-label { display: grid; gap: 9px; }
input[type="file"] { width: 100%; color: var(--dim); font-size: 13px; }
input[type="file"]::file-selector-button {
  min-height: 44px; padding: 0 12px; margin-right: 8px; border-radius: 10px; border: 1px solid var(--line);
  background: #211c35; color: var(--text); font: inherit; font-weight: 750; cursor: pointer;
}
.button { min-height: 44px; padding: 8px 13px; border: 1px solid transparent; border-radius: 10px; font-weight: 750; }
.primary { background: var(--lilac); color: #1b122e; }
.secondary { border-color: var(--line); background: #211c35; }
.danger { border-color: #694153; background: #2a1727; color: #ffc4d4; }
.status { color: var(--dim); font-size: 13px; line-height: 1.5; }
.status:empty { display: none; }
#mine-status:not(:empty) { margin-bottom: 12px; }
.preview {
  width: 100%; max-height: min(42vh, 340px); aspect-ratio: 9 / 16; object-fit: contain;
  border-radius: 12px; background: #08080f;
}
.preview-info { display: flex; gap: 10px; align-items: center; color: var(--dim); font-size: 13px; }
.preview-info img { max-height: 80px; object-fit: contain; border-radius: 6px; }
progress { width: 100%; height: 5px; appearance: none; border: 0; background: #d7ccff40; accent-color: var(--lilac); }
progress::-webkit-progress-bar { background: #d7ccff40; }
progress::-webkit-progress-value { background: var(--lilac); }
progress::-moz-progress-bar { background: var(--lilac); }

.power-panel { display: grid; gap: 10px; margin-bottom: 14px; }
.power-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.power-header h2 { font-size: 17px; }
.power-header h2 span { margin-left: 4px; color: var(--lilac); }
.power-header p { color: var(--dim); text-align: right; font-size: 12px; line-height: 1.45; }
#power-meter { height: 8px; overflow: hidden; border-radius: 999px; }
.power-toast {
  position: fixed; z-index: 5; inset: auto auto calc(var(--bottom) + 72px) 50%;
  transform: translateX(-50%); width: max-content; max-width: calc(100% - 32px);
  pointer-events: none; text-align: center; white-space: pre-line;
}
.power-toast:not(:empty) {
  padding: 9px 13px; border: 1px solid var(--line); border-radius: 12px;
  background: #211738; color: var(--text); font-size: 13px; font-weight: 750;
}

.mine-header { display: flex; gap: 13px; align-items: center; }
.mine-header img { width: 52px; aspect-ratio: 9 / 16; object-fit: cover; border-radius: 7px; background: #090912; }
.mine-header h2 { font-size: 17px; }
.mine-header p { color: var(--dim); font-size: 12px; margin-top: 5px; }
.metrics { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; margin: 0; }
.metrics div { padding: 9px 7px; border-bottom: 1px solid var(--line); }
.metrics dt { color: var(--dim); font-size: 12px; }
.metrics dd { margin: 4px 0 0; font-size: 16px; font-weight: 750; }
.histogram { display: grid; gap: 6px; }
.histogram h3 { font-size: 13px; }
.bars { position: relative; height: 50px; border-bottom: 1px solid var(--line); }
.bars span { position: absolute; bottom: 0; background: var(--aqua); border-radius: 2px 2px 0 0; }
.hist-labels { display: flex; justify-content: space-between; color: var(--dim); font-size: 12px; }
.histogram details { color: var(--dim); font-size: 12px; }
.histogram details p { margin-top: 6px; }
.card-actions { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; }
.quota { display: flex; justify-content: space-between; align-items: center; }
.quota strong { color: var(--lilac); font-size: 25px; }
.subheading { margin: 22px 0 11px; font-size: 16px; }
.invite-list, .comment-list { list-style: none; margin: 0; padding: 0; }
.invite-list { display: grid; gap: 7px; }
.invite-list li {
  min-width: 0; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 5px 10px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
}
.invite-list time { display: block; margin-top: 3px; color: var(--dim); font-size: 12px; }

.sheet {
  position: fixed; inset: auto 0 0; max-width: none; max-height: min(86vh, 740px); max-height: min(86dvh, 740px);
  margin: 0 auto; padding: 0; overflow: auto; color: var(--text); background: #151526;
  border: 1px solid var(--line); border-bottom: 0; border-radius: 21px 21px 0 0;
  overscroll-behavior: contain;
}
.sheet[open] { animation: rise .2s ease-out; }
.sheet::backdrop { background: #05040bb3; }
@keyframes rise { from { transform: translateY(100%); } to { transform: translateY(0); } }
@media (prefers-reduced-motion: reduce) { .sheet[open] { animation: none; } }
.sheet-inner { display: grid; gap: 12px; padding: 12px 16px calc(16px + var(--bottom)); }
.sheet-header { display: flex; justify-content: space-between; align-items: center; }
.sheet-header h2 { font-size: 18px; }
.sheet-player { width: 100%; max-height: 24vh; background: #08080f; border-radius: 10px; }
.comment-list { max-height: 33vh; overflow: auto; overscroll-behavior: contain; }
.comment-list li { display: grid; gap: 3px; padding: 7px 0; border-bottom: 1px solid var(--line); }
.comment-line { display: flex; align-items: center; gap: 10px; min-width: 0; }
.comment-line strong { overflow-wrap: anywhere; font-size: 13px; }
.comment-line button {
  min-height: 44px; padding: 0 8px; border: 0; background: transparent;
  color: var(--aqua); font-size: 13px; font-variant-numeric: tabular-nums;
}
.comment-list p { color: var(--text); white-space: pre-wrap; font-size: 14px; line-height: 1.45; }
.comment-head { display: flex; justify-content: space-between; align-items: center; gap: 7px; }
.comment-head strong { color: var(--dim); font-size: 13px; overflow-wrap: anywhere; }
.comment-form { display: grid; gap: 8px; }
.comment-form output { color: var(--aqua); font-variant-numeric: tabular-nums; }
.comment-actions { display: flex; justify-content: flex-end; gap: 8px; }
#comment-kind[aria-pressed="true"], .helpful[aria-pressed="true"] { border-color: var(--lilac); color: var(--lilac); }
.helpful { justify-self: start; }
.helpful:disabled[aria-pressed="true"] { opacity: 1; }

@media (min-width: 520px) {
  body { background: #05050b; }
  .shell { box-shadow: 0 0 0 1px #211b34, 0 0 80px #0009; }
}

.clip-who { display: flex; align-items: center; gap: 8px; }
.ava { flex: none; width: 34px; height: 34px; border-radius: 50%; overflow: hidden; display: inline-grid; place-items: center;
  background: #2a2340; color: #e0d4ff; font-weight: 800; font-size: 15px; box-shadow: 0 0 0 2px #ffffff33; }
.ava img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ava.small { width: 22px; height: 22px; font-size: 11px; margin-right: 6px; vertical-align: middle; }
