:root {
  color-scheme: dark;
  --bg: #0c0c0e;
  --surface: #131316;
  --surface-2: #19191d;
  --surface-3: #222227;
  --line: #2b2b31;
  --text: #f4f4f5;
  --muted: #a1a1aa;
  --orange: #fb923c;
  --orange-light: #fdba74;
  --orange-soft: rgba(251, 146, 60, .1);
  --danger: #fda4af;
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --gutter: clamp(20px, 4vw, 48px);
}

* { box-sizing: border-box; }
html { min-height: 100%; scrollbar-gutter: stable; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: "Inter", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; font-size: 14px; line-height: 1.55; -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; }
button, a, [role="button"] { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
button, [role="button"] { cursor: pointer; }
button { color: inherit; }
button:disabled { cursor: wait; opacity: .55; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; }
::selection { background: rgba(251,146,60,.25); color: white; }
.hidden { display: none !important; }
:where(button, a, input, select, [role="button"]):focus-visible { outline: 2px solid var(--orange); outline-offset: 4px; }
.material-symbols-rounded { display: inline-flex; align-items: center; justify-content: center; width: 1em; height: 1em; flex: 0 0 auto; font-family: "Material Symbols Rounded"; font-size: 20px; font-weight: normal; font-style: normal; line-height: 1; letter-spacing: normal; text-transform: none; white-space: nowrap; vertical-align: middle; font-feature-settings: "liga"; -webkit-font-feature-settings: "liga"; font-variation-settings: "FILL" 0, "wght" 450, "GRAD" 0, "opsz" 24; }
.eyebrow { margin: 0 0 6px; color: var(--muted); font-size: 11px; font-weight: 600; letter-spacing: .09em; text-transform: uppercase; }
.primary, .danger, .login-button, .logout-button { display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; gap: 8px; min-height: 44px; padding: 10px 16px; border: 1px solid transparent; border-radius: var(--radius-sm); font-size: 13px; font-weight: 600; line-height: 1.4; transition: background .18s, border-color .18s, color .18s; }
.primary, .login-button { background: var(--orange); color: #251507; box-shadow: inset 0 1px rgba(255,255,255,.15), 0 2px 4px rgba(0,0,0,.15); }
.primary:hover, .login-button:hover { background: var(--orange-light); }
.danger { background: rgba(251,113,133,.08); border-color: rgba(251,113,133,.15); color: var(--danger); }
.danger:hover { background: rgba(251,113,133,.16); border-color: rgba(251,113,133,.3); }
.icon-button { display: inline-grid; place-items: center; flex: 0 0 auto; width: 44px; height: 44px; padding: 0; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-2); color: var(--muted); transition: color .18s, background .18s; }
.icon-button:hover { background: var(--surface-3); color: var(--text); }

/* A quiet login, with only the brand and the sign-in action. */
.login-shell { display: grid; place-items: center; min-height: 100vh; min-height: 100dvh; padding: 24px; }
.login-card { display: flex; flex-direction: column; align-items: center; width: min(100%, 384px); padding: 32px; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); box-shadow: 0 24px 80px rgba(0,0,0,.25); }
.login-logo { display: block; width: 228px; height: 180px; margin-bottom: 24px; object-fit: contain; }
.login-button { width: 100%; min-height: 48px; font-size: 14px; }
.form-error { width: 100%; margin: 0 0 20px; color: var(--danger); font-size: 13px; text-align: center; overflow-wrap: anywhere; }
.form-error:empty { display: none; }

/* Equal outer columns keep the navigation at the center of the page. */
.app-shell { min-height: 100vh; min-height: 100dvh; }
.site-header { position: sticky; z-index: 10; top: 0; display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 24px; min-height: 88px; padding: 12px var(--gutter); border-bottom: 1px solid var(--line); background: rgba(12,12,14,.94); backdrop-filter: blur(16px); }
.site-brand { grid-column: 1; grid-row: 1; display: inline-flex; align-items: center; width: fit-content; border-radius: 8px; }
.site-logo { display: block; width: 110px; height: 56px; object-fit: contain; object-position: left center; }
.page-tabs { grid-column: 2; grid-row: 1; display: flex; gap: 4px; padding: 4px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.page-tab { min-height: 40px; padding: 9px 18px; border: 1px solid transparent; border-radius: 8px; background: transparent; color: var(--muted); font-size: 13px; font-weight: 500; white-space: nowrap; transition: background .18s, color .18s; }
.page-tab:hover { color: var(--text); background: var(--surface-2); }
.page-tab.active { border-color: rgba(251,146,60,.15); background: var(--orange-soft); color: var(--orange-light); }
.account-menu { grid-column: 3; grid-row: 1; display: flex; align-items: center; justify-self: end; gap: 16px; min-width: 0; max-width: 100%; }
.user-card { display: flex; align-items: center; gap: 10px; min-width: 0; }
.user-card > span:last-child { min-width: 0; }
.avatar { display: grid; place-items: center; flex: 0 0 auto; width: 36px; height: 36px; border: 1px solid rgba(255,255,255,.1); border-radius: 50%; background: var(--orange-soft); color: var(--orange-light); font-size: 14px; font-weight: 600; }
.avatar-image { display: block; object-fit: cover; }
.user-card b, .user-card small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-card b { font-size: 13px; font-weight: 500; }
.user-card small { margin-top: 1px; color: var(--muted); font-size: 11px; }
.logout-button { padding: 10px 12px; border-color: var(--line); background: transparent; color: var(--muted); }
.logout-button:hover { border-color: #45454f; background: var(--surface-2); color: var(--text); }

.workspace { width: min(100%, 1248px); margin-inline: auto; padding: 48px var(--gutter) 72px; }
.topbar { display: flex; align-items: center; gap: 20px; margin-bottom: 32px; }
.page-heading { flex: 1; min-width: 0; }
.page-heading h1 { margin: 0; font-size: clamp(25px, 2.5vw, 32px); font-weight: 600; line-height: 1.2; letter-spacing: -.045em; }
.page-heading p { margin: 9px 0 0; color: var(--muted); font-size: 14px; }
.search-field { display: flex; align-items: center; gap: 10px; flex: 0 1 280px; min-width: 0; min-height: 44px; padding: 0 13px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); color: var(--muted); }
.search-field input { width: 100%; min-width: 0; padding: 11px 0; border: 0; outline: none; background: transparent; color: var(--text); font-size: 13px; }
.search-field input::placeholder { color: var(--muted); }
.search-field:focus-within { border-color: var(--orange); box-shadow: 0 0 0 3px var(--orange-soft); }
.content, .page-panel { min-width: 0; }
.dropzone { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 360px; padding: 40px 24px; border: 1px dashed #424047; border-radius: var(--radius-lg); background: radial-gradient(ellipse at 50% 0%, rgba(251,146,60,.045), transparent 65%), var(--surface); text-align: center; transition: border-color .18s, background .18s; }
.dropzone:hover, .dropzone.dragging { border-color: var(--orange); background: var(--surface-2); }
.dropzone-icon { width: 64px; height: 64px; margin-bottom: 24px; border: 1px solid rgba(251,146,60,.16); border-radius: 18px; background: var(--orange-soft); color: var(--orange-light); font-size: 30px; }
.dropzone-copy b { display: block; font-size: 20px; font-weight: 600; letter-spacing: -.025em; }
.dropzone-copy > span { display: block; margin-top: 7px; color: var(--muted); font-size: 14px; }
.dropzone-action { display: inline-flex; align-items: center; justify-content: center; gap: 10px; min-height: 44px; margin-top: 24px; padding: 10px 16px; border: 1px solid #3c3c43; border-radius: var(--radius-sm); background: var(--surface-3); color: var(--text); font-size: 13px; font-weight: 500; }
.dropzone-action .material-symbols-rounded { font-size: 18px; }
.dropzone:hover .dropzone-action { border-color: rgba(251,146,60,.4); }
.dropzone small { margin-top: 20px; color: var(--muted); font-size: 12px; }
.upload-info-card { display: flex; align-items: flex-start; justify-content: center; gap: 12px; margin: 24px auto 0; padding: 0 12px; }
.upload-info-card > .material-symbols-rounded { margin-top: 2px; color: var(--muted); }
.upload-info-card b, .upload-info-card small { display: block; }
.upload-info-card b { color: #d4d4d8; font-size: 12px; font-weight: 500; }
.upload-info-card small { margin-top: 3px; color: var(--muted); font-size: 12px; }

.library-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: 0 0 20px; padding-bottom: 20px; border-bottom: 1px solid var(--line); }
.library-head > div { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.library-head h3 { margin: 0; font-size: 15px; font-weight: 500; }
.library-head div > span { padding: 3px 8px; border: 1px solid var(--line); border-radius: 6px; color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
select { min-height: 44px; max-width: 100%; padding: 9px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); color: #d4d4d8; font-size: 13px; }
.upload-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr)); gap: 20px; }
.upload-card { min-width: 0; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--surface); transition: border-color .18s, box-shadow .18s; }
.upload-card:hover { border-color: #56515a; box-shadow: 0 8px 24px rgba(0,0,0,.16); }
.card-preview { position: relative; aspect-ratio: 4 / 3; overflow: hidden; background: #101012; }
.card-preview img { display: block; width: 100%; height: 100%; object-fit: cover; }
.card-preview::after { content: ""; position: absolute; inset: auto 0 0; height: 45%; background: linear-gradient(transparent, rgba(0,0,0,.35)); pointer-events: none; }
.card-actions { position: absolute; z-index: 2; right: 10px; bottom: 10px; display: flex; gap: 6px; opacity: 0; transition: opacity .18s; }
.upload-card:hover .card-actions, .upload-card:focus-within .card-actions { opacity: 1; }
.card-actions button { display: grid; place-items: center; width: 44px; height: 44px; padding: 0; border: 1px solid rgba(255,255,255,.16); border-radius: var(--radius-sm); background: rgba(12,12,14,.85); color: white; backdrop-filter: blur(8px); }
.card-actions button:hover { background: var(--surface-3); color: var(--orange-light); }
.card-info { padding: 16px; }
.card-info b { display: block; overflow: hidden; font-size: 13px; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.card-meta { display: flex; flex-wrap: wrap; gap: 4px 10px; justify-content: space-between; margin-top: 8px; color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.loading-state { display: flex; align-items: center; justify-content: center; gap: 7px; min-height: 280px; }
.loading-state span { width: 7px; height: 7px; border-radius: 50%; background: var(--orange); animation: pulse 1s infinite alternate; }
.loading-state span:nth-child(2) { animation-delay: .2s; }
.loading-state span:nth-child(3) { animation-delay: .4s; }
.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 340px; padding: 40px 24px; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); text-align: center; }
.empty-state > .material-symbols-rounded { width: 56px; height: 56px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface-2); color: var(--orange-light); font-size: 26px; }
.empty-state h3 { margin: 20px 0 8px; font-size: 20px; font-weight: 600; letter-spacing: -.025em; }
.empty-state p { max-width: 430px; margin: 0 0 24px; color: var(--muted); font-size: 14px; }

dialog { width: min(1040px, calc(100% - 40px)); max-height: calc(100dvh - 40px); margin: auto; padding: 0; overflow-y: auto; border: 1px solid #36363d; border-radius: var(--radius-lg); background: var(--surface); color: var(--text); box-shadow: 0 32px 100px rgba(0,0,0,.5); }
dialog::backdrop { background: rgba(0,0,0,.75); backdrop-filter: blur(6px); }
body:has(dialog[open]) { overflow: hidden; }
.dialog-shell { padding: 28px; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.dialog-head > div { min-width: 0; }
.dialog-head h2 { overflow: hidden; margin: 0; font-size: 20px; font-weight: 600; letter-spacing: -.025em; text-overflow: ellipsis; white-space: nowrap; }
.detail-grid { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); align-items: start; gap: 28px; }
.detail-preview { display: grid; place-items: center; min-width: 0; min-height: 380px; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius-md); background: #0b0b0d; }
.detail-preview button { display: grid; place-items: center; width: 100%; min-width: 0; min-height: inherit; padding: 0; border: 0; background: transparent; cursor: zoom-in; }
.detail-preview img { display: block; max-width: 100%; max-height: 65dvh; object-fit: contain; }
.detail-content { min-width: 0; }
.detail-content dl { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin: 0 0 24px; padding-bottom: 24px; border-bottom: 1px solid var(--line); }
.detail-content dt { color: var(--muted); font-size: 12px; }
.detail-content dd { margin: 5px 0 0; font-size: 13px; font-weight: 500; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.link-list { display: grid; gap: 14px; }
.link-list label { color: var(--muted); font-size: 12px; font-weight: 500; }
.link-list label > span { display: grid; grid-template-columns: minmax(0, 1fr) 44px; margin-top: 7px; }
.link-list input { min-width: 0; padding: 11px; border: 1px solid var(--line); border-radius: 9px 0 0 9px; background: var(--bg); color: #d4d4d8; font: 12px/1.5 ui-monospace, SFMono-Regular, Consolas, monospace; }
.link-list button { display: grid; place-items: center; min-height: 44px; padding: 0; border: 1px solid var(--line); border-left: 0; border-radius: 0 9px 9px 0; background: var(--surface-2); color: var(--muted); }
.link-list button:hover { background: var(--surface-3); color: var(--orange-light); }
.dialog-actions { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px; margin-top: 24px; }
.moderation-menu { display: grid; gap: 12px; margin-top: 24px; padding: 16px; border: 1px solid rgba(251,113,133,.2); border-radius: var(--radius-md); background: rgba(251,113,133,.04); }
.moderation-menu strong { font-size: 13px; }
.moderation-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.image-lightbox { width: fit-content; max-width: calc(100% - 32px); padding: 16px; background: #101012; }
.image-lightbox::backdrop { background: rgba(0,0,0,.88); }
.image-lightbox figure { display: grid; place-items: center; min-width: 0; gap: 12px; margin: 0; }
.image-lightbox img { display: block; max-width: 100%; max-height: calc(100dvh - 130px); object-fit: contain; }
.image-lightbox figcaption { max-width: 100%; overflow: hidden; color: var(--muted); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.lightbox-close { position: absolute; z-index: 1; top: 12px; right: 12px; background: rgba(19,19,22,.9); color: white; }
.progress-toast, .toast { position: fixed; z-index: 20; right: 24px; bottom: max(24px, env(safe-area-inset-bottom)); max-width: min(400px, calc(100% - 40px)); border: 1px solid #3b3b43; border-radius: var(--radius-md); background: var(--surface-2); box-shadow: 0 12px 48px rgba(0,0,0,.3); overflow-wrap: anywhere; }
.progress-toast { display: flex; align-items: center; gap: 14px; padding: 16px 20px; }
.progress-toast b, .progress-toast small { display: block; }
.progress-toast b { font-size: 13px; font-weight: 500; }
.progress-toast small { margin-top: 3px; color: var(--muted); font-size: 12px; }
.spinner { flex-shrink: 0; width: 24px; height: 24px; border: 2px solid var(--line); border-top-color: var(--orange); border-radius: 50%; animation: spin .7s linear infinite; }
.toast { padding: 14px 18px; font-size: 13px; opacity: 0; pointer-events: none; transform: translateY(8px); transition: opacity .18s, transform .18s; }
.toast.show { opacity: 1; transform: none; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { to { opacity: .25; } }

@media (max-width: 1000px) {
  .account-menu { gap: 10px; }
  .logout-button { width: 44px; padding: 0; }
  .logout-button > span:last-child { display: none; }
  .topbar { flex-wrap: wrap; }
  .search-field { order: 3; flex-basis: 100%; }
  .detail-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; }
}
@media (max-width: 760px) {
  :root { --gutter: 20px; }
  .site-header { grid-template-columns: minmax(0, 1fr) auto; gap: 12px 20px; padding-block: 12px; }
  .site-logo { width: 92px; height: 46px; }
  .account-menu { grid-column: 2; max-width: 260px; }
  .page-tabs { grid-column: 1 / -1; grid-row: 2; justify-self: center; }
  .page-tab { min-height: 44px; padding-inline: 24px; }
  .workspace { padding-top: 32px; padding-bottom: 48px; }
  .topbar { gap: 20px 12px; margin-bottom: 24px; }
  .page-heading p { font-size: 13px; }
  .dropzone { min-height: 340px; padding: 32px 20px; }
  .dropzone-copy > span { max-width: 320px; }
  .upload-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
  .card-info { padding: 14px; }
  .detail-grid { grid-template-columns: minmax(0, 1fr); gap: 24px; }
  .detail-preview { min-height: 220px; }
  .detail-preview img { max-height: 44dvh; }
  .dialog-shell { padding: 20px; }
}
@media (max-width: 480px) {
  :root { --gutter: 16px; }
  .site-header { gap: 10px 12px; }
  .site-logo { width: 80px; height: 44px; }
  .account-menu { max-width: 190px; }
  .user-card { gap: 8px; }
  .user-card small { display: none; }
  .user-card b { max-width: 100px; font-size: 12px; }
  .avatar { width: 32px; height: 32px; }
  .page-tabs { width: 100%; }
  .page-tab { flex: 1; padding-inline: 10px; }
  .topbar > .primary { width: 44px; padding: 0; }
  .topbar > .primary > span:last-child { display: none; }
  .page-heading h1 { font-size: 25px; }
  .dropzone { padding: 32px 18px; }
  .dropzone-copy b { font-size: 19px; }
  .dropzone small { max-width: 220px; line-height: 1.7; }
  .upload-info-card { margin-top: 20px; padding: 0 4px; }
  .library-head { align-items: flex-start; gap: 12px; }
  .library-head > div { gap: 6px; }
  .library-head h3 { width: 100%; }
  .upload-grid { grid-template-columns: minmax(0, 1fr); }
  dialog { width: calc(100% - 24px); max-height: calc(100dvh - 24px); border-radius: 16px; }
  .dialog-shell { padding: 16px; }
  .dialog-head h2 { font-size: 18px; }
  .dialog-actions { flex-direction: column-reverse; }
  .dialog-actions > *, .moderation-actions > * { width: 100%; }
  .login-card { padding: 28px 24px; }
  .progress-toast, .toast { right: 16px; max-width: calc(100% - 32px); bottom: max(16px, env(safe-area-inset-bottom)); }
}
@media (hover: none), (pointer: coarse) {
  .card-actions { opacity: 1; }
  .search-field input, select, .link-list input { font-size: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
