:root {
  color-scheme: light;
  --ink: #24231f;
  --muted: #77736b;
  --paper: #f2eee5;
  --card: #fffdf8;
  --line: #dcd5c8;
  --accent: #b64830;
  --accent-dark: #8e3422;
  --soft-accent: #f7e5dc;
  --ok: #2f7553;
  --warn: #9a641f;
  --danger: #a1342e;
  --shadow: 0 28px 85px rgba(62, 51, 37, .09);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 16% -4%, rgba(182, 72, 48, .15), transparent 31rem),
    linear-gradient(180deg, #f6f2e9 0, var(--paper) 55%, #ece7dc 100%);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button, input, select { font: inherit; }
button { color: inherit; }

.shell { width: min(1080px, calc(100% - 32px)); margin: 0 auto; padding: 24px 0 48px; }
.step { margin: 0; color: var(--accent); font-size: 11px; font-weight: 850; letter-spacing: .18em; }

.workspace { overflow: hidden; border: 1px solid var(--line); border-radius: 26px; background: rgba(255, 253, 248, .94); box-shadow: var(--shadow); backdrop-filter: blur(12px); }
.tabs { display: flex; gap: 6px; padding: 8px; border-bottom: 1px solid var(--line); background: rgba(238, 233, 222, .65); }
.tab { min-height: 46px; padding: 0 18px; border: 0; border-radius: 12px; background: transparent; color: var(--muted); font-weight: 760; cursor: pointer; }
.tab:hover { color: var(--ink); background: rgba(255,255,255,.55); }
.tab.active { color: var(--ink); background: var(--card); box-shadow: 0 3px 12px rgba(62, 51, 37, .08); }
.count { display: inline-grid; min-width: 22px; height: 22px; margin-left: 6px; padding: 0 6px; place-items: center; border-radius: 999px; background: var(--soft-accent); color: var(--accent-dark); font-size: 11px; }

.session-bar { display: flex; justify-content: space-between; gap: 16px; padding: 11px clamp(22px, 5vw, 46px); border-bottom: 1px solid var(--line); background: #fbf6ec; color: var(--muted); font-size: 13px; }
.session-bar strong { color: var(--ink); }
.text-button { padding: 0; border: 0; background: none; color: var(--accent); font-weight: 750; cursor: pointer; }
.text-button:hover { color: var(--accent-dark); }

.panel { padding: clamp(24px, 5vw, 48px); }
.panel-heading, .library-heading { display: flex; justify-content: space-between; align-items: end; gap: 28px; margin-bottom: 28px; }
.panel h2 { margin: 7px 0 0; font-family: Georgia, "Times New Roman", serif; font-size: clamp(28px, 4vw, 39px); font-weight: 500; letter-spacing: -.028em; }
.panel-note { max-width: 390px; margin: 0; color: var(--muted); font-size: 13px; line-height: 1.55; }

form { display: grid; grid-template-columns: 1fr 1.35fr; gap: 20px; }
label > span, .filters label > span { display: block; margin: 0 0 8px; color: #4c4943; font-size: 12px; font-weight: 780; }
input, select { width: 100%; min-height: 52px; border: 1px solid var(--line); border-radius: 12px; background: #fff; padding: 0 14px; color: var(--ink); }
input:focus, select:focus { outline: 3px solid rgba(182, 72, 48, .14); border-color: var(--accent); }
input[readonly] { background: #f4f0e8; color: var(--muted); }

.dropzone { grid-column: 1 / -1; min-height: 205px; display: grid; place-content: center; justify-items: center; text-align: center; border: 1.5px dashed #b8afa2; border-radius: 19px; background: #faf7f0; cursor: pointer; transition: .2s ease; }
.dropzone:hover, .dropzone.drag { border-color: var(--accent); background: #fff8f2; transform: translateY(-1px); }
.dropzone input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.drop-icon { display: grid; width: 42px; height: 42px; margin-bottom: 12px; place-items: center; border-radius: 50%; background: var(--soft-accent); color: var(--accent); font-size: 26px; line-height: 1; }
.dropzone strong { color: var(--accent); font-size: 18px; }
.dropzone small { margin-top: 7px; color: var(--muted); }

.primary-button, .secondary-button { min-height: 50px; border-radius: 12px; font-weight: 820; cursor: pointer; transition: .15s ease; }
.primary-button { grid-column: 1 / -1; border: 0; background: var(--accent); color: #fff; }
.primary-button:hover { background: var(--accent-dark); }
.primary-button:disabled { opacity: .46; cursor: wait; }
.secondary-button { padding: 0 17px; border: 1px solid var(--line); background: #fff; }
.secondary-button:hover { border-color: #bdb4a6; background: #faf7f0; }

.message { min-height: 24px; margin-top: 18px; color: var(--muted); }
.message.error { color: var(--danger); }
.message.success { color: var(--ok); }
.workspace-message { min-height: 0; margin: 0; padding: 13px clamp(22px, 5vw, 46px); border-bottom: 1px solid var(--line); background: #faf7f0; }
.workspace-message:empty { display: none; }
.queue { display: grid; gap: 12px; margin-top: 14px; }
.job { padding: 14px; border: 1px solid var(--line); border-radius: 13px; background: #fff; }
.job-head { display: flex; justify-content: space-between; gap: 16px; margin-bottom: 10px; font-size: 13px; }
.job-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 730; }
.job-state { flex: 0 0 auto; color: var(--muted); }
.job.done .job-state { color: var(--ok); font-weight: 800; }
.bar { height: 7px; overflow: hidden; border-radius: 999px; background: #ece7dd; }
.bar > i { display: block; height: 100%; width: 0; border-radius: inherit; background: var(--accent); transition: width .2s ease; }

.library-heading { align-items: center; }
.filters { display: grid; grid-template-columns: minmax(180px, 1fr) minmax(180px, 1fr); gap: 14px; margin-bottom: 24px; }
.filters select { min-height: 44px; }
.empty-library { display: grid; justify-items: center; padding: 58px 20px 48px; text-align: center; border: 1px dashed var(--line); border-radius: 18px; color: var(--muted); }
.empty-library > span { display: grid; width: 50px; height: 50px; place-items: center; border-radius: 50%; background: #f3eee5; color: var(--accent); font-size: 25px; }
.empty-library h3 { margin: 14px 0 5px; color: var(--ink); font-family: Georgia, "Times New Roman", serif; font-size: 25px; font-weight: 500; }
.empty-library p { margin: 0 0 18px; }
.library-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 17px; }
.media-card { overflow: hidden; border: 1px solid var(--line); border-radius: 17px; background: #fff; box-shadow: 0 9px 28px rgba(57, 49, 39, .055); }
.media-preview { position: relative; width: 100%; aspect-ratio: 4 / 3; display: grid; place-items: center; overflow: hidden; border: 0; background: #ebe5da; cursor: pointer; }
.media-preview img { width: 100%; height: 100%; object-fit: cover; transition: transform .25s ease; }
.media-preview:hover img { transform: scale(1.025); }
.media-fallback { color: #9a9185; font-size: 38px; }
.type-chip { position: absolute; top: 10px; right: 10px; padding: 5px 8px; border-radius: 999px; background: rgba(27, 25, 22, .76); color: #fff; font-size: 10px; font-weight: 800; letter-spacing: .06em; }
.media-body { padding: 14px; }
.status-line { display: flex; align-items: center; gap: 7px; margin-bottom: 9px; color: var(--muted); font-size: 11px; font-weight: 760; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: #9c9589; }
.status-review .status-dot { background: var(--warn); }
.status-uploaded .status-dot { background: var(--ok); }
.status-error .status-dot { background: var(--danger); }
.media-name { margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.media-meta { margin: 7px 0 12px; color: var(--muted); font-size: 11px; line-height: 1.45; }
.card-error { margin: 8px 0 12px; color: var(--danger); font-size: 11px; line-height: 1.45; overflow-wrap: anywhere; }
.delete-reason { width: 100%; margin: 2px 0 0; color: var(--muted); font-size: 10px; line-height: 1.4; }
.card-actions { display: flex; flex-wrap: wrap; gap: 7px; }
.card-actions button { min-height: 40px; padding: 0 11px; border: 1px solid var(--line); border-radius: 9px; background: #faf8f3; font-size: 11px; font-weight: 760; cursor: pointer; }
.card-actions button:hover { border-color: #bdb3a4; background: #fff; }
.card-actions button:disabled { opacity: .58; cursor: not-allowed; }
.card-actions .danger { color: var(--danger); }
.countdown { margin-top: 8px; color: var(--warn); font-size: 11px; }

.preview-dialog { width: min(900px, calc(100% - 24px)); max-height: calc(100vh - 24px); padding: 0; overflow: auto; border: 0; border-radius: 20px; background: #171613; color: #fff; box-shadow: 0 40px 120px rgba(0,0,0,.45); }
.preview-dialog::backdrop { background: rgba(26, 23, 19, .72); backdrop-filter: blur(7px); }
.dialog-close { position: sticky; z-index: 2; top: 12px; float: right; width: 40px; height: 40px; margin: 12px 12px -52px 0; border: 0; border-radius: 50%; background: rgba(255,255,255,.13); color: #fff; font-size: 26px; cursor: pointer; }
.preview-media { min-height: 320px; display: grid; place-items: center; background: #0f0e0c; }
.preview-media img, .preview-media video { display: block; max-width: 100%; max-height: 72vh; }
.preview-placeholder { color: #aaa39a; text-align: center; }
.preview-copy { padding: 18px 22px 22px; }
.preview-copy h2 { margin: 0 0 6px; font-size: 18px; }
.preview-copy p { margin: 0; color: #aaa39a; font-size: 12px; }

@media (max-width: 780px) {
  .shell { padding-top: 20px; }
  .panel-heading, .library-heading { align-items: start; flex-direction: column; }
  .library-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 560px) {
  .shell { width: min(100% - 20px, 1080px); padding-top: 12px; }
  .tabs { overflow-x: auto; }
  .tab { flex: 1 0 auto; padding: 0 12px; }
  .session-bar { align-items: start; flex-direction: column; gap: 5px; }
  form, .filters { grid-template-columns: 1fr; }
  .dropzone, .primary-button { grid-column: 1; }
  .dropzone { min-height: 175px; }
  .library-grid { grid-template-columns: 1fr; }
}
