:root {
  color-scheme: light;
  font-family: "Segoe UI", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", sans-serif;
  --ink: #191919;
  --muted: #6e6a67;
  --line: #dedbd7;
  --paper: #f7f5f1;
  --white: #fff;
  --accent: #ff3b30;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; min-width: 320px; background: var(--paper); color: var(--ink); }
button, input { font: inherit; }
button { cursor: pointer; }

.site-header { height: 72px; padding: 0 clamp(20px, 5vw, 72px); display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); background: rgba(247,245,241,.88); backdrop-filter: blur(14px); }
.brand { display: inline-flex; align-items: center; gap: 11px; color: var(--ink); font-weight: 800; text-decoration: none; letter-spacing: -.03em; }
.brand-mark { width: 30px; height: 22px; display: grid; place-items: center; border-radius: 7px; background: var(--accent); }
.brand-mark span { width: 0; height: 0; margin-left: 2px; border-top: 5px solid transparent; border-bottom: 5px solid transparent; border-left: 8px solid white; }
.header-actions { display: flex; align-items: center; gap: 18px; }
.header-note { color: var(--muted); font-size: 12px; letter-spacing: .08em; }
.header-tool-button { min-height: 38px; padding: 0 13px; display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--ink); border-radius: 7px; background: transparent; color: var(--ink); font-size: 11px; font-weight: 700; transition: background .18s, color .18s, transform .18s; }
.header-tool-button[hidden] { display: none; }
.header-tool-button svg { width: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.header-tool-button:hover { background: var(--ink); color: white; transform: translateY(-1px); }

main { overflow: hidden; }
.workspace { width: min(1120px, calc(100% - 40px)); min-height: calc(100svh - 72px); margin: 0 auto; padding: clamp(48px, 6vw, 76px) 0 70px; }
.intro { max-width: 760px; animation: enter .65s cubic-bezier(.2,.8,.2,1) both; }
.eyebrow { margin: 0 0 17px; color: var(--accent); font-size: 11px; font-weight: 800; letter-spacing: .2em; }
h1 { margin: 0; font-size: clamp(42px, 7vw, 84px); line-height: .99; letter-spacing: -.065em; }
h1 span { color: var(--accent); }
.lead { max-width: 620px; margin: 25px 0 0; color: var(--muted); font-size: clamp(15px, 2vw, 18px); line-height: 1.8; }

.url-form { margin-top: 0; animation: enter .65s .12s cubic-bezier(.2,.8,.2,1) both; }
.url-form label { display: block; margin-bottom: 10px; font-size: 13px; font-weight: 700; }
.input-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; }
.input-wrap { position: relative; }
.input-wrap > svg { position: absolute; left: 18px; top: 50%; width: 21px; transform: translateY(-50%); fill: none; stroke: #918b86; stroke-width: 1.8; stroke-linecap: round; }
input { width: 100%; height: 62px; padding: 0 50px; border: 1px solid var(--line); border-radius: 10px; outline: none; background: var(--white); color: var(--ink); transition: border-color .2s, box-shadow .2s; }
input:focus { border-color: var(--ink); box-shadow: 0 0 0 3px rgba(25,25,25,.08); }
.clear-button { position: absolute; right: 12px; top: 50%; width: 32px; height: 32px; transform: translateY(-50%); border: 0; border-radius: 50%; background: #efedea; color: #6b6763; font-size: 20px; }
.primary-button { height: 62px; padding: 0 24px; display: inline-flex; align-items: center; gap: 16px; border: 0; border-radius: 10px; background: var(--ink); color: white; font-weight: 700; transition: transform .18s, background .18s; }
.primary-button svg { width: 18px; fill: none; stroke: currentColor; stroke-width: 2; }
.primary-button:hover { background: var(--accent); transform: translateY(-2px); }
.primary-button:active { transform: translateY(0); }
.form-message { min-height: 21px; margin: 10px 0 0; color: var(--muted); font-size: 12px; }
.form-message.error { color: #c62d25; }

.empty-state { margin-top: 58px; text-align: center; animation: enter .65s .22s both; }
.empty-visual { position: relative; width: min(100%, 520px); aspect-ratio: 16/9; margin: 0 auto; overflow: hidden; border: 1px dashed #c9c4bf; border-radius: 14px; background: repeating-linear-gradient(-45deg,#f2efeb 0,#f2efeb 8px,#f7f5f1 8px,#f7f5f1 16px); }
.empty-play { position: absolute; inset: 50% auto auto 50%; width: 70px; height: 50px; transform: translate(-50%,-50%); border-radius: 15px; background: #dedad5; }
.empty-play::after { content: ""; position: absolute; left: 29px; top: 15px; border-top: 10px solid transparent; border-bottom: 10px solid transparent; border-left: 15px solid #f7f5f1; }
.scan-line { position: absolute; left: 0; right: 0; top: 0; height: 2px; background: var(--accent); opacity: .7; animation: scan 3s ease-in-out infinite; }
.empty-state p { margin: 16px 0 0; color: #9c9690; font-size: 12px; }

.results { margin-top: 64px; }
.results.reveal { animation: enter .5s cubic-bezier(.2,.8,.2,1) both; }
.results-heading { display: flex; align-items: end; justify-content: space-between; margin-bottom: 24px; }
.results-heading .eyebrow { margin-bottom: 8px; }
h2 { margin: 0; font-size: clamp(28px, 4vw, 44px); letter-spacing: -.045em; }
.result-toolbar { display: flex; align-items: center; gap: 16px; }
.x-post-button { background: var(--ink); border-color: var(--ink); color: white; }
.text-button { padding: 8px 0; border: 0; border-bottom: 1px solid var(--ink); background: none; font-size: 12px; }
.result-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 42px 24px; }
.result-item { min-width: 0; }
.thumbnail-frame { position: relative; overflow: hidden; aspect-ratio: 16/9; border-radius: 12px; background: #e6e2dd; }
.thumbnail-frame img { width: 100%; height: 100%; display: block; object-fit: cover; transition: transform .5s cubic-bezier(.2,.8,.2,1); }
.result-item:hover img { transform: scale(1.025); }
.quality-tag { position: absolute; right: 10px; bottom: 10px; padding: 5px 8px; border-radius: 5px; background: rgba(15,15,15,.78); color: white; font-size: 10px; font-weight: 800; backdrop-filter: blur(8px); }
.result-meta { margin-top: 13px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.result-meta strong { display: block; font-size: 14px; }
.result-meta small { display: block; margin-top: 3px; color: var(--muted); }
.result-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 7px; }
.action-button { min-height: 38px; padding: 0 12px; border: 1px solid var(--line); border-radius: 7px; background: var(--white); color: var(--ink); font-size: 11px; font-weight: 700; transition: border-color .18s, color .18s, transform .18s; }
.action-button:hover { border-color: var(--accent); color: var(--accent); transform: translateY(-1px); }
.action-button.download { background: var(--ink); border-color: var(--ink); color: white; }

.how-to { width: min(1120px, calc(100% - 40px)); margin: 0 auto; padding: 90px 0; border-top: 1px solid var(--line); display: grid; grid-template-columns: .8fr 1.8fr; gap: 60px; }
.how-to-top { padding: clamp(42px, 6vw, 68px) 0; border-top: 0; border-bottom: 1px solid var(--line); grid-template-columns: minmax(300px, .9fr) 1.8fr; }
.how-to-title { display: flex; align-items: center; gap: 14px; font-size: clamp(28px, 3vw, 36px); white-space: nowrap; }
.how-to-title img { width: 52px; height: 52px; border-radius: 12px; flex: 0 0 auto; }
.how-to ol { margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); list-style: none; }
.how-to li { padding: 8px 24px 0; border-left: 1px solid var(--line); }
.how-to li > span { display: block; margin-bottom: 36px; color: var(--accent); font: 800 11px/1 "Segoe UI",sans-serif; letter-spacing: .15em; }
.how-to strong { font-size: 15px; }
.how-to strong.how-to-long-label { display: block; font-size: 12px; white-space: nowrap; }
.how-to li p { margin: 8px 0 0; color: var(--muted); font-size: 12px; line-height: 1.7; }
.notice { width: min(1120px, calc(100% - 40px)); margin: 0 auto 60px; padding: 20px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); display: flex; gap: 40px; color: var(--muted); font-size: 11px; line-height: 1.7; }
.notice strong { flex: 0 0 auto; color: var(--ink); }
.notice p { margin: 0; }
.version-note { margin: 18px 0 0; color: #b6afa8; font-size: 10px; letter-spacing: .04em; text-align: center; }
.page-footer { width: min(1120px, calc(100% - 40px)); margin: 8px auto 0; padding: 14px 0 28px; border-top: 1px solid rgba(148,163,184,.35); color: #aaa39c; font-size: 11px; line-height: 1.7; text-align: center; }
.page-footer p { margin: 0; }
.page-footer a { color: #807970; text-decoration: none; }
.page-footer a:hover { text-decoration: underline; }
.install-dialog[hidden] { display: none; }
.install-dialog { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 20px; }
.install-dialog-backdrop { position: absolute; inset: 0; width: 100%; border: 0; background: rgba(25,25,25,.48); backdrop-filter: blur(4px); }
.install-dialog-panel { position: relative; width: min(100%, 430px); padding: 34px; border-radius: 14px; background: var(--paper); box-shadow: 0 24px 70px rgba(25,25,25,.22); animation: enter .25s cubic-bezier(.2,.8,.2,1) both; }
.install-dialog-panel .eyebrow { margin-bottom: 10px; }
.install-dialog-panel h2 { font-size: clamp(26px, 5vw, 34px); }
.install-dialog-panel > p:not(.eyebrow) { margin: 18px 0 24px; color: var(--muted); font-size: 14px; line-height: 1.8; }
.install-dialog-close { position: absolute; top: 12px; right: 12px; width: 36px; height: 36px; border: 0; border-radius: 50%; background: transparent; color: var(--muted); font-size: 24px; }
.install-dialog-close:hover { background: #ebe7e2; color: var(--ink); }
.install-dialog-ok { width: 100%; justify-content: center; }
.toast { position: fixed; left: 50%; bottom: 28px; z-index: 10; padding: 11px 17px; border-radius: 8px; background: #191919; color: white; font-size: 12px; opacity: 0; pointer-events: none; transform: translate(-50%, 14px); transition: .25s; }
.toast.show { opacity: 1; transform: translate(-50%,0); }

@keyframes enter { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }
@keyframes scan { 0%,100% { top: 5%; opacity: 0; } 15%,85% { opacity: .7; } 50% { top: 95%; } }
@media (max-width: 1180px) {
  .how-to-top { grid-template-columns: 1fr; gap: 38px; }
}
@media (max-width: 760px) {
  .how-to-top { grid-template-columns: 1fr; }
  .how-to-title img { width: 44px; height: 44px; border-radius: 10px; }
  .site-header { height: 62px; }
  .brand > span:last-child { display: none; }
  .header-note { display: none; }
  .header-actions { gap: 8px; }
  .header-tool-button { min-height: 36px; padding: 0 10px; }
  .header-tool-button span { display: none; }
  .header-tool-button svg { width: 18px; }
  .install-dialog { align-items: end; padding: 0; }
  .install-dialog-panel { width: 100%; padding: 30px 24px calc(24px + env(safe-area-inset-bottom)); border-radius: 16px 16px 0 0; }
  .workspace { min-height: auto; padding-top: 40px; }
  h1 { font-size: clamp(40px, 13vw, 62px); }
  .lead { font-size: 14px; }
  .input-row { grid-template-columns: 1fr; }
  .primary-button { justify-content: center; }
  .result-grid { grid-template-columns: 1fr; }
  .result-meta { align-items: flex-start; flex-direction: column; }
  .result-actions { width: 100%; display: grid; grid-template-columns: repeat(2, 1fr); }
  .action-button { width: 100%; }
  .results-heading { align-items: start; gap: 20px; }
  .result-toolbar { flex-direction: column; align-items: flex-end; gap: 8px; }
  .how-to { grid-template-columns: 1fr; gap: 38px; padding: 65px 0; }
  .how-to ol { grid-template-columns: 1fr; }
  .how-to li { padding: 18px 0 18px 50px; position: relative; border-left: 0; border-top: 1px solid var(--line); }
  .how-to li > span { position: absolute; left: 0; top: 23px; margin: 0; }
  .notice { display: block; }
  .notice p { margin-top: 7px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; } }
