/* ── Tokens ─────────────────────────────────────────── */
:root {
  color-scheme: dark;
  --bg: #0a0f1d;
  --bg-raise: #0f1629;
  --surface: rgba(255, 255, 255, .028);
  --surface-2: rgba(255, 255, 255, .055);
  --field: rgba(5, 9, 19, .55);
  --line: rgba(196, 210, 236, .12);
  --line-strong: rgba(196, 210, 236, .24);
  --text: #e7ecf5;
  --muted: #97a3bb;
  --faint: #67738d;
  --silver: #d8dfeb;
  --accent: #a8c3ec;
  --accent-soft: rgba(168, 195, 236, .12);
  --danger: #efa7a7;
  --sans: "Pretendard", "Pretendard Variable", "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", system-ui, -apple-system, "Segoe UI", sans-serif;
  --serif: "Noto Serif KR", "Nanum Myeongjo", "AppleMyungjo", "Batang", serif;
}
body.accent-blue     { --accent: #a8c3ec; --accent-soft: rgba(168, 195, 236, .12); }
body.accent-rose     { --accent: #e4b9c7; --accent-soft: rgba(228, 185, 199, .12); }
body.accent-lavender { --accent: #c3baf0; --accent-soft: rgba(195, 186, 240, .12); }
body.accent-mint     { --accent: #a5d8cb; --accent-soft: rgba(165, 216, 203, .12); }
.language-picker { position:fixed; right:18px; bottom:16px; z-index:40; display:flex; align-items:center; gap:9px; padding:6px 10px; border:1px solid var(--line); border-radius:10px; background:rgba(10,15,29,.94); color:var(--muted); font-size:11px; }
.language-picker select { width:104px; min-height:30px; margin:0; padding:3px 6px; border:0; background:transparent; font-size:12px; color:var(--text); }
html[lang="ja"] body { word-break:normal; font-family:"Noto Sans JP","Yu Gothic",Meiryo,var(--sans); }
html[lang="en"] body { word-break:normal; }

/* ── Base ───────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.6;
  letter-spacing: -.005em;
  word-break: keep-all;
  -webkit-font-smoothing: antialiased;
}
/* static night sky: soft glow + a few still stars */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(1.3px 1.3px at 7% 12%, rgba(228, 235, 248, .75), transparent),
    radial-gradient(1px 1px at 18% 34%, rgba(228, 235, 248, .45), transparent),
    radial-gradient(1.2px 1.2px at 29% 8%, rgba(228, 235, 248, .55), transparent),
    radial-gradient(1px 1px at 41% 22%, rgba(228, 235, 248, .35), transparent),
    radial-gradient(1.4px 1.4px at 57% 6%, rgba(228, 235, 248, .6), transparent),
    radial-gradient(1px 1px at 66% 28%, rgba(228, 235, 248, .4), transparent),
    radial-gradient(1.2px 1.2px at 78% 16%, rgba(228, 235, 248, .5), transparent),
    radial-gradient(1px 1px at 92% 38%, rgba(228, 235, 248, .45), transparent),
    radial-gradient(1.2px 1.2px at 12% 72%, rgba(228, 235, 248, .4), transparent),
    radial-gradient(1px 1px at 34% 88%, rgba(228, 235, 248, .3), transparent),
    radial-gradient(1.3px 1.3px at 71% 82%, rgba(228, 235, 248, .45), transparent),
    radial-gradient(1px 1px at 88% 64%, rgba(228, 235, 248, .35), transparent),
    radial-gradient(900px 520px at 88% -10%, rgba(112, 142, 206, .16), transparent 70%),
    radial-gradient(760px 520px at -12% 112%, rgba(78, 98, 158, .10), transparent 70%);
}
h1, h2, h3 { margin: 0; font-weight: 500; line-height: 1.3; letter-spacing: -.02em; }
p { margin: 0; }
a { color: inherit; }
button { font: inherit; color: inherit; }
img { max-width: 100%; }

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

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.ico { width: 1em; height: 1em; flex: none; fill: currentColor; }
.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0; border: 0;
  overflow: hidden; white-space: nowrap;
  clip: rect(0 0 0 0); clip-path: inset(50%);
}
.muted { color: var(--muted); }
.small { font-size: 12.5px; line-height: 1.55; }

/* ── Controls ───────────────────────────────────────── */
form { display: grid; gap: 16px; }
form label:not(.file-button) {
  display: grid;
  gap: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
}
input:not([type="file"]):not([type="checkbox"]):not([type="radio"]),
textarea,
select {
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background-color: var(--field);
  color: var(--text);
  font: inherit;
  font-size: 15px;
  font-weight: 400;
  transition: border-color .15s, box-shadow .15s;
}
textarea { padding: 12px 14px; resize: vertical; line-height: 1.6; min-height: 96px; }
input::placeholder, textarea::placeholder { color: var(--faint); }
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
input[type="search"] { -webkit-appearance: none; appearance: none; }
select {
  -webkit-appearance: none;
  appearance: none;
  padding-right: 42px;
  cursor: pointer;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 21px) 50%, calc(100% - 16px) 50%;
  background-size: 5px 5px;
  background-repeat: no-repeat;
}
option { background: var(--bg-raise); color: var(--text); }

.primary,
.upload-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 22px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: linear-gradient(180deg, #eef2f9, #c9d2e2);
  color: #0b1222;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: filter .15s;
}
.primary:hover, .upload-button:hover { filter: brightness(1.06); }
.primary:disabled { opacity: .55; cursor: progress; }

.quiet,
.file-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: background-color .15s, border-color .15s;
}
.quiet:hover, .file-button:hover { background: var(--surface-2); border-color: rgba(196, 210, 236, .34); }
.file-button { min-height: 48px; font-size: 14px; }
.upload-button:has(input:focus-visible),
.file-button:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }

.text-button {
  padding: 6px 2px;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
}
.text-button:hover { color: var(--text); }
.subtle-link { color: var(--faint); font-size: 13px; text-decoration: none; }
.subtle-link:hover { color: var(--muted); }

.eyebrow {
  margin: 0 0 10px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--accent);
}
.error { margin-top: 14px; color: var(--danger); font-size: 13px; }
.error:empty { display: none; }

/* ── Login ──────────────────────────────────────────── */
.entry {
  position: relative;
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 56px 16px;
  overflow: hidden;
}
.entry-background { position:absolute; inset:0; width:100%; height:100%; object-fit:cover; object-position:center; pointer-events:none; }
.entry-shade { position:absolute; inset:0; background:linear-gradient(90deg,rgba(6,11,22,.05),rgba(6,11,22,.22)); pointer-events:none; }
.background-editor { margin:28px 0; }
.background-editor h3 { margin-bottom:14px; }
#background-preview { display:block; width:min(100%,560px); aspect-ratio:16/9; object-fit:cover; border:1px solid var(--line); border-radius:12px; margin-bottom:12px; }
.entry-sky { position: absolute; inset: 0; pointer-events: none; }
.sky-moon {
  position: absolute;
  top: 9%; right: 10%;
  width: clamp(120px, 15vw, 210px);
  height: clamp(120px, 15vw, 210px);
  fill: #dfe6f2;
  opacity: .92;
  filter: drop-shadow(0 0 42px color-mix(in srgb, var(--accent) 32%, transparent));
}
.sky-star { position: absolute; fill: var(--silver); opacity: .55; }
.s1 { top: 22%; left: 14%; width: 14px; height: 14px; }
.s2 { top: 68%; left: 9%;  width: 9px;  height: 9px; opacity: .4; }
.s3 { top: 15%; left: 47%; width: 8px;  height: 8px; opacity: .35; }
.s4 { bottom: 15%; right: 17%; width: 12px; height: 12px; }
.sky-snow { position: absolute; bottom: 13%; left: 18%; width: 30px; height: 30px; color: var(--silver); opacity: .3; }

.login-card {
  position: relative;
  z-index: 1;
  width: min(100%, 400px);
  padding: 44px 36px 28px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(14, 20, 38, .72);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  box-shadow: 0 30px 80px -30px rgba(0, 0, 0, .6);
  text-align: center;
}
body > .login-card { margin: 12vh auto; }   /* standalone use, e.g. owner setup */
.login-card form { margin-top: 28px; text-align: left; }
.login-card form .primary { width: 100%; margin-top: 6px; }
.login-card h1, .login-card h2 {
  font-family: var(--serif);
  font-size: 27px;
  font-weight: 400;
  letter-spacing: -.01em;
}
.login-card h1 + p, .login-card h2 + p,
.login-card .muted { margin-top: 8px; font-size: 14px; color: var(--muted); }
.login-card img, .login-card canvas {
  display: block;
  margin: 20px auto 0;
  padding: 12px;
  border-radius: 12px;
  background: #fff;
}
.login-card code, .login-card pre {
  display: block;
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--field);
  font-size: 13px;
  letter-spacing: .06em;
  word-break: break-all;
  white-space: pre-wrap;
}
.brand-icon {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  margin: 0 auto 22px;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: radial-gradient(circle at 32% 28%, rgba(255, 255, 255, .09), transparent 70%);
  color: var(--silver);
  font-family: var(--serif);
  font-size: 18px;
  line-height: 1;
}
.brand-icon svg { width: 22px; height: 22px; fill: currentColor; }
.login-links {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

/* ── Top bar ────────────────────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 64px;
  padding: 10px max(20px, calc((100% - 1120px) / 2));
  border-bottom: 1px solid var(--line);
  background: rgba(10, 15, 29, .74);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
}
.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  text-decoration: none;
}
.wordmark .ico { width: 17px; height: 17px; fill: var(--silver); }
.wordmark span { font-size: 12.5px; font-weight: 500; letter-spacing: .3em; text-transform: uppercase; }
.account { display: flex; align-items: center; gap: 8px; min-width: 0; }
#identity {
  margin-right: 4px;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 180px;
}

/* ── Space ──────────────────────────────────────────── */
.space {
  max-width: 1160px;
  margin: 0 auto;
  padding: 28px 20px 56px;
  display: grid;
  gap: 28px;
}

/* hero */
.hero {
  position: relative;
  display: flex;
  align-items: flex-end;
  min-height: 248px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 22px;
  background:
    radial-gradient(520px 260px at 84% 40%, color-mix(in srgb, var(--accent) 10%, transparent), transparent 70%),
    linear-gradient(160deg, rgba(30, 42, 74, .55), rgba(11, 17, 33, .45));
}
.hero.has-cover { min-height: clamp(260px, 36vw, 420px); }
#hero-cover { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.hero-shade { position: absolute; inset: 0; display: none; }
.hero.has-cover .hero-shade {
  display: block;
  background: linear-gradient(180deg, rgba(8, 12, 24, 0) 30%, rgba(8, 12, 24, .5) 62%, rgba(8, 12, 24, .88) 100%);
}
.hero-sky { position: absolute; inset: 0; pointer-events: none; }
.hero.has-cover .hero-sky { display: none; }
.h-moon {
  position: absolute;
  top: 50%; right: 8%;
  width: clamp(84px, 11vw, 132px);
  height: clamp(84px, 11vw, 132px);
  transform: translateY(-50%);
  fill: #e2e8f3;
  filter: drop-shadow(0 0 34px color-mix(in srgb, var(--accent) 34%, transparent));
}
.h-star { position: absolute; fill: var(--silver); opacity: .5; }
.hs1 { top: 24%; right: 23%; width: 11px; height: 11px; }
.hs2 { bottom: 22%; right: 17%; width: 7px; height: 7px; opacity: .4; }
.hs3 { top: 40%; right: 31%; width: 6px; height: 6px; opacity: .32; }
.h-snow { position: absolute; bottom: 18%; right: 27%; width: 16px; height: 16px; color: var(--silver); opacity: .3; }
.hero-copy {
  position: relative;
  z-index: 1;
  padding: 40px clamp(40px, 26%, 300px) 38px 44px;
}
.hero.has-cover .hero-copy { padding-right: 44px; }
#site-title {
  font-family: var(--serif);
  font-size: clamp(28px, 4vw, 42px);
  font-weight: 400;
  letter-spacing: -.015em;
  line-height: 1.25;
}
#site-subtitle { margin-top: 10px; color: var(--muted); font-size: 15px; max-width: 46em; }
#site-subtitle:empty { display: none; }
.hero.has-cover #site-title,
.hero.has-cover #site-subtitle { text-shadow: 0 1px 14px rgba(0, 0, 0, .45); }
.hero.has-cover #site-subtitle { color: rgba(231, 236, 245, .82); }

/* notice */
.notice {
  position: relative;
  padding: 16px 20px 16px 46px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
  font-size: 14.5px;
  white-space: pre-line;
}
.notice::before {
  content: "";
  position: absolute;
  top: 21px; left: 20px;
  width: 12px; height: 12px;
  background: var(--accent);
  clip-path: polygon(50% 0, 60% 40%, 100% 50%, 60% 60%, 50% 100%, 40% 60%, 0 50%, 40% 40%);
}
.notice:empty { display: none; }

/* editor */
.editor {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr);
  gap: 24px 40px;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--surface);
}
.editor-head { grid-column: 1 / -1; }
.editor-head h2 { font-size: 18px; }
.form-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 4px; }
#pin-form { align-content: start; padding-left: 40px; border-left: 1px solid var(--line); }
#pin-form h3 { font-size: 15px; }
#pin-form .quiet { justify-self: start; }

/* library */
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.section-heading h2 { font-size: 20px; }
.upload-button { min-height: 44px; padding: 0 18px; font-size: 14px; }
.upload-button .ico { width: 17px; height: 17px; }

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 18px 0 16px;
}
#breadcrumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; min-width: 0; }
#breadcrumbs button {
  padding: 6px 8px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--muted);
  font-size: 14px;
  cursor: pointer;
}
#breadcrumbs button:hover { color: var(--text); background: var(--surface-2); }
#breadcrumbs button:last-of-type { color: var(--text); font-weight: 500; }
#breadcrumbs span { color: var(--faint); font-size: 13px; }

.search { position: relative; flex: 0 1 280px; }
.search .ico {
  position: absolute;
  top: 50%; left: 14px;
  width: 16px; height: 16px;
  transform: translateY(-50%);
  color: var(--faint);
  pointer-events: none;
}
.search input { min-height: 42px; padding-left: 40px; font-size: 14px; }

#drop-area { border-radius: 16px; transition: background-color .15s; }
#drop-area.dragging { outline: 1px dashed var(--accent); outline-offset: 8px; background: var(--accent-soft); }

.upload-status {
  margin-bottom: 16px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}
#upload-message {
  margin-bottom: 10px;
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
progress {
  display: block;
  width: 100%;
  height: 4px;
  border: 0;
  border-radius: 4px;
  overflow: hidden;
  -webkit-appearance: none;
  appearance: none;
  background: var(--line);
}
progress::-webkit-progress-bar { background: var(--line); }
progress::-webkit-progress-value { background: var(--accent); transition: width .2s; }
progress::-moz-progress-bar { background: var(--accent); }

/* file cards */
.file-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(184px, 1fr));
  gap: 16px;
}
.file-card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  transition: border-color .15s, background-color .15s;
}
.file-card:hover { border-color: var(--line-strong); background: rgba(255, 255, 255, .04); }
.file-visual {
  -webkit-appearance: none;
  appearance: none;
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 4 / 3;
  margin: 0;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-bottom: 1px solid var(--line);
  background:
    radial-gradient(120% 90% at 50% 0%, rgba(168, 195, 236, .07), transparent 70%),
    rgba(255, 255, 255, .015);
  color: var(--silver);
  cursor: pointer;
}
.file-visual:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.file-visual img { display: block; width: 100%; height: 100%; object-fit: cover; }
.file-symbol {
  display: grid;
  place-items: center;
  min-width: 48px;
  height: 60px;
  padding: 0 7px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: rgba(255, 255, 255, .02);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .1em;
  color: var(--silver);
}
/* folder: line-drawn shape replaces the JS glyph */
.folder .file-visual {
  background:
    radial-gradient(120% 90% at 50% 0%, color-mix(in srgb, var(--accent) 12%, transparent), transparent 70%),
    rgba(255, 255, 255, .015);
}
.folder .file-symbol {
  position: relative;
  width: 60px;
  min-width: 0;
  height: 44px;
  margin-top: 10px;
  padding: 0;
  border: 1.2px solid var(--silver);
  border-radius: 3px 8px 8px 8px;
  background: var(--accent-soft);
  font-size: 0;
  color: transparent;
}
.folder .file-symbol::before {
  content: "";
  position: absolute;
  top: -10px; left: -1.2px;
  width: 24px; height: 10px;
  border: 1.2px solid var(--silver);
  border-bottom: 0;
  border-radius: 5px 7px 0 0;
}
.file-info { display: grid; gap: 4px; min-width: 0; padding: 12px 14px 14px; }
.file-name {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.45;
  word-break: normal;
  overflow-wrap: anywhere;
}
.file-meta { display: flex; flex-wrap: wrap; gap: 0 6px; font-size: 12px; color: var(--muted); }
.file-meta span + span::before { content: "·"; margin-right: 6px; color: var(--faint); }
.file-person { font-size: 12px; color: var(--faint); overflow-wrap: anywhere; }
.download-link {
  justify-self: start;
  margin-top: 6px;
  padding: 2px 0;
  font-size: 12px;
  color: var(--accent);
  text-decoration: none;
}
.download-link:hover { text-decoration: underline; text-underline-offset: 3px; }

.empty { padding: 64px 0; text-align: center; color: var(--faint); font-size: 14px; }
.empty .ico { display: block; width: 28px; height: 28px; margin: 0 auto 14px; color: var(--accent); opacity: .7; }
#more { display: flex; margin: 24px auto 0; min-width: 120px; }

.upload-hint { margin-top: 28px; text-align: center; font-size: 12.5px; color: var(--faint); }
.upload-hint strong { color: var(--muted); font-weight: 500; }

/* footer */
.site-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  max-width: 1120px;
  margin: 0 auto;
  padding: 22px 20px 40px;
  border-top: 1px solid var(--line);
  color: var(--faint);
  font-size: 12px;
}
.site-footer .ico { width: 13px; height: 13px; color: var(--faint); }
.site-footer a { color: var(--faint); text-decoration: none; }
.site-footer a:hover { color: var(--muted); }

/* ── Toast ──────────────────────────────────────────── */
#toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  z-index: 50;
  max-width: calc(100% - 32px);
  padding: 12px 18px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: rgba(19, 27, 47, .96);
  color: var(--text);
  font-size: 14px;
  box-shadow: 0 18px 48px -16px rgba(0, 0, 0, .6);
  transform: translateX(-50%);
}

/* ── Preview dialog ─────────────────────────────────── */
#preview-dialog {
  width: auto;
  max-width: min(1100px, calc(100vw - 24px));
  max-height: calc(100dvh - 24px);
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 18px;
  background: #0b1121;
  color: var(--text);
  box-shadow: 0 40px 100px -30px rgba(0, 0, 0, .8);
}
#preview-dialog[open] { display: flex; flex-direction: column; }
#preview-dialog::backdrop { background: rgba(4, 7, 15, .84); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
#preview-image {
  display: block;
  min-width: min(320px, calc(100vw - 26px));
  min-height: 200px;
  max-width: 100%;
  max-height: calc(100dvh - 104px);
  margin: 0 auto;
  object-fit: contain;
  background: #060a14;
}
.preview-close {
  position: absolute;
  top: 12px; right: 12px;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 40px; height: 40px;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: rgba(10, 15, 29, .72);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  color: var(--text);
  cursor: pointer;
}
.preview-close .ico { width: 18px; height: 18px; }
.preview-caption {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
}
#preview-title { flex: 1; min-width: 0; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── Mobile ─────────────────────────────────────────── */
@media (max-width: 760px) {
  .editor { grid-template-columns: 1fr; padding: 22px 18px; }
  #pin-form { padding: 22px 0 0; border-left: 0; border-top: 1px solid var(--line); }
}
@media (max-width: 640px) {
  input:not([type="file"]):not([type="checkbox"]):not([type="radio"]),
  textarea, select, .search input { font-size: 16px; } /* prevent iOS zoom */

  .entry { padding: 40px 14px; place-items: start center; padding-top: 18vh; }
  .sky-moon { top: 4%; right: 7%; width: 84px; height: 84px; }
  .s1 { top: 9%; left: 12%; }
  .s3 { top: 6%; left: 46%; }
  .s2, .sky-snow { display: none; }
  .login-card { padding: 36px 22px 22px; border-radius: 20px; }
  .login-card h1, .login-card h2 { font-size: 24px; }

  .topbar { min-height: 56px; padding: 8px 16px; }
  .account { gap: 6px; }
  #identity { max-width: 96px; font-size: 12.5px; }
  .account .quiet { min-height: 34px; padding: 0 11px; font-size: 12.5px; }

  .space { padding: 18px 16px 44px; gap: 22px; }
  .hero { min-height: 200px; border-radius: 18px; }
  .hero.has-cover { min-height: 260px; }
  .hero-copy, .hero.has-cover .hero-copy { padding: 24px 22px 22px; }
  .h-moon { top: 22px; right: 22px; width: 58px; height: 58px; transform: none; }
  .hs1 { top: 30px; right: 104px; }
  .hs2 { top: 92px; right: 40px; bottom: auto; }
  .hs3, .h-snow { display: none; }
  #site-subtitle { font-size: 14px; }

  .notice { padding: 14px 16px 14px 40px; font-size: 14px; }
  .notice::before { top: 19px; left: 17px; }

  .section-heading h2 { font-size: 18px; }
  .upload-button { min-height: 42px; padding: 0 14px; }
  .toolbar { flex-direction: column; align-items: stretch; gap: 10px; }
  .search { flex: 1 1 auto; }

  .file-grid { grid-template-columns: repeat(auto-fill, minmax(148px, 1fr)); gap: 12px; }
  .file-info { padding: 10px 12px 12px; }
  .file-name { font-size: 13.5px; }

  .preview-caption { padding: 10px 12px; }
}

/* ── Motion ─────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}
