:root {
  --canvas: #f4eee3;
  --canvas-deep: #e9dfcf;
  --paper: #fffaf1;
  --paper-soft: #faf4e9;
  --ink: #29241d;
  --ink-soft: #6d6458;
  --line: #d9cdbd;
  --line-light: #e9dfd1;
  --gold: #ad7e2f;
  --gold-dark: #815a1d;
  --gold-pale: #ead6ae;
  --danger: #8b3f35;
  --success: #4f704e;
  --shadow: 0 20px 55px rgba(76, 55, 28, 0.10);
  --shadow-small: 0 10px 30px rgba(76, 55, 28, 0.08);
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --sidebar: 255px;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--canvas); }
body { margin: 0; min-height: 100vh; color: var(--ink); font-family: var(--sans); -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
img, video { display: block; max-width: 100%; }
::selection { background: var(--gold-pale); color: var(--ink); }

.skip-link { position: fixed; top: -100px; left: 18px; z-index: 1000; padding: 12px 16px; background: var(--ink); color: white; }
.skip-link:focus { top: 18px; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 29px 20px 22px; border-right: 1px solid var(--line); background: rgba(250, 245, 236, 0.92); backdrop-filter: blur(18px); z-index: 30; }
.brand { display: flex; align-items: center; gap: 13px; min-width: 0; }
.brand-mark { width: 42px; height: 42px; display: grid; place-items: center; flex: 0 0 auto; border: 1px solid var(--gold); color: var(--gold-dark); font-family: var(--serif); font-size: 24px; background: var(--paper); }
.brand strong { display: block; font-family: var(--serif); font-size: 18px; letter-spacing: .03em; text-transform: uppercase; white-space: nowrap; }
.brand small { display: block; margin-top: 3px; color: var(--ink-soft); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; }
.main-nav { display: grid; gap: 7px; margin-top: 48px; }
.nav-item { display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 13px; border: 1px solid transparent; color: #514a40; font-size: 14px; transition: .18s ease; }
.nav-item:hover { border-color: var(--line); background: rgba(255,255,255,.45); }
.nav-item.active { color: var(--gold-dark); background: #efe1c7; border-color: #e4d0aa; }
.nav-icon { width: 20px; text-align: center; font-family: var(--serif); font-size: 18px; }
.sidebar-user { margin-top: auto; padding-top: 20px; border-top: 1px solid var(--line); display: grid; grid-template-columns: 38px minmax(0,1fr) 34px; gap: 10px; align-items: center; }
.avatar { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; background: var(--ink); color: var(--paper); font-family: var(--serif); }
.sidebar-user-copy { min-width: 0; }
.sidebar-user-copy strong, .sidebar-user-copy small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-user-copy strong { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.sidebar-user-copy small { margin-top: 3px; color: var(--ink-soft); font-size: 10px; }
.icon-button { border: 0; width: 34px; height: 34px; background: transparent; cursor: pointer; color: var(--ink-soft); font-size: 18px; }
.icon-button:hover { color: var(--gold-dark); }

.main-content { min-width: 0; padding: 45px clamp(24px, 4vw, 70px) 72px; background: radial-gradient(circle at 90% 0%, rgba(255,255,255,.58), transparent 30%), var(--canvas); }
.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 30px; margin-bottom: 34px; }
.page-header h1, .section-heading h2, .group-heading h2 { margin: 0; font-family: var(--serif); font-weight: 500; }
.page-header h1 { font-size: clamp(38px, 5vw, 66px); line-height: .98; letter-spacing: -.025em; }
.page-header p:not(.eyebrow) { max-width: 690px; margin: 14px 0 0; color: var(--ink-soft); line-height: 1.65; }
.eyebrow { margin: 0 0 11px; color: var(--gold-dark); font-size: 11px; font-weight: 700; letter-spacing: .17em; text-transform: uppercase; }
.security-pill { display: inline-flex; align-items: center; gap: 8px; padding: 10px 13px; border: 1px solid #d4c6af; background: rgba(255,255,255,.45); color: var(--ink-soft); font-size: 11px; letter-spacing: .04em; white-space: nowrap; }
.security-pill span, .status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 4px rgba(79,112,78,.12); }

.button { display: inline-flex; align-items: center; justify-content: center; min-height: 42px; padding: 0 17px; border: 1px solid transparent; cursor: pointer; font-size: 12px; font-weight: 700; letter-spacing: .045em; transition: .18s ease; }
.button:hover { transform: translateY(-1px); }
.button-gold { color: #fffaf0; background: var(--gold); border-color: var(--gold); box-shadow: 0 8px 22px rgba(173,126,47,.18); }
.button-gold:hover { background: var(--gold-dark); border-color: var(--gold-dark); }
.button-dark { color: white; background: var(--ink); border-color: var(--ink); }
.button-ghost { color: var(--ink); background: transparent; border-color: var(--line); }
.button-danger { color: var(--danger); background: transparent; border-color: rgba(139,63,53,.35); }
.button-large { width: 100%; min-height: 51px; }
.text-link { color: var(--gold-dark); font-weight: 700; font-size: 12px; }
.back-link { color: var(--gold-dark); font-size: 12px; font-weight: 700; }

.message-stack { position: fixed; right: 24px; top: 24px; z-index: 100; width: min(420px, calc(100vw - 48px)); }
.message { padding: 14px 16px; border: 1px solid var(--line); background: var(--paper); box-shadow: var(--shadow-small); font-size: 13px; }
.message.success { border-left: 4px solid var(--success); }
.message.error { border-left: 4px solid var(--danger); }

.filter-panel { margin-bottom: 24px; padding: 18px; border: 1px solid var(--line); background: rgba(255,250,241,.72); box-shadow: var(--shadow-small); }
.search-row { display: flex; gap: 10px; }
.search-field { position: relative; flex: 1; }
.search-field span { position: absolute; left: 15px; top: 50%; transform: translateY(-50%); color: var(--ink-soft); font-size: 20px; }
.search-field input { width: 100%; height: 44px; padding: 0 16px 0 44px; border: 1px solid var(--line); background: var(--paper); color: var(--ink); outline: 0; }
.search-field input:focus, select:focus, input:focus, textarea:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(173,126,47,.12); outline: 0; }
.filter-details { margin-top: 13px; border-top: 1px solid var(--line-light); }
.filter-details summary { cursor: pointer; list-style: none; padding-top: 13px; color: var(--ink-soft); font-size: 12px; font-weight: 700; }
.filter-details summary::-webkit-details-marker { display: none; }
.filter-count { display: inline-grid; place-items: center; width: 21px; height: 21px; margin-left: 5px; border-radius: 50%; background: var(--gold); color: white; }
.filter-grid { display: grid; grid-template-columns: repeat(4, minmax(135px, 1fr)); gap: 14px; padding-top: 17px; }
.filter-grid label, .stack-form label { display: grid; gap: 7px; color: var(--ink-soft); font-size: 11px; font-weight: 700; letter-spacing: .04em; }
.filter-grid select, .filter-grid input, .stack-form input, .stack-form select, .stack-form textarea { width: 100%; min-height: 42px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 0; background: var(--paper); color: var(--ink); }
.filter-grid select { max-width: 100%; }
.filter-footer { margin-top: 15px; text-align: right; }
.result-toolbar, .detail-topbar { display: flex; align-items: center; justify-content: space-between; color: var(--ink-soft); font-size: 12px; }
.result-toolbar { margin: 0 0 18px; padding: 0 2px; }
.result-toolbar p { margin: 0; }

.masonry-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 17px; }
.compact-grid { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.media-card { display: flex; flex-direction: column; min-width: 0; width: 100%; overflow: hidden; border: 1px solid var(--line); background: var(--paper); box-shadow: 0 4px 18px rgba(61,43,19,.045); transition: transform .22s ease, box-shadow .22s ease; }
.media-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-small); }
.media-card-visual { position: relative; display: block; aspect-ratio: 4 / 3; overflow: hidden; background: #d8ccb9; }
.media-card-visual img { display: block; width: 100%; height: 100%; object-fit: cover; transition: transform .45s ease; }
.media-card-visual .video-cover { height: 100%; min-height: 0; }
.media-card:hover .media-card-visual img { transform: scale(1.025); }
.media-type-badge { position: absolute; top: 10px; left: 10px; padding: 6px 8px; background: rgba(35,30,23,.83); color: white; font-size: 9px; letter-spacing: .12em; text-transform: uppercase; backdrop-filter: blur(7px); }
.video-cover { min-height: 270px; display: grid; align-content: center; justify-items: center; gap: 11px; color: #f6ead8; background: radial-gradient(circle at 50% 40%, rgba(184,137,62,.4), transparent 34%), linear-gradient(135deg, #32291e, #17140f); }
.video-cover small { font-size: 10px; letter-spacing: .14em; text-transform: uppercase; }
.play-symbol { width: 58px; height: 58px; display: grid; place-items: center; padding-left: 4px; border: 1px solid rgba(255,255,255,.55); border-radius: 50%; font-size: 19px; }
.media-card-body { padding: 15px 15px 13px; }
.media-card-heading { display: flex; align-items: start; justify-content: space-between; gap: 12px; }
.media-card-heading h3 { margin: 0; min-width: 0; height: 46px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow-wrap: anywhere; font-family: var(--serif); font-size: 20px; font-weight: 500; line-height: 1.15; }
.media-card-heading span { color: var(--ink-soft); font-size: 9px; white-space: nowrap; }
.media-card-body > p { margin: 7px 0 12px; color: var(--ink-soft); font-size: 10px; line-height: 1.45; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.media-card-actions { display: flex; align-items: center; gap: 15px; min-height: 47px; padding-top: 10px; border-top: 1px solid var(--line-light); }
.media-delete-button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-width: 36px; min-height: 36px; border: 1px solid rgba(139,63,53,.35); border-radius: 6px; color: var(--danger); }
.media-card-actions .media-delete-button { margin-left: auto; color: var(--danger); }
.media-delete-button:hover { background: rgba(139,63,53,.08); }
.media-delete-button svg { width: 18px; height: 18px; flex-shrink: 0; }
.delete-confirmation { max-width: 640px; padding: 28px; background: var(--paper); border: 1px solid var(--line); }
.delete-confirmation h1 { font-size: 36px; }
.delete-confirmation p { overflow-wrap: anywhere; }
.media-card-actions a { color: var(--gold-dark); font-size: 10px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.gallery-group { margin-top: 38px; }
.group-heading, .section-heading { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 18px; padding-bottom: 11px; border-bottom: 1px solid var(--line); }
.group-heading h2, .section-heading h2 { font-size: 30px; }
.group-heading span { color: var(--ink-soft); font-size: 11px; }
.section-heading { margin-top: 48px; }
.pagination { display: flex; align-items: center; justify-content: space-between; margin-top: 28px; padding-top: 20px; border-top: 1px solid var(--line); color: var(--ink-soft); font-size: 12px; }
.pagination a { color: var(--gold-dark); font-weight: 700; }
.empty-state { width: 100%; padding: 70px 25px; border: 1px dashed var(--line); background: rgba(255,255,255,.3); text-align: center; break-inside: avoid; }
.empty-state h3 { margin: 9px 0; font-family: var(--serif); font-size: 28px; font-weight: 500; }
.empty-state p { color: var(--ink-soft); }
.empty-symbol { font-family: var(--serif); color: var(--gold); font-size: 38px; }

.metric-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 15px; }
.metric-card { min-height: 178px; padding: 23px; border: 1px solid var(--line); background: var(--paper-soft); }
.metric-card small, .metric-card span { display: block; color: var(--ink-soft); }
.metric-card small { font-size: 10px; letter-spacing: .12em; text-transform: uppercase; }
.metric-card strong { display: block; margin: 25px 0 12px; font-family: var(--serif); font-size: 42px; font-weight: 500; }
.metric-card span { font-size: 11px; }

.detail-topbar { margin-bottom: 18px; }
.lightbox-layout { min-height: calc(100vh - 120px); display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(300px, .6fr); border: 1px solid var(--line); background: var(--paper); box-shadow: var(--shadow); }
.lightbox-stage { position: relative; min-height: 620px; display: grid; place-items: center; overflow: hidden; background: #17140f; }
.lightbox-stage img, .lightbox-stage video { max-width: 100%; max-height: calc(100vh - 130px); width: auto; height: auto; object-fit: contain; }
.lightbox-stage:fullscreen { background: #0d0b09; }
.lightbox-stage:fullscreen img, .lightbox-stage:fullscreen video { max-height: 100vh; }
.stage-arrow { position: absolute; top: 50%; transform: translateY(-50%); width: 46px; height: 46px; display: grid; place-items: center; border-radius: 50%; color: white; background: rgba(255,255,255,.13); backdrop-filter: blur(8px); font-family: var(--serif); font-size: 34px; }
.stage-arrow-left { left: 17px; }
.stage-arrow-right { right: 17px; }
.detail-panel { padding: clamp(25px, 4vw, 52px); display: flex; flex-direction: column; }
.detail-panel h1 { margin: 0; font-family: var(--serif); font-size: clamp(37px, 4vw, 57px); font-weight: 500; line-height: .98; }
.detail-description { margin: 20px 0 0; color: var(--ink-soft); font-family: var(--serif); font-size: 18px; line-height: 1.6; }
.metadata-list { margin: 36px 0 0; border-top: 1px solid var(--line); }
.metadata-list > div { display: grid; grid-template-columns: 120px 1fr; gap: 14px; padding: 13px 0; border-bottom: 1px solid var(--line-light); }
.metadata-list dt { color: var(--ink-soft); font-size: 10px; letter-spacing: .08em; text-transform: uppercase; }
.metadata-list dd { margin: 0; overflow-wrap: anywhere; font-size: 12px; }
.detail-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: auto; padding-top: 35px; }
.danger-zone { margin-top: 18px; color: var(--ink-soft); font-size: 11px; }
.danger-zone summary { cursor: pointer; }
.danger-zone form { margin-top: 10px; }

.catalog-list { border-top: 1px solid var(--line); }
.catalog-row { display: flex; justify-content: space-between; gap: 30px; padding: 23px 8px; border-bottom: 1px solid var(--line); transition: background .18s; }
.catalog-row:hover { background: rgba(255,255,255,.42); }
.catalog-row > div:first-child { display: flex; align-items: center; gap: 25px; }
.catalog-index { color: var(--gold); font-family: var(--serif); font-size: 19px; }
.catalog-row h2 { margin: 0; font-family: var(--serif); font-size: 26px; font-weight: 500; }
.catalog-row p { margin: 5px 0 0; color: var(--ink-soft); font-size: 11px; }
.catalog-counts { display: flex; align-items: center; gap: 22px; color: var(--ink-soft); font-size: 11px; }
.catalog-counts strong { min-width: 45px; text-align: right; color: var(--ink); font-family: var(--serif); font-size: 26px; font-weight: 500; }
.category-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.category-card { position: relative; min-height: 220px; padding: 25px; border: 1px solid var(--line); background: var(--paper-soft); overflow: hidden; }
.category-card::after { content: ""; position: absolute; width: 140px; height: 140px; right: -55px; bottom: -55px; border: 1px solid var(--gold-pale); border-radius: 50%; }
.category-card > span { color: var(--gold); font-family: var(--serif); }
.category-card h2 { margin: 55px 0 7px; font-family: var(--serif); font-size: 30px; font-weight: 500; }
.category-card p { color: var(--ink-soft); font-size: 11px; }
.category-card i { position: absolute; right: 23px; top: 22px; font-style: normal; color: var(--gold-dark); }

.settings-grid { display: grid; grid-template-columns: 1.1fr 1fr 1fr; gap: 16px; }
.settings-card { position: relative; min-height: 290px; padding: 27px; border: 1px solid var(--line); background: var(--paper-soft); }
.settings-card.featured { background: var(--ink); color: var(--paper); }
.settings-card h2 { margin: 12px 0 25px; font-family: var(--serif); font-size: 31px; font-weight: 500; }
.settings-card p:not(.eyebrow) { color: var(--ink-soft); line-height: 1.7; }
.settings-card.featured p:not(.eyebrow), .settings-card.featured dt { color: #bfb4a4; }
.settings-card dl { margin: 0; }
.settings-card dl div { display: flex; justify-content: space-between; gap: 18px; padding: 12px 0; border-top: 1px solid rgba(215,203,185,.35); }
.settings-card dt { color: var(--ink-soft); font-size: 11px; }
.settings-card dd { margin: 0; text-align: right; font-size: 11px; font-weight: 700; }
.status-dot { position: absolute; right: 25px; top: 25px; background: var(--danger); }
.status-dot.online { background: #7da27a; }
.notice-panel { margin-top: 20px; padding: 21px 24px; border-left: 3px solid var(--gold); background: rgba(255,255,255,.42); }
.notice-panel p { margin: 7px 0 0; color: var(--ink-soft); line-height: 1.6; }
code { padding: 2px 5px; background: rgba(173,126,47,.12); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .9em; }

.table-card, .form-card { border: 1px solid var(--line); background: var(--paper); box-shadow: var(--shadow-small); }
.table-card { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 15px 17px; border-bottom: 1px solid var(--line-light); text-align: left; font-size: 12px; }
th { color: var(--ink-soft); font-size: 9px; letter-spacing: .11em; text-transform: uppercase; }
td strong, td small { display: block; }
td small { margin-top: 4px; color: var(--ink-soft); }
.status-label { display: inline-block; padding: 5px 8px; border: 1px solid var(--line); color: var(--ink-soft); font-size: 9px; text-transform: uppercase; }
.status-label.active { border-color: rgba(79,112,78,.4); color: var(--success); }
.form-card { width: min(700px, 100%); padding: 30px; }
.stack-form { display: grid; gap: 11px; }
.stack-form ul { margin: 0; padding-left: 20px; color: var(--ink-soft); font-size: 11px; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.form-error, .field-error { color: var(--danger); font-size: 11px; }

.login-body { min-height: 100vh; background: var(--canvas); }
.login-shell { min-height: 100vh; display: grid; grid-template-columns: minmax(380px, 1.1fr) minmax(420px, .9fr); }
.login-art { position: relative; display: grid; place-items: center; padding: 50px; overflow: hidden; background: radial-gradient(circle at 70% 20%, rgba(201,155,80,.45), transparent 30%), linear-gradient(145deg, #31271c, #17130e); }
.login-art::before, .login-art::after { content: ""; position: absolute; border: 1px solid rgba(232,210,171,.24); border-radius: 50%; }
.login-art::before { width: 580px; height: 580px; left: -180px; bottom: -240px; }
.login-art::after { width: 310px; height: 310px; right: -80px; top: -100px; }
.login-art-frame { position: relative; z-index: 1; width: min(520px, 100%); min-height: 560px; display: flex; flex-direction: column; justify-content: flex-end; padding: 48px; border: 1px solid rgba(238,217,180,.4); color: #f8ead5; }
.login-art-frame span { margin-bottom: 16px; font-size: 10px; letter-spacing: .2em; text-transform: uppercase; }
.login-art-frame strong { font-family: var(--serif); font-size: clamp(47px, 6vw, 78px); font-weight: 400; line-height: .95; }
.login-card { display: flex; flex-direction: column; justify-content: center; width: min(520px, 100%); margin: 0 auto; padding: 60px; }
.login-brand { margin-bottom: 80px; }
.login-heading h1 { margin: 0; font-family: var(--serif); font-size: 55px; font-weight: 500; }
.login-heading > p:not(.eyebrow) { margin: 11px 0 34px; color: var(--ink-soft); line-height: 1.6; }
.login-note { margin-top: 24px; color: var(--ink-soft); font-size: 10px; text-align: center; }

@media (max-width: 1180px) {
  :root { --sidebar: 220px; }
  .filter-grid { grid-template-columns: repeat(2, 1fr); }
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .settings-grid { grid-template-columns: 1fr 1fr; }
  .settings-card:last-child { grid-column: 1 / -1; }
  .lightbox-layout { grid-template-columns: 1fr; }
  .lightbox-stage { min-height: 520px; }
  .detail-panel { min-height: 480px; }
}

@media (max-width: 820px) {
  .app-shell { display: block; }
  .sidebar { position: relative; width: 100%; height: auto; padding: 18px; border-right: 0; border-bottom: 1px solid var(--line); }
  .main-nav { display: flex; overflow-x: auto; margin-top: 18px; padding-bottom: 5px; }
  .nav-item { flex: 0 0 auto; }
  .sidebar-user { display: none; }
  .main-content { padding: 30px 18px 55px; }
  .page-header { display: block; }
  .page-header > .button, .security-pill { margin-top: 20px; }
  .search-row { flex-wrap: wrap; }
  .search-field { flex: 1 0 100%; }
  .filter-grid { grid-template-columns: 1fr; }
  .category-grid, .settings-grid { grid-template-columns: 1fr; }
  .settings-card:last-child { grid-column: auto; }
  .catalog-row { display: block; }
  .catalog-counts { margin: 18px 0 0 55px; }
  .login-shell { display: block; }
  .login-art { display: none; }
  .login-card { min-height: 100vh; padding: 35px 24px; }
  .login-brand { margin-bottom: 65px; }
}

@media (max-width: 540px) {
  .page-header h1 { font-size: 44px; }
  .metric-grid { grid-template-columns: 1fr; }
  .search-row .button { flex: 1; }
  .masonry-grid, .compact-grid { grid-template-columns: minmax(0, 1fr); }
  .detail-actions { grid-template-columns: 1fr; }
  .metadata-list > div { grid-template-columns: 95px 1fr; }
  .catalog-counts span { display: none; }
}

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