:root {
  --bg: #fbf9f5;
  --surface: #fff;
  --fill: #f2f0eb;
  --fill-strong: #e9e5dd;
  --ink: #261208;
  --ink-secondary: #46352b;
  --muted: #746b65;
  --faint: #aaa39c;
  --brand: #00cc70;
  --danger: #bd4a39;
  --danger-soft: #f4e4dc;
  --danger-soft-hover: #edd4c8;
  --danger-ink: #9a3412;
  --danger-ink-hover: #7c2d12;
  --border: #e4ded6;
  --radius: 18px;
  --radius-sm: 12px;
  --page-pad: clamp(16px, 4vw, 48px);
  --content: 1280px;
}

* { box-sizing: border-box; }
html {
  scroll-behavior: smooth;
  overflow-y: scroll;
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  scrollbar-color: #c6bfba transparent;
}
html::-webkit-scrollbar,
body::-webkit-scrollbar,
.dialog-body::-webkit-scrollbar,
.select-menu::-webkit-scrollbar,
.prompt-block::-webkit-scrollbar,
.profile-pane::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
html::-webkit-scrollbar-track,
body::-webkit-scrollbar-track,
.dialog-body::-webkit-scrollbar-track,
.select-menu::-webkit-scrollbar-track,
.prompt-block::-webkit-scrollbar-track,
.profile-pane::-webkit-scrollbar-track {
  background: transparent;
}
html::-webkit-scrollbar-thumb,
body::-webkit-scrollbar-thumb,
.dialog-body::-webkit-scrollbar-thumb,
.select-menu::-webkit-scrollbar-thumb,
.prompt-block::-webkit-scrollbar-thumb,
.profile-pane::-webkit-scrollbar-thumb {
  border: 2px solid transparent;
  border-radius: 999px;
  background: #c6bfba;
  background-clip: padding-box;
}
html::-webkit-scrollbar-thumb:hover,
body::-webkit-scrollbar-thumb:hover,
.dialog-body::-webkit-scrollbar-thumb:hover {
  background: #aaa39c;
  background-clip: padding-box;
}
[hidden] { display: none !important; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.5 "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", Inter, system-ui, sans-serif;
}
button, input, textarea { font: inherit; }
button { border: 0; cursor: pointer; }
button, input, textarea { -webkit-tap-highlight-color: transparent; }
button:focus-visible, input:focus-visible, textarea:focus-visible { outline: 3px solid rgb(0 204 112 / .35); outline-offset: 2px; }

.app-header {
  position: sticky; top: 0; z-index: 10; border-bottom: 1px solid rgb(38 18 8 / .08);
  background: rgb(251 249 245 / .9); backdrop-filter: blur(18px);
}
.header-inner {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 18px;
  max-width: var(--content); min-height: 72px; margin: auto; padding: 10px var(--page-pad);
}
.brand { display: inline-flex; align-items: center; gap: 9px; color: inherit; text-decoration: none; width: fit-content; }
.brand-logo { width: 36px; height: 36px; display: block; }
.brand strong, .brand small { display: block; line-height: 1.1; }
.brand strong { letter-spacing: .06em; font-size: 15px; }
.brand small { margin-top: 4px; color: var(--muted); font-size: 11px; }
.main-nav { display: flex; gap: 3px; padding: 4px; background: var(--fill); border-radius: 999px; }
.nav-button { padding: 7px 16px; color: var(--muted); border-radius: 999px; background: transparent; }
.nav-button.is-active { color: #fff; background: var(--ink); font-weight: 650; }
.header-actions { display: flex; justify-content: flex-end; align-items: center; gap: 10px; }
body.is-public .admin-only,
body.is-admin .public-only,
body.is-public:not(.is-logged-in) .logged-in-only,
body.is-admin:not(.is-authed) .app-header,
body.is-admin:not(.is-authed) .app-main,
body.is-admin:not(.is-authed) .admin-only { display: none !important; }
.login-dialog, .user-auth-dialog, .user-dialog, .admin-user-dialog, .admin-account-dialog { width: min(420px, calc(100vw - 28px)); }
.user-chip {
  position: relative;
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 40px; padding: 0 16px;
  border: 0; border-radius: 999px; background: var(--fill); color: var(--ink); font-weight: 650;
}
.user-chip:hover { background: var(--fill-strong); }
.user-chip .notice-dot {
  position: absolute; top: 8px; right: 8px;
  width: 8px; height: 8px; border-radius: 99px; background: var(--danger);
  box-shadow: 0 0 0 2px var(--surface);
}
.auth-forgot {
  justify-self: start; min-height: 36px; padding: 0 12px; margin: 0;
  border-radius: 999px; background: transparent; color: var(--muted); font-weight: 650;
}
.auth-forgot:hover { background: var(--fill); color: var(--ink); }
.oauth-block { display: grid; gap: 10px; padding-top: 4px; }
.oauth-label { margin: 0; color: var(--faint); font-size: 12px; text-align: center; }
.oauth-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.oauth-button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 0 16px; border-radius: 999px;
  background: var(--fill); color: var(--ink); font-weight: 650; font-size: 13px;
}
.oauth-button img,
.oauth-button svg { width: 20px; height: 20px; object-fit: contain; flex-shrink: 0; }
.oauth-button:hover { background: var(--fill-strong); }
.oauth-button.is-bound { background: var(--fill-strong); cursor: default; }
.bind-row { display: grid; gap: 10px; padding: 0 8px; }
.bind-row .oauth-button { width: 100%; justify-content: space-between; padding: 0 18px; }
.oauth-button-label { display: inline-flex; align-items: center; gap: 8px; }
.admin-table { display: grid; gap: 10px; }
.section-actions { display: flex; justify-content: flex-end; margin: 0 0 14px; }
.admin-row {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 16px; align-items: center;
  padding: 16px 18px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface);
}
.admin-row h3 { margin: 0 0 4px; font-size: 15px; }
.admin-row p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.45; }
.admin-row-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px; }
.status-chip {
  display: inline-flex; align-items: center; min-height: 22px; padding: 0 8px; margin-right: 6px;
  border-radius: 999px; background: var(--fill); color: var(--muted); font-size: 12px; font-weight: 650;
}
.status-chip.is-pending { background: #f4ead4; color: #8a5a18; }
.status-chip.is-approved { background: rgb(0 204 112 / .16); color: #0b7a46; }
.status-chip.is-rejected, .status-chip.is-banned { background: var(--danger-soft); color: var(--danger-ink); }
.admin-tabs { display: flex; gap: 3px; width: fit-content; max-width: 100%; margin: 0 0 16px; padding: 4px; border-radius: 999px; background: var(--fill); }
.admin-tabs button { min-height: 36px; padding: 0 14px; border-radius: 999px; background: transparent; color: var(--muted); font-weight: 650; }
.admin-tabs button.is-active { background: var(--ink); color: #fff; }
.service-status { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); white-space: nowrap; }
.service-status i { width: 7px; height: 7px; border-radius: 99px; background: var(--faint); }
.service-status.is-online i { background: var(--brand); box-shadow: 0 0 0 4px rgb(0 204 112 / .14); }
.service-status.is-offline i { background: #d1882d; }

.app-main { max-width: var(--content); margin: 0 auto; padding: 40px var(--page-pad) 100px; }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.search-cluster { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; }
.search-field {
  display: flex; align-items: center; gap: 10px; width: min(520px, 100%); padding: 0 16px;
  border: 1px solid var(--border); border-radius: 999px; background: var(--surface);
}
.search-field:focus-within { border-color: var(--ink); box-shadow: 0 0 0 4px rgb(38 18 8 / .08); }
.search-field svg { width: 19px; fill: none; stroke: var(--muted); stroke-width: 1.8; }
.search-field input { width: 100%; height: 46px; border: 0; outline: 0; background: transparent; color: var(--ink); }
.toolbar-actions { display: flex; align-items: center; gap: 12px; }
.text-button {
  min-height: 36px; padding: 0 12px; border-radius: 999px;
  color: var(--muted); background: transparent; font-weight: 650; text-decoration: none;
}
.text-button:hover { background: var(--fill); color: var(--ink); }
.page-size-field { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; white-space: nowrap; }
.sort-field { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; white-space: nowrap; }
.sort-field select {
  min-width: 126px; height: 40px; padding: 0 34px 0 14px; border: 1px solid var(--border); border-radius: 999px;
  appearance: none; background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23746B65' d='M1.2 1.4 6 6.2l4.8-4.8'/%3E%3C/svg%3E") no-repeat right 14px center;
  color: var(--ink); cursor: pointer;
}
.sort-field select:hover, .sort-field select:focus { border-color: var(--ink); background-color: var(--fill); outline: none; }
.custom-select { position: relative; }
.custom-select select { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); pointer-events: none; }
.select-trigger {
  display: flex; align-items: center; justify-content: space-between; min-width: 118px; height: 40px; padding: 0 34px 0 14px;
  border: 1px solid var(--border); border-radius: 999px; background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23746B65' d='M1.2 1.4 6 6.2l4.8-4.8'/%3E%3C/svg%3E") no-repeat right 14px center;
  color: var(--ink); text-align: left;
}
.select-trigger:hover, .select-trigger.is-open { background-color: var(--fill); }
.select-menu { position: fixed; z-index: 40; display: flex; flex-direction: column; gap: 4px; max-height: min(320px, 50vh); overflow-y: auto; padding: 8px; border-radius: 14px; background: var(--surface); box-shadow: 0 18px 40px rgb(38 18 8 / .14); }
.select-menu[hidden] { display: none; }
.select-option { min-height: 42px; padding: 9px 14px; border-radius: 999px; background: transparent; color: var(--ink); text-align: left; }
.select-option:hover { background: var(--fill); }
.select-option.is-active { background: var(--ink); color: #fff; }
.result-heading { display: flex; justify-content: space-between; align-items: center; margin: 28px 0 16px; color: var(--muted); }
.result-heading p { margin: 0; }
.result-heading strong { color: var(--ink); font-size: 18px; }

.card-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.case-card { position: relative; overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); transition: box-shadow .16s ease, border-color .16s ease; }
.case-card:hover { border-color: #d1c9bf; box-shadow: 0 4px 12px rgb(38 18 8 / .06); }
.case-card.is-selected,
body.is-editing .case-card.is-selected,
body.is-editing .case-card.is-selected:hover {
  border-color: var(--ink);
  box-shadow: 0 0 0 1px var(--ink);
}
body.is-editing .case-card { cursor: pointer; }
body.is-editing .case-open { pointer-events: none; cursor: pointer; }
body.is-editing .case-card:hover { transform: none; box-shadow: none; }
body.is-editing .card-actions,
body.is-editing .mini-button,
body.is-editing .heart-button { pointer-events: none; }
.case-open { display: block; width: 100%; padding: 0; background: transparent; color: inherit; text-align: left; }
.image-pair { display: grid; grid-template-columns: 1fr 1fr; min-height: 205px; background: var(--fill); }
.case-image { position: relative; min-width: 0; overflow: hidden; background: #ede9e2; }
.case-image + .case-image { border-left: 1px solid rgb(255 255 255 / .75); }
.case-image img { width: 100%; height: 205px; display: block; object-fit: cover; }
.case-image-label { position: absolute; top: 8px; left: 8px; padding: 3px 7px; border-radius: 6px; color: #fff; background: rgb(38 18 8 / .64); font-size: 11px; }
.case-image.is-disabled { background: var(--fill-strong); }
.case-image.is-disabled .image-empty { color: var(--faint); }
.image-empty { display: grid; place-items: center; min-height: 205px; padding: 12px; color: var(--faint); font-size: 12px; text-align: center; }
.card-copy { padding: 15px 16px 12px; }
.card-title-row { display: flex; align-items: center; gap: 8px; margin: 0 0 10px; }
.card-copy h3 { overflow: hidden; margin: 0; font-size: 16px; white-space: nowrap; text-overflow: ellipsis; flex: 1; min-width: 0; }
.type-badge {
  display: inline-flex; align-items: center; flex-shrink: 0;
  min-height: 22px; padding: 2px 8px; border-radius: 999px;
  background: var(--fill); color: var(--muted); font-size: 12px; font-weight: 650;
}
.type-badge.is-txt2img { background: rgb(0 204 112 / .14); color: var(--ink); }
.tag-list { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { display: inline-flex; align-items: center; min-height: 22px; padding: 2px 8px; border-radius: 99px; background: var(--fill); color: var(--muted); font-size: 12px; }
.prompt-preview { display: -webkit-box; margin: 11px 0 0; overflow: hidden; color: var(--muted); font-size: 13px; line-height: 1.55; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.publisher-meta { display: flex; align-items: center; gap: 8px; margin: -2px 0 10px; color: var(--faint); font-size: 12px; }
.publisher-meta span + span::before { margin-right: 8px; content: "·"; }
.card-footer { display: flex; align-items: center; justify-content: space-between; padding: 0 16px 15px; }
.update-time { color: var(--faint); font-size: 12px; }
.card-actions { display: flex; gap: 6px; }
.mini-button { min-height: 28px; padding: 4px 10px; border-radius: 999px; background: var(--fill); color: var(--muted); font-size: 12px; }
.mini-button:hover { color: var(--ink); background: var(--fill-strong); }
.mini-button.is-danger { color: var(--danger-ink); background: var(--danger-soft); }
.mini-button.is-danger:hover { color: var(--danger-ink-hover); background: var(--danger-soft-hover); }
.heart-button { display: grid; place-items: center; width: 36px; height: 36px; padding: 0; border-radius: 999px; background: var(--fill); color: var(--muted); }
.heart-button svg { width: 18px; height: 18px; }
.heart-button:hover { background: #fae9e5; color: var(--danger); }
.heart-button.is-active { color: var(--danger); background: #fae9e5; }
.card-select {
  position: absolute; z-index: 2; top: 10px; right: 10px;
  display: grid; place-items: center; width: 20px; height: 20px;
}
.yb-check {
  position: absolute; inset: 0; z-index: 1; margin: 0; padding: 0;
  opacity: 0; cursor: pointer;
}
.yb-check-ui {
  display: block; width: 20px; height: 20px; border: 1.5px solid #c6bfba;
  border-radius: 50%; background: #fff; pointer-events: none; overflow: hidden;
}
.yb-check:checked + .yb-check-ui {
  border-color: var(--ink); background-color: var(--ink);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='%23fff' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round' d='M3.4 8.2 6.6 11.3 12.6 4.6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: center; background-size: 14px 14px;
}
.yb-check:focus-visible + .yb-check-ui { outline: 3px solid rgb(0 204 112 / .35); outline-offset: 2px; }

.empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  min-height: 430px; padding: 28px 20px; border: 1px dashed #cfc7be; border-radius: var(--radius);
  text-align: center; background: linear-gradient(135deg, rgb(255 255 255 / .7), rgb(242 240 235 / .5));
}
.empty-illustration { width: 100px; height: 100px; margin: 0; }
.empty-illustration img, .empty-illustration svg { display: block; width: 100px; height: 100px; }
.empty-state h2 { margin: 0; font-size: 20px; }
.empty-state p { margin: 0; color: var(--muted); white-space: nowrap; }
.empty-state .button { margin-top: 4px; }

.button {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 40px; padding: 0 16px; border-radius: 999px;
  background: var(--fill); color: var(--ink); font-weight: 600; white-space: nowrap;
  text-decoration: none; line-height: 1; box-sizing: border-box;
}
a.button { text-decoration: none; }
.button-primary { background: var(--ink); color: #fff; }
.button-primary:hover { background: var(--ink-secondary); color: #fff; }
.button-ghost { background: var(--fill); color: var(--ink); }
.button-ghost:hover { background: var(--fill-strong); }
.button-danger { background: var(--danger-soft); color: var(--danger-ink); }
.button-danger:hover { background: var(--danger-soft-hover); color: var(--danger-ink-hover); }
.pagination { display: flex; justify-content: center; gap: 7px; margin: 30px 0 0; }
.pagination button { min-width: 36px; height: 36px; padding: 0 12px; border-radius: 999px; color: var(--muted); background: var(--fill); }
.pagination button.is-current { color: #fff; background: var(--ink); }
.pagination button:disabled { opacity: .4; cursor: default; }

dialog { width: min(1020px, calc(100vw - 28px)); max-height: min(850px, calc(100vh - 28px)); padding: 0; border: 0; border-radius: 22px; background: var(--surface); box-shadow: 0 24px 70px rgb(38 18 8 / .28); color: var(--ink); }
dialog::backdrop { background: rgb(38 18 8 / .42); backdrop-filter: blur(3px); }
.dialog-shell { display: flex; flex-direction: column; max-height: inherit; }
.dialog-header, .dialog-footer { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 20px 24px; }
.dialog-header { border-bottom: 1px solid var(--border); }
.dialog-header h2 { margin: 0; font-size: 23px; }
.dialog-header .tag-list { margin-top: 8px; }
.dialog-header .section-kicker { display: block; margin: 6px 0 0; }
.icon-button {
  display: grid; place-items: center; width: 40px; height: 40px; padding: 0;
  border-radius: 999px; background: var(--fill); color: var(--muted); flex-shrink: 0;
}
.icon-button svg { display: block; width: 20px; height: 20px; }
.icon-button:hover { background: var(--fill-strong); color: var(--ink); }
.dialog-body { overflow: auto; padding: 24px; }
.dialog-footer { justify-content: flex-end; border-top: 1px solid var(--border); }
.detail-visuals { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.detail-image {
  position: relative; display: grid; place-items: center; min-height: 380px; height: 380px;
  overflow: hidden; border-radius: var(--radius-sm); background: #eee9e1;
}
.detail-image-label {
  position: absolute; z-index: 1; top: 10px; left: 10px;
  min-height: 22px; padding: 3px 10px; border-radius: 999px;
  color: #fff; background: rgb(38 18 8 / .64); font-size: 12px; font-weight: 650; line-height: 1.4;
}
.detail-image-open { display: block; width: 100%; height: 100%; padding: 0; background: transparent; cursor: zoom-in; }
.detail-image img { display: block; width: 100%; height: 100%; object-fit: contain; }
.detail-image .image-empty { min-height: 380px; height: 100%; }
.detail-image.is-disabled { background: var(--fill-strong); }
.detail-image.is-disabled .image-empty { color: var(--faint); }
.prompt-section { margin-top: 26px; }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 16px; }
.section-heading span, .section-kicker { color: var(--muted); font-size: 12px; }
.section-heading h3 { margin: 2px 0 0; font-size: 18px; }
.prompt-block { min-height: 130px; margin: 12px 0 0; padding: 16px; overflow: auto; border-radius: var(--radius-sm); background: #29231e; color: #f9f6f1; font: 13px/1.7 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; white-space: pre-wrap; }

.editor-dialog { width: min(850px, calc(100vw - 28px)); }
.editor-body { display: grid; gap: 24px; }
.template-type { display: flex; gap: 3px; width: 100%; padding: 4px; border-radius: 999px; background: var(--fill); }
.template-type button { flex: 1; min-height: 40px; padding: 7px 16px; border-radius: 999px; background: transparent; color: var(--muted); }
.template-type button:hover { color: var(--ink); }
.template-type button.is-active { background: var(--ink); color: #fff; font-weight: 650; }
.editor-media { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: stretch; gap: 16px; }
.media-slot { position: relative; min-height: 230px; overflow: hidden; border: 2px dashed #cbc4ba; border-radius: var(--radius); background: var(--fill); color: var(--muted); text-align: left; cursor: pointer; }
.media-slot.is-target { border-color: var(--brand); box-shadow: 0 0 0 3px rgb(0 204 112 / .15); }
.media-slot.is-disabled { cursor: default; border-color: var(--border); background: var(--fill-strong); color: var(--faint); box-shadow: none; pointer-events: none; }
.media-slot .slot-label { position: absolute; z-index: 1; top: 11px; left: 11px; padding: 3px 8px; border-radius: 999px; color: var(--ink); background: rgb(255 255 255 / .84); font-weight: 650; font-size: 12px; }
.slot-content { position: absolute; left: 16px; right: 16px; bottom: 16px; z-index: 1; display: block; height: auto; text-align: center; font-size: 12px; line-height: 1.5; pointer-events: none; }
.media-slot.is-disabled .slot-content { inset: 0; display: grid; place-items: center; padding: 20px; }
.media-slot img { display: block; width: 100%; height: 230px; object-fit: cover; }
.upload-button { position: absolute; top: 50%; left: 50%; z-index: 2; min-height: 40px; padding: 0 18px; border: 0; border-radius: 999px; background: var(--ink); color: #fff; font-size: 13px; font-weight: 650; transform: translate(-50%, -50%); box-shadow: 0 5px 14px rgb(38 18 8 / .2); }
.upload-button:hover { background: var(--ink-secondary); }
.slot-delete {
  position: absolute; top: 10px; right: 10px; z-index: 3;
  display: grid; place-items: center; width: 36px; height: 36px; padding: 0;
  border-radius: 999px; background: var(--danger-soft); color: var(--danger);
}
.slot-delete svg { width: 18px; height: 18px; }
.slot-delete:hover { background: var(--danger-soft-hover); color: var(--danger-ink-hover); }
.media-hint { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.65; text-align: center; }
.editor-field { display: grid; gap: 8px; }
.editor-field > span { font-weight: 650; font-size: 13px; }
.editor-field input, .editor-field textarea { width: 100%; border: 1px solid var(--border); border-radius: 14px; padding: 11px 14px; background: var(--surface); color: var(--ink); resize: vertical; }
.editor-field input { border-radius: 999px; }
.editor-field input:focus, .editor-field textarea:focus { border-color: var(--brand); outline: 0; box-shadow: 0 0 0 3px rgb(0 204 112 / .1); }
.editor-field.is-invalid input { border-color: var(--danger); }
.field-error { margin: 0; color: var(--danger); font-size: 12px; font-weight: 650; }
.password-field, .code-field { position: relative; display: flex; align-items: center; }
.password-field input { padding-right: 46px; }
.password-toggle {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  display: grid; place-items: center; width: 34px; height: 34px; padding: 0;
  border: 0; border-radius: 999px; background: transparent; color: var(--muted);
}
.password-toggle svg { width: 18px; height: 18px; }
.password-toggle:hover { background: var(--fill); color: var(--ink); }
.code-field { gap: 8px; }
.code-field input { flex: 1; min-width: 0; }
.code-field .button { flex-shrink: 0; min-width: 108px; padding: 0 12px; }
.user-auth-dialog .editor-body,
.login-dialog .dialog-body,
.admin-user-dialog .editor-body,
.admin-account-dialog .editor-body { gap: 16px; }

.asset-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 15px; }
.asset-card { overflow: hidden; padding: 0; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); text-align: left; color: inherit; }
.asset-card:hover { border-color: var(--brand); box-shadow: 0 8px 20px rgb(38 18 8 / .08); }
.asset-card img, .asset-card .asset-empty { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; background: var(--fill); }
.asset-empty { display: grid; place-items: center; color: var(--faint); font-size: 12px; }
.asset-copy { display: block; padding: 10px 12px 12px; }
.asset-copy h3 { overflow: hidden; margin: 5px 0 0; font-size: 13px; white-space: nowrap; text-overflow: ellipsis; }
.asset-kind { font-size: 11px; color: var(--muted); }

.edit-fab { position: fixed; right: 20px; bottom: 20px; z-index: 35; display: grid; place-items: center; width: 56px; height: 56px; padding: 0; border-radius: 50%; background: var(--ink); color: #fff; box-shadow: 0 10px 24px rgb(38 18 8 / .22); }
.edit-fab:hover { background: var(--ink-secondary); }
.edit-fab svg { width: 22px; height: 22px; }
.edit-bar { position: fixed; bottom: 16px; left: 50%; z-index: 35; display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; width: max-content; max-width: calc(100vw - 24px); padding: 10px; border-radius: 999px; background: rgb(251 249 245 / .94); box-shadow: 0 12px 32px rgb(38 18 8 / .12); backdrop-filter: blur(20px) saturate(1.2); transform: translateX(-50%); }
.edit-bar[hidden] { display: none; }
.edit-bar .button:disabled { cursor: default; opacity: .45; }
body.is-editing { padding-bottom: 96px; }
body.is-editing .edit-fab { display: none; }
.file-input { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); }
.toast {
  position: fixed; inset: 0; z-index: 80;
  display: none; place-items: center;
  width: 100vw; height: 100dvh; max-width: none; max-height: none;
  margin: 0; padding: 0; border: 0; overflow: visible;
  background: transparent; color: inherit;
  pointer-events: none; opacity: 0;
  transform: none;
  transition: opacity 160ms ease;
}
.toast.is-visible, .toast:popover-open {
  display: grid; opacity: 1;
}
.toast-message {
  display: block; width: max-content; max-width: min(340px, calc(100vw - 32px));
  padding: 12px 18px; border-radius: 999px;
  background: var(--ink); color: #fff; text-align: center;
  box-shadow: 0 10px 28px rgb(38 18 8 / .22);
}
.lightbox-dialog {
  position: relative; width: auto; max-width: 96vw; max-height: 96vh; padding: 0; border: 0;
  background: transparent; box-shadow: none; overflow: visible;
}
.lightbox-dialog::backdrop { background: rgb(38 18 8 / .82); backdrop-filter: blur(6px); }
.lightbox-dialog img {
  display: block; max-width: 92vw; max-height: 88vh; margin: auto;
  object-fit: contain; border-radius: 14px; background: #1c120c;
}
.lightbox-close { position: absolute; top: 12px; right: 12px; color: #fff; background: rgb(38 18 8 / .55); }
.lightbox-close:hover { background: rgb(38 18 8 / .75); color: #fff; }

.profile-dialog { width: min(760px, calc(100vw - 28px)); }
.profile-dialog .dialog-body { display: grid; gap: 20px; }
.profile-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.profile-user { display: grid; gap: 4px; }
.profile-user strong { font-size: 18px; }
.profile-user span { color: var(--muted); font-size: 13px; }
.profile-tabs { display: flex; flex-wrap: wrap; gap: 3px; padding: 4px; border-radius: 999px; background: var(--fill); }
.profile-tabs button { min-height: 36px; padding: 0 14px; border-radius: 999px; background: transparent; color: var(--muted); font-weight: 650; }
.profile-tabs button.is-active { background: var(--ink); color: #fff; }
.profile-pane { display: grid; gap: 12px; max-height: min(520px, 58vh); overflow: auto; padding: 4px 12px 8px; }
.notice-item, .history-item {
  display: grid; gap: 4px; padding: 14px 16px;
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface);
}
.notice-item.is-unread { border-color: rgb(0 204 112 / .35); background: rgb(0 204 112 / .06); }
.notice-item h3, .history-item h3 { margin: 0; font-size: 14px; }
.notice-item p, .history-item p { margin: 0; color: var(--muted); font-size: 13px; }
.notice-meta { color: var(--faint); font-size: 12px; }
.mini-card-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.mini-card { overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); text-align: left; color: inherit; padding: 0; }
.mini-card img, .mini-card .image-empty { display: block; width: 100%; height: 120px; object-fit: cover; background: var(--fill); }
.mini-card .image-empty { min-height: 120px; font-size: 12px; }
.mini-card-copy { display: grid; gap: 6px; padding: 10px 12px 12px; }
.mini-card-copy h3 { margin: 0; font-size: 14px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }

.page-loading {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px;
  min-height: 430px; color: var(--muted);
}
.page-loading p { margin: 0; font-weight: 650; }
.page-spinner {
  width: 48px;
  height: 48px;
  animation: page-spin .85s linear infinite;
  -webkit-mask-image: conic-gradient(from -8deg, #000 0%, rgb(0 0 0 / .4) 28%, rgb(0 0 0 / 0) 50%, rgb(0 0 0 / 0) 100%);
          mask-image: conic-gradient(from -8deg, #000 0%, rgb(0 0 0 / .4) 28%, rgb(0 0 0 / 0) 50%, rgb(0 0 0 / 0) 100%);
}
.page-spinner circle {
  fill: none;
  stroke: var(--ink);
  stroke-width: 4.5;
  stroke-linecap: round;
  stroke-dasharray: 84 29;
  transform-origin: 24px 24px;
  transform: rotate(-90deg);
}
@keyframes page-spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

@media (max-width: 900px) {
  .header-inner { grid-template-columns: 1fr auto; }
  .main-nav { order: 3; grid-column: 1 / -1; justify-self: center; }
  .service-status { display: none; }
  .card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .asset-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (max-width: 580px) {
  .app-main { padding-top: 24px; }
  .header-actions .button { padding: 8px 10px; }
  .toolbar { align-items: stretch; flex-direction: column; }
  .search-cluster { width: 100%; }
  .search-field { width: 100%; }
  .toolbar-actions { justify-content: space-between; flex-wrap: wrap; }
  .sort-field { flex: 1; }
  .sort-field select { width: 100%; }
  .page-size-field { margin-left: auto; }
  .card-grid, .asset-grid { grid-template-columns: 1fr 1fr; gap: 11px; }
  .case-image img, .image-empty { height: 145px; min-height: 145px; }
  .card-copy { padding: 11px 12px 8px; }
  .card-footer { padding: 0 12px 12px; }
  .update-time { display: none; }
  .detail-visuals, .editor-media { grid-template-columns: 1fr; }
  .detail-image, .detail-image .image-empty { min-height: 240px; height: 240px; }
  .media-slot, .media-slot img { min-height: 180px; height: 180px; }
  .dialog-header, .dialog-footer, .dialog-body { padding: 16px; }
  .dialog-footer { flex-wrap: wrap; }
  .detail-dialog .dialog-footer .button { flex: 1; }
  .edit-bar { gap: 6px; padding: 8px; }
  .edit-bar .button { padding: 8px 10px; font-size: 13px; }
  .mini-card-list { grid-template-columns: 1fr; }
  .admin-row { grid-template-columns: 1fr; }
  .admin-row-actions { justify-content: flex-start; }
  .oauth-row { gap: 6px; }
  .oauth-button { font-size: 12px; gap: 6px; padding: 0 8px; }
}
