/* img — calm, one-screen image hosting. Mobile-first. */
@font-face { font-family: "Nunito"; src: url("/static/fonts/Nunito.ttf") format("truetype"); font-weight: 200 1000; font-display: swap; }

:root {
  color-scheme: light dark;
  --bg: #faf7f2; --bg-2: #ffffff; --bg-3: #f1ede6; --line: #e6e1d8; --line-strong: #d3cdc2;
  --text: #1f2430; --muted: #6b7080; --faint: #9aa0ad;
  --accent: #e8463a; --accent-ink: #fff;
  --ok: #1f9d6a; --err: #d64560; --warn: #c27a00;
  --radius: 16px; --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(31,36,48,.06), 0 6px 20px -8px rgba(31,36,48,.14);
  --font: "Nunito", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --top-h: 56px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161c; --bg-2: #1d2029; --bg-3: #262a35; --line: #2e323d; --line-strong: #3d424f;
    --text: #eceef3; --muted: #a0a6b5; --faint: #858c9c; --warn: #f5b84a; --accent: #f05a4e;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px -10px rgba(0,0,0,.6);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scrollbar-gutter: stable; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.5 var(--font); min-height: 100dvh; overflow-x: hidden; -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
a { color: var(--accent); text-decoration: none; }
button { font: inherit; color: inherit; }
h1 { font-size: 1.35rem; margin: 0; font-weight: 800; letter-spacing: -.01em; }
h2 { font-size: 1.05rem; margin: 0 0 .5rem; font-weight: 800; }
.h-small { font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 0; font-weight: 800; }
.ico { display: inline-flex; width: 18px; height: 18px; flex: none; }
.ico svg { width: 100%; height: 100%; }
.muted { color: var(--muted); } .small { font-size: .85rem; } .center { text-align: center; }
.row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.row--between { justify-content: space-between; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* layout */
.app { min-height: 100dvh; display: flex; flex-direction: column; }
.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 1rem; height: calc(var(--top-h) + env(safe-area-inset-top)); padding: env(safe-area-inset-top) 16px 0; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(12px) saturate(140%); border-bottom: 1px solid var(--line); }
.brand { display: inline-flex; align-items: center; gap: .5rem; color: var(--text); font-weight: 900; font-size: 1.1rem; }
.top__right { margin-left: auto; display: flex; gap: .25rem; align-items: center; min-width: 0; }
.top__right form { margin: 0; }
#who-btn { max-width: 40vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: inline-block; line-height: 34px; }
.main { flex: 1; width: 100%; max-width: 1100px; margin: 0 auto; padding: 16px 16px calc(32px + env(safe-area-inset-bottom)); }

/* cards & controls */
.card { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); margin-bottom: 20px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; min-height: 44px; padding: 0 18px; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--bg-2); color: var(--text); font-weight: 800; cursor: pointer; text-decoration: none; transition: transform .08s ease, background .12s ease; user-select: none; -webkit-tap-highlight-color: transparent; white-space: nowrap; }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: default; }
.btn--primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn--danger { background: var(--err); border-color: var(--err); color: #fff; }
.btn--ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn--ghost:hover { background: var(--bg-3); color: var(--text); }
.btn--small { min-height: 40px; padding: 0 14px; font-size: .9rem; }
.btn--icon { width: 44px; padding: 0; }
.btn--small.btn--icon { width: 40px; }
.btn--danger-ghost { color: var(--err); }
.btn--danger-ghost:hover { background: color-mix(in srgb, var(--err) 10%, var(--bg-2)); }
.iconbtn { width: 40px; height: 40px; border-radius: 50%; border: 0; background: transparent; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; color: var(--muted); flex: none; }
.iconbtn:hover { background: var(--bg-3); color: var(--text); }
.iconbtn svg { width: 22px; height: 22px; }
.field { display: flex; flex-direction: column; gap: .3rem; margin-bottom: .9rem; }
.field--tight { margin-bottom: .4rem; }
.field > span { font-size: .85rem; font-weight: 800; color: var(--muted); }
input:not([type=checkbox]):not([type=radio]):not([type=file]) { width: 100%; font: inherit; color: var(--text); background: var(--bg-2); border: 1px solid var(--line-strong); border-radius: var(--radius-sm); padding: 10px 12px; min-height: 44px; font-size: 16px; }
input:focus, .btn:focus-visible, .seg__opt:focus-visible, .drop:focus-within { outline: 2px solid var(--accent); outline-offset: 1px; }
.alert { padding: 10px 14px; border-radius: var(--radius-sm); background: var(--bg-3); margin: .5rem 0; font-weight: 600; }
.alert--err { background: color-mix(in srgb, var(--err) 14%, var(--bg-2)); color: var(--err); }

/* upload */
.upload { padding: 12px; }
.drop { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .3rem; text-align: center; min-height: 168px; padding: 20px; border: 2px dashed var(--line-strong); border-radius: 12px; cursor: pointer; transition: background .12s, border-color .12s; }
.drop:hover, .drop.is-over { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 6%, var(--bg-2)); }
.drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }
.drop__icon { width: 46px; height: 46px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; background: var(--accent); color: #fff; margin-bottom: .3rem; }
.drop__icon svg { width: 24px; height: 24px; }
.pending { margin-top: 12px; }
.pitem { display: grid; grid-template-columns: 76px minmax(0, 1fr) auto; gap: 12px; align-items: start; padding: 12px 0; border-top: 1px solid var(--line); }
.pitem__thumb { width: 76px; height: 76px; object-fit: cover; border-radius: 10px; background: var(--bg-3); }
.pitem__meta { margin-bottom: .35rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pitem__x { margin-top: -4px; }
.namebox { display: flex; align-items: stretch; }
.namebox input { border-top-right-radius: 0 !important; border-bottom-right-radius: 0 !important; }
.namebox__ext { display: inline-flex; align-items: center; padding: 0 12px; border: 1px solid var(--line-strong); border-left: 0; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; background: var(--bg-3); color: var(--muted); font-weight: 700; }
.url-preview { overflow-wrap: anywhere; }
.progress { height: 6px; border-radius: 99px; background: var(--bg-3); overflow: hidden; margin-top: .5rem; }
.progress i { display: block; height: 100%; background: var(--accent); transition: width .15s; }
.okline { display: flex; align-items: center; gap: .35rem; color: var(--ok); font-weight: 800; margin-bottom: .4rem; }
.urlbox { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.urlbox input { flex: 1 1 180px; min-width: 0; font-size: 15px !important; }
.pending__foot { border-top: 1px solid var(--line); padding-top: 12px; }
.pending__foot p { margin: .2rem 0 .8rem; }
.seg { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.seg__opt { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 54px; padding: 6px 4px; border-radius: 12px; border: 1px solid var(--line-strong); background: var(--bg-2); cursor: pointer; line-height: 1.2; }
.seg__opt b { font-size: .92rem; }
.seg__opt small { font-size: .72rem; color: var(--muted); margin-top: 2px; }
.seg__opt.is-on { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, var(--bg-2)); box-shadow: inset 0 0 0 1px var(--accent); }
.seg__opt:disabled { opacity: .45; cursor: default; }

/* list */
.list-head { margin: 4px 0 12px; min-height: 44px; }
.search { max-width: 260px; }
.grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
.item { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 12px; background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; box-shadow: var(--shadow); }
.item.is-fresh { border-color: var(--ok); box-shadow: 0 0 0 1px var(--ok), var(--shadow); }
.item__thumb { display: block; width: 96px; height: 96px; border-radius: 10px; overflow: hidden; background: var(--bg-3) repeating-conic-gradient(var(--line) 0 25%, transparent 0 50%) 0 0 / 16px 16px; }
.item__thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.item__body { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.item__name { font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item__meta { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item__actions { display: flex; gap: 6px; margin-top: auto; padding-top: 6px; flex-wrap: wrap; }
.exp { display: inline-flex; align-items: center; gap: .3rem; color: var(--muted); }
.exp .ico { width: 15px; height: 15px; }
.exp--soon { color: var(--warn); font-weight: 700; }
.empty { display: flex; flex-direction: column; gap: .25rem; align-items: center; text-align: center; padding: 36px 16px; border: 1px dashed var(--line-strong); border-radius: var(--radius); }
@media (min-width: 760px) {
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .main { padding-top: 24px; }
}
@media (min-width: 1060px) { .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 420px) {
  .item { grid-template-columns: 80px minmax(0, 1fr); }
  .item__thumb { width: 80px; height: 80px; }
  .item__actions .btn--primary { flex: 1; }
  .seg__opt small { font-size: .66rem; }
}

/* sheet (bottom on mobile, dialog on desktop) */
.sheet-backdrop { position: fixed; inset: 0; z-index: 50; background: rgba(15,17,22,.45); display: flex; align-items: flex-end; justify-content: center; animation: fade .15s ease; }
.sheet { width: 100%; max-width: 520px; max-height: 90dvh; overflow: auto; background: var(--bg-2); border-radius: 20px 20px 0 0; padding: 12px 16px calc(20px + env(safe-area-inset-bottom)); animation: up .2s ease; }
.sheet__head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: .25rem; }
.sheet__head h2 { margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (min-width: 640px) {
  .sheet-backdrop { align-items: center; }
  .sheet { border-radius: 20px; padding-bottom: 20px; }
}
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(24px); opacity: .6; } }

/* toast */
.toast { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px); z-index: 60; max-width: calc(100% - 32px); padding: 12px 18px; border-radius: 14px; background: var(--text); color: var(--bg); font-weight: 700; box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: opacity .15s, transform .15s; }
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }
.toast.is-err { background: var(--err); color: #fff; }

/* login */
.login-body { display: flex; align-items: center; justify-content: center; padding: 16px; }
.login { width: 100%; max-width: 360px; }
.login__brand { text-align: center; margin-bottom: 18px; }
.login__brand img { border-radius: 14px; margin-bottom: 8px; }
.login__form { padding: 20px; }
