@font-face {
  font-family: Manrope; font-weight: 400 800; font-display: swap;
  src: url('/assets/manrope-latin.woff2') format('woff2');
}
@font-face {
  font-family: Manrope; font-weight: 400 800; font-display: swap;
  src: url('/assets/manrope-cyrillic.woff2') format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

:root {
  font-family: Manrope, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color-scheme: light;
  --bg: #f7f7fb;
  --paper: #fff;
  --ink: #211f35;
  --muted: #65637b;
  --subtle: #737187;
  --line: #eae8f2;
  --line-strong: #e3e0ed;
  --brand: #5943df;
  --brand-strong: #4934c9;
  --lavender: #f1edff;
  --lavender-deep: #e6defc;
  --green: #16694e;
  --green-bg: #e7f5ee;
  --red: #a23852;
  --red-bg: #faedf1;
  --amber: #845816;
  --amber-bg: #fdf3dd;
  --shadow: 0 2px 9px rgb(35 27 68 / 4%);
}

:root[data-theme='dark'] {
  color-scheme: dark;
  --bg: #171623;
  --paper: #201f2f;
  --ink: #f7f3ff;
  --muted: #c0b9d3;
  --subtle: #aaa3bf;
  --line: #343147;
  --line-strong: #423e56;
  --brand: #b5a4ff;
  --brand-strong: #a48dfb;
  --lavender: #302846;
  --lavender-deep: #4b3c6e;
  --green: #a0edd0;
  --green-bg: #1d3a36;
  --red: #ffadc1;
  --red-bg: #402938;
  --amber: #f2c985;
  --amber-bg: #403321;
  --shadow: none;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--ink); }
button, textarea { font: inherit; }
button { border: 0; color: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; }
button:disabled { cursor: default; }
button:focus-visible, textarea:focus-visible { outline: 3px solid var(--brand); outline-offset: 3px; }
h1, h2, p { margin: 0; }
svg { display: block; width: 18px; height: 18px; flex: 0 0 auto; }
[data-icon] { display: inline-grid; place-items: center; }

.appbar { background: var(--paper); border-bottom: 1px solid var(--line); }
.bar-inner, .shell { width: min(100% - 56px, 1140px); margin-inline: auto; }
.bar-inner { height: 68px; display: flex; justify-content: space-between; align-items: center; }
.brand, .bar-actions { display: flex; align-items: center; }
.brand { gap: 10px; font-size: 21px; font-weight: 800; letter-spacing: -.07em; }
.brand-muted { color: var(--brand); }
.brand-icon {
  width: 36px; height: 36px; border-radius: 12px; color: #fff;
  background: linear-gradient(145deg, #7862ff, #5139d4); box-shadow: 0 4px 9px rgb(88 66 223 / 22%);
}
.brand-icon svg { width: 19px; height: 19px; }
.bar-actions { gap: 12px; }
.environment { color: var(--brand); background: var(--lavender); border-radius: 100px; padding: 6px 10px; font-size: 11px; font-weight: 800; display: flex; align-items: center; gap: 6px; }
.environment > span:first-child { width: 6px; height: 6px; border-radius: 50%; background: var(--brand); }
.icon-button { width: 40px; height: 40px; display: inline-grid; place-items: center; background: var(--paper); border: 1px solid var(--line-strong); border-radius: 12px; color: var(--muted); }
.icon-button:hover { color: var(--brand); border-color: var(--brand); }
.icon-button:disabled { opacity: .5; }
.refresh.loading svg { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.shell { padding-block: 32px 64px; }
.intro { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 27px; }
.intro h1 { font-size: clamp(34px, 5vw, 48px); font-weight: 800; line-height: 1.05; letter-spacing: -.075em; }
.route, .route-source, .route-target { display: flex; align-items: center; }
.route { gap: 10px; margin-top: 13px; font-size: 13px; color: var(--muted); font-weight: 700; flex-wrap: wrap; }
.route-source, .route-target { gap: 6px; }
.route-target > [data-icon] { color: #408ebf; }
.route-target svg, .route-arrow svg { width: 15px; height: 15px; }
.route-arrow { color: var(--subtle); }
.source-logo { display: grid; place-items: center; width: 17px; height: 17px; background: #dceeff; color: #155ab1; border-radius: 5px; font-size: 11px; font-weight: 800; }
.workspace { display: grid; grid-template-columns: minmax(285px, 340px) minmax(0, 1fr); gap: 22px; align-items: start; }
.panel { background: var(--paper); border: 1px solid var(--line); border-radius: 22px; box-shadow: var(--shadow); min-width: 0; }
.queue { padding: 19px 12px 12px; }
.queue-head { padding: 0 8px 12px; }
.queue h2 { font-size: 20px; font-weight: 800; letter-spacing: -.045em; margin-bottom: 13px; }
.queue-summary { white-space: nowrap; background: var(--lavender); color: var(--brand); border-radius: 9px; padding: 8px 9px; font-size: 11px; font-weight: 800; }
.queue-summary span:not(:empty) { margin-left: 3px; }
.queue-list { display: flex; flex-direction: column; gap: 4px; }
.queue-item { width: 100%; min-height: 72px; background: transparent; text-align: left; padding: 9px; display: grid; grid-template-columns: 54px minmax(0, 1fr) 14px; align-items: center; gap: 10px; border-radius: 13px; border: 1px solid transparent; }
.queue-item:hover { background: var(--bg); }
.queue-item[aria-current='true'] { background: var(--lavender); border-color: var(--lavender-deep); }
.thumb { width: 54px; height: 50px; border-radius: 10px; overflow: hidden; display: grid; place-items: center; color: var(--brand); background: var(--lavender-deep); }
.thumb img { display: block; width: 100%; height: 100%; min-height: 0; object-fit: cover; }
.queue-info { min-width: 0; display: grid; gap: 5px; }
.queue-title { color: var(--ink); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 13px; font-weight: 800; }
.queue-meta { color: var(--subtle); font-size: 10.5px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.queue-arrow { color: var(--subtle); }
.queue-arrow svg { width: 14px; height: 14px; }
.queue-item[aria-current='true'] .queue-arrow { color: var(--brand); }
.queue-empty { color: var(--muted); line-height: 1.55; font-size: 13px; padding: 17px 9px 20px; }
.load-more { margin: 10px 8px; }

.editor { min-height: 373px; }
.editor-empty { min-height: 372px; display: grid; justify-items: center; align-content: center; gap: 10px; padding: 24px; text-align: center; }
.empty-icon, .dialog-icon { width: 52px; height: 52px; border-radius: 17px; background: var(--lavender); color: var(--brand); }
.empty-icon svg, .dialog-icon svg { width: 23px; height: 23px; }
.editor-empty h2 { margin-top: 5px; font-size: 20px; letter-spacing: -.04em; }
.editor-empty p { color: var(--muted); font-size: 13px; }
.editor-head { padding: 21px 23px 15px; }
.detail-meta { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.status { display: inline-flex; align-items: center; gap: 6px; min-height: 24px; border-radius: 100px; padding: 4px 9px; font-size: 10.5px; font-weight: 800; color: var(--brand); background: var(--lavender); }
.status::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status.published { color: var(--green); background: var(--green-bg); }
.status.discarded { color: var(--red); background: var(--red-bg); }
.status.uncertain, .status.publishing { color: var(--amber); background: var(--amber-bg); }
.detail-id { color: var(--subtle); font-size: 11px; font-weight: 700; }
.editor-head h2 { font-size: clamp(23px, 3vw, 33px); font-weight: 800; line-height: 1.15; letter-spacing: -.062em; overflow-wrap: anywhere; }
.back { display: none !important; }

.gallery { display: grid; grid-template-columns: minmax(0, 1fr) 115px; gap: 8px; height: clamp(180px, 22vw, 259px); margin: 0 23px 19px; }
.gallery.single { grid-template-columns: 1fr; }
.gallery-side { display: grid; grid-auto-rows: minmax(0, 1fr); gap: 8px; min-height: 0; }
.gallery-shot { position: relative; display: grid; place-items: center; background: var(--lavender); color: var(--brand); text-align: left; min-width: 0; min-height: 0; padding: 0; overflow: hidden; border-radius: 13px; }
.gallery-shot img { display: block; width: 100%; height: 100%; object-fit: cover; transition: transform .22s ease; }
.gallery-shot:first-child img { object-position: center 52%; }
.gallery-shot:hover img { transform: scale(1.035); }
.gallery-label { position: absolute; bottom: 10px; left: 10px; display: flex; align-items: center; gap: 6px; padding: 6px 8px; border-radius: 8px; background: rgb(22 19 34 / 74%); color: #fff; font-size: 11px; font-weight: 800; }
.gallery-label svg { width: 15px; height: 15px; }
.gallery-more { position: absolute; inset: 0; background: rgb(22 19 34 / 48%); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 19px; }

.text-area { padding: 0 23px 15px; }
.original-block { margin: 0 23px 15px; padding: 11px 13px; border: 1px solid var(--line-strong); border-radius: 12px; }
.original-block summary { color: var(--ink); cursor: pointer; font-size: 14px; font-weight: 800; }
.original-block pre { max-height: 300px; overflow: auto; margin: 10px 0 0; font: inherit; font-size: 13px; line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--muted); }
.field-label, .field-foot { display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.field-label { margin-bottom: 8px; }
.field-label label { font-size: 14px; font-weight: 800; }
.edit-indicator { font-size: 10px; color: var(--amber); background: var(--amber-bg); padding: 4px 7px; border-radius: 100px; font-weight: 800; }
textarea { display: block; width: 100%; min-height: 153px; resize: vertical; background: var(--bg); border: 1px solid var(--line-strong); border-radius: 12px; padding: 11px 13px; color: var(--ink); font-size: 13.5px; line-height: 1.6; }
textarea[readonly] { resize: none; }
.field-foot { margin-top: 7px; font-size: 10.5px; font-weight: 700; color: var(--subtle); }
#counter { flex-shrink: 0; }
.action-notice { margin: 0 23px 17px; border-radius: 11px; padding: 10px 12px; background: var(--amber-bg); color: var(--amber); font-size: 12px; font-weight: 700; }
.editor-actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 23px; border-top: 1px solid var(--line); }
.primary-actions { display: flex; align-items: center; gap: 8px; }
.button { min-height: 39px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 8px 13px; border-radius: 11px; font-size: 12px; line-height: 1.15; font-weight: 800; white-space: nowrap; transition: background .17s, border-color .17s, color .17s; }
.button svg { width: 15px; height: 15px; }
.button.secondary { background: var(--paper); color: var(--ink); border: 1px solid var(--line-strong); }
.button.secondary:hover:not(:disabled) { border-color: var(--brand); color: var(--brand); }
.button.primary { background: #5943df; color: #fff; border: 1px solid transparent; box-shadow: 0 3px 7px rgb(89 67 223 / 22%); }
.button.primary:hover:not(:disabled) { background: #4731c6; }
.button.danger { color: var(--red); background: var(--paper); padding-inline: 6px; }
.button.danger:hover:not(:disabled) { background: var(--red-bg); }
.button.plain { color: var(--brand); background: transparent; }
.button:disabled { opacity: .46; box-shadow: none; }

.toast { position: fixed; left: 50%; translate: -50% 0; bottom: max(18px, env(safe-area-inset-bottom)); z-index: 5; max-width: min(92vw, 500px); padding: 12px 16px; border-radius: 12px; background: #211b37; color: #fff; box-shadow: 0 8px 25px rgb(16 12 35 / 23%); font-size: 13px; font-weight: 700; }
.toast.error { background: #74283d; }
.dialog { width: min(414px, 100% - 32px); background: var(--paper); color: var(--ink); border: 1px solid var(--line); border-radius: 21px; padding: 23px; box-shadow: 0 20px 70px rgb(23 18 60 / 25%); }
.dialog::backdrop, .viewer::backdrop { background: rgb(22 18 40 / 56%); }
.dialog h2 { font-size: 22px; letter-spacing: -.05em; margin: 11px 0 7px; }
.dialog p { font-size: 13px; color: var(--muted); line-height: 1.6; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 7px; margin-top: 19px; }
.dialog.reject .dialog-icon { background: var(--red-bg); color: var(--red); }
.dialog.reject .primary { background: #a13951; }
.photo-actions { display: flex; justify-content: flex-end; margin: -7px 23px 16px; }
.move-dialog { width: min(510px, 100% - 28px); max-height: calc(100% - 28px); overflow: auto; }
.move-selection { display: flex; align-items: center; justify-content: space-between; font-size: 13px; color: var(--muted); }
.move-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(67px, 1fr)); gap: 8px; max-height: 30vh; overflow-y: auto; padding: 3px; }
.move-shot { display: grid; position: relative; cursor: pointer; }
.move-thumb { aspect-ratio: 1; display: grid; place-items: center; background: var(--lavender); color: var(--brand); border-radius: 10px; overflow: hidden; }
.move-thumb img { width: 100%; height: 100%; object-fit: cover; }
.move-thumb svg { width: 22px; height: 22px; }
.move-shot input { position: absolute; z-index: 1; margin: 5px; width: 21px; height: 21px; accent-color: var(--brand); }
.move-shot input:checked + .move-thumb { outline: 2px solid var(--brand); outline-offset: 1px; }
.move-label { display: block; margin: 16px 0 7px; font-size: 13px; font-weight: 750; }
.move-dialog select { display: block; width: 100%; min-height: 42px; padding: 8px; border: 1px solid var(--line-strong); border-radius: 10px; color: var(--ink); background: var(--paper); font: inherit; text-overflow: ellipsis; }
.move-dialog #move-message { margin: 8px 0 0; }
.viewer { position: fixed; padding: 12px; border: none; background: transparent; color: white; width: min(93vw, 950px); max-width: none; max-height: 95vh; overflow: visible; }
.viewer[open] { display: grid; grid-template-columns: 40px minmax(0, 1fr) 40px; align-items: center; gap: 8px; }
.viewer[open] :is(#viewer-image, #viewer-video) { width: 100%; max-height: 81vh; object-fit: contain; border-radius: 12px; grid-area: 1 / 2; }
.viewer .icon-button { border: 0; background: rgb(255 255 255 / 15%); color: white; }
.viewer-close { position: absolute; z-index: 1; right: 8px; top: 8px; }
.viewer-prev { grid-area: 1 / 1; }
.viewer-next { grid-area: 1 / 3; }
#viewer-counter { grid-column: 2; text-align: center; font-size: 12px; }

@media (max-width: 880px) and (min-width: 761px) {
  .bar-inner, .shell { width: calc(100% - 32px); }
  .workspace { grid-template-columns: 283px minmax(0, 1fr); gap: 13px; }
}

@media (max-width: 760px) {
  .bar-inner, .shell { width: calc(100% - 32px); }
  .bar-inner { height: 56px; }
  .brand { font-size: 19px; gap: 8px; }
  .brand-icon { width: 32px; height: 32px; border-radius: 10px; }
  .brand-icon svg { width: 17px; height: 17px; }
  .icon-button { width: 36px; height: 36px; }
  .shell { padding: 24px 0 32px; }
  .intro { margin-bottom: 16px; gap: 10px; align-items: flex-start; }
  .intro h1 { font-size: 34px; }
  .route { font-size: 11px; margin-top: 9px; gap: 7px; }
  .test-button { width: 38px; height: 38px; min-height: 38px; font-size: 0; padding: 0; flex: 0 0 auto; }
  .test-button svg { width: 18px; height: 18px; }
  .workspace { display: block; }
  .queue { border-radius: 17px; padding: 14px 9px 9px; }
  .queue h2 { margin-bottom: 8px; }
  .queue-item { min-height: 71px; grid-template-columns: 54px minmax(0, 1fr) 18px; }
  .queue-title { font-size: 14px; }
  .queue-meta { font-size: 11px; }
  .editor { display: none; }
  .compact-detail .intro, .compact-detail .queue { display: none; }
  .compact-detail .shell { width: 100%; padding-top: 0; padding-bottom: 90px; }
  .compact-detail .editor { display: block; border: 0; border-radius: 0; box-shadow: none; min-height: calc(100svh - 146px); }
  .back { display: inline-flex !important; padding-inline: 0; min-height: 35px; margin-bottom: 8px; }
  .editor-head { padding: 9px 16px 13px; }
  .editor-head h2 { font-size: clamp(24px, 7vw, 32px); }
  .gallery { margin: 0 16px 17px; grid-template-columns: minmax(0, 1fr) 72px; gap: 5px; height: clamp(145px, 48vw, 245px); }
  .gallery-side { gap: 5px; }
  .photo-actions { margin-inline: 16px; }
  .gallery-shot { border-radius: 10px; }
  .text-area { padding: 0 16px 15px; }
  .original-block { margin-inline: 16px; }
  .action-notice { margin-inline: 16px; }
  textarea { font-size: 16px; min-height: 173px; }
  .editor-actions { position: fixed; z-index: 2; inset: auto 0 0; background: var(--paper); padding: 10px 10px max(10px, env(safe-area-inset-bottom)); gap: 3px; }
  .editor-actions .button { min-height: 43px; font-size: 11px; padding-inline: 8px; }
  .editor-actions .button svg { width: 13px; height: 13px; }
  .primary-actions { gap: 4px; }
  .toast { bottom: max(68px, calc(env(safe-area-inset-bottom) + 62px)); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
