:root {
  --bg-top: #f4f5f7;
  --bg-mid: #eceff2;
  --bg-bottom: #f8f9fb;
  --glass: rgba(255, 255, 255, 0.78);
  --glass-strong: rgba(255, 255, 255, 0.9);
  --line: rgba(118, 126, 136, 0.24);
  --line-strong: rgba(118, 126, 136, 0.45);
  --ink: #1f242b;
  --ink-soft: #616a75;
  --primary: #69b7ee;
  --primary-strong: #3b98d8;
  --accent: #9fd5f7;
  --danger: #cb4a63;
  --success: #1e8f64;
  --shadow-soft: 0 12px 32px rgba(44, 51, 59, 0.12);
  --shadow-strong: 0 22px 50px rgba(44, 51, 59, 0.2);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  overflow: hidden;
  color: var(--ink);
  font-family: "Plus Jakarta Sans", "Avenir Next", "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 12% 8%, rgba(217, 224, 233, 0.72) 0, transparent 42%),
    radial-gradient(circle at 92% 0%, rgba(232, 237, 243, 0.8) 0, transparent 32%),
    radial-gradient(circle at 80% 100%, rgba(224, 241, 255, 0.34) 0, transparent 45%),
    linear-gradient(145deg, var(--bg-top), var(--bg-mid) 45%, var(--bg-bottom));
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(120deg, rgba(255, 255, 255, 0.4), rgba(255, 255, 255, 0)),
    repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.1) 0 3px, transparent 3px 12px);
  opacity: 0.35;
}

.layout {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100dvh;
  padding: 18px;
  display: grid;
  grid-template-columns: minmax(0, 1.9fr) minmax(320px, 1fr);
  gap: 14px;
  align-items: start;
}

.panel-0,
.panel {
  border-radius: 20px;
  border: 1px solid var(--line);
  background: linear-gradient(155deg, var(--glass-strong), var(--glass));
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(16px) saturate(120%);
  animation: panel-in 420ms ease-out both;
}

@keyframes panel-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.panel-0 {
  height: calc(100dvh - 36px);
  padding: 14px;
  overflow-y: auto;
}

.right-col {
  height: calc(100dvh - 36px);
  display: grid;
  grid-template-rows: repeat(3, 1fr);
  gap: 10px;
}

.panel {
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 12px;
  overflow: hidden;
}

.panel-1 {
  cursor: pointer;
  transition: border-color 160ms ease, background-color 160ms ease, box-shadow 160ms ease;
}

.panel-1.drag-over {
  border-color: var(--primary);
  background: linear-gradient(155deg, rgba(255, 255, 255, 0.92), rgba(236, 245, 252, 0.86));
  box-shadow: var(--shadow-strong);
}

.head {
  position: sticky;
  top: -1px;
  z-index: 4;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  padding: 2px 2px 10px;
  margin-bottom: 10px;
  border-bottom: 1px solid rgba(127, 136, 146, 0.32);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(255, 255, 255, 0.78));
  backdrop-filter: blur(12px);
}

.eyebrow {
  margin: 0;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--primary-strong);
}

.head h1 {
  margin: 4px 0;
  font-size: 1.8rem;
  line-height: 1.15;
  letter-spacing: -0.02em;
}

.head-sub {
  margin: 0;
  font-size: 0.84rem;
  color: var(--ink-soft);
}

.head-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  align-items: center;
}

.book-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

label {
  display: flex;
  flex-direction: column;
  margin: 0;
  gap: 3px;
  font-size: 0.71rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #5a6470;
}

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

input,
textarea,
select {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 7px 9px;
  background: rgba(255, 255, 255, 0.75);
  color: var(--ink);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  transition: border-color 140ms ease, box-shadow 140ms ease, background-color 140ms ease;
}

textarea {
  resize: vertical;
  min-height: 72px;
}

input::placeholder,
textarea::placeholder {
  color: #8d96a1;
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(105, 183, 238, 0.26);
  background: rgba(255, 255, 255, 0.95);
}

button:focus-visible,
.file-tile:focus-visible,
.tile-recat:focus-visible,
.panel-1:focus-visible {
  outline: 3px solid rgba(105, 183, 238, 0.4);
  outline-offset: 2px;
}

.full {
  grid-column: 1 / -1;
}

.half {
  grid-column: span 2;
}

.preview-group {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 10px;
  padding: 8px;
  border: 1px solid rgba(124, 133, 143, 0.2);
  border-radius: 16px;
  background: linear-gradient(140deg, rgba(255, 255, 255, 0.78), rgba(241, 244, 248, 0.56));
}

.author-row {
  align-items: stretch;
}

.author-bio-wrap {
  display: flex;
  min-width: 0;
}

.author-bio-wrap label,
.no-margin {
  flex: 1;
  margin: 0;
}

.author-row .author-bio-wrap textarea {
  height: 96px;
}

.preview-label {
  margin: 0 0 5px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #616a75;
}

.single-preview,
.multi-preview {
  border: 1px dashed var(--line-strong);
  border-radius: 12px;
  background:
    linear-gradient(150deg, rgba(255, 255, 255, 0.9), rgba(241, 245, 248, 0.72));
  min-height: 88px;
  padding: 5px;
  transition: border-color 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}

.single-preview {
  width: 150px;
  height: 108px;
}

.multi-preview {
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 6px;
  min-height: 108px;
  max-height: 108px;
  overflow: auto;
}

.illustration-wrap .multi-preview {
  min-height: 102px;
  max-height: 102px;
}

.author-row .single-preview {
  width: 146px;
  height: 102px;
}

.single-preview.drag-over,
.multi-preview.drag-over {
  border-color: var(--primary);
  box-shadow: 0 12px 24px rgba(95, 164, 214, 0.2);
  transform: translateY(-1px);
}

.single-preview img,
.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 10px;
}

.thumb {
  width: 66px;
  height: 66px;
  border-radius: 8px;
  border: 1px solid var(--line);
  overflow: hidden;
  background: rgba(255, 255, 255, 0.8);
}

button {
  border: 1px solid rgba(102, 111, 121, 0.26);
  border-radius: 12px;
  padding: 8px 12px;
  color: #fff;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  cursor: pointer;
  background: linear-gradient(135deg, #79838e, #626b76);
  box-shadow: 0 8px 16px rgba(63, 71, 80, 0.18);
  transition: transform 120ms ease, box-shadow 120ms ease, filter 120ms ease;
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 20px rgba(63, 71, 80, 0.22);
  filter: brightness(1.03);
}

button:active {
  transform: translateY(0);
}

button:disabled {
  opacity: 0.65;
  cursor: not-allowed;
  box-shadow: none;
}

.head-send,
.head-reset,
.head-preview {
  white-space: nowrap;
}

.head-reset {
  background: linear-gradient(135deg, #7e8996, #616c78);
}

.head-preview {
  background: linear-gradient(135deg, #6fbcec, #479edb);
}

#sendBtn,
.head-send {
  background: linear-gradient(135deg, #59ace4, #328ecf);
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  flex-shrink: 0;
}

.panel-head-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

.panel-analyze,
.panel-empty {
  padding: 5px 10px;
  font-size: 0.72rem;
}

.panel-analyze {
  background: linear-gradient(135deg, #6fbcec, #479edb);
}

.panel-empty {
  background: linear-gradient(135deg, #8f7e88, #75666f);
}

h2 {
  margin: 0;
  font-size: 0.86rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #5b6672;
}

.panel-note {
  margin: 0 0 8px;
  font-size: 0.74rem;
  color: var(--ink-soft);
}

.icon-grid {
  flex: 1;
  min-height: 0;
  padding: 8px;
  border: 1px solid rgba(124, 133, 143, 0.18);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.74);
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(58px, 1fr));
  gap: 7px;
  align-content: start;
}

.file-tile {
  position: relative;
  cursor: pointer;
  border: 1px solid rgba(126, 136, 146, 0.22);
  border-radius: 10px;
  background: linear-gradient(165deg, rgba(255, 255, 255, 0.94), rgba(242, 245, 248, 0.72));
  padding: 7px 4px 5px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  transition: transform 120ms ease, box-shadow 120ms ease, border-color 120ms ease;
}

.file-tile:hover {
  transform: translateY(-1px);
  border-color: rgba(105, 183, 238, 0.5);
  box-shadow: 0 8px 14px rgba(90, 158, 206, 0.16);
}

.folder-icon {
  width: 28px;
  height: 20px;
  border: 1px solid rgba(133, 142, 152, 0.75);
  border-radius: 4px;
  background: linear-gradient(180deg, #e7ebef, #cfd6dc);
  position: relative;
  flex-shrink: 0;
}

.folder-icon::before {
  content: "";
  position: absolute;
  left: 2px;
  top: -6px;
  width: 13px;
  height: 6px;
  border: 1px solid rgba(133, 142, 152, 0.75);
  border-bottom: 0;
  border-radius: 4px 4px 0 0;
  background: #dbe1e6;
}

.tile-ext {
  position: absolute;
  right: 2px;
  bottom: 1px;
  font-size: 0.46rem;
  font-weight: 800;
  color: #59636f;
  line-height: 1;
}

.tile-name {
  width: 100%;
  text-align: center;
  font-size: 0.61rem;
  line-height: 1.25;
  font-weight: 700;
  color: #59636f;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tile-remove {
  position: absolute;
  top: -5px;
  right: -5px;
  width: 17px;
  height: 17px;
  padding: 0;
  border: 1.5px solid #fff;
  border-radius: 50%;
  background: var(--danger);
  color: #fff;
  font-size: 0.66rem;
  line-height: 15px;
  text-align: center;
  box-shadow: 0 6px 14px rgba(167, 42, 74, 0.3);
  display: none;
  z-index: 2;
}

.file-tile:hover .tile-remove {
  display: block;
}

.classified-tile {
  cursor: grab;
  padding-bottom: 3px;
}

.classified-tile.dragging {
  opacity: 0.5;
  outline: 2px dashed var(--primary);
}

.tile-thumb-img {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 8px;
  display: block;
  flex-shrink: 0;
}

.tile-recat {
  width: 100%;
  margin-top: 2px;
  padding: 2px 4px;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.88);
  color: var(--ink);
  font-size: 0.54rem;
  font-weight: 700;
  cursor: pointer;
}

.status-log {
  flex: 1;
  min-height: 0;
  margin: 0;
  padding: 9px;
  border: 1px solid rgba(126, 136, 146, 0.24);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.74);
  overflow-y: auto;
  font-size: 0.72rem;
  font-family: "IBM Plex Mono", "SFMono-Regular", Menlo, monospace;
  line-height: 1.45;
  color: #56606b;
  white-space: pre-wrap;
}

.warn-field {
  border-color: #f4ac4a;
  background: rgba(255, 244, 226, 0.95);
  box-shadow: 0 0 0 3px rgba(244, 172, 74, 0.15);
}

[aria-invalid="true"] {
  border-color: #d1851f;
  box-shadow: 0 0 0 3px rgba(209, 133, 31, 0.18);
}

::-webkit-scrollbar {
  width: 9px;
  height: 9px;
}

::-webkit-scrollbar-thumb {
  border-radius: 8px;
  border: 2px solid transparent;
  background: linear-gradient(160deg, rgba(134, 144, 154, 0.62), rgba(173, 183, 194, 0.62));
  background-clip: padding-box;
}

::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.2);
}

@media (max-width: 1320px) {
  .layout {
    grid-template-columns: minmax(0, 1.5fr) minmax(300px, 1fr);
  }

  .book-form {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .half {
    grid-column: span 3;
  }
}

@media (max-width: 1080px) {
  body {
    overflow: auto;
  }

  .layout {
    height: auto;
    min-height: 100dvh;
    grid-template-columns: 1fr;
    padding: 10px;
  }

  .panel-0,
  .right-col {
    height: auto;
  }

  .panel-0 {
    overflow-y: visible;
  }

  .right-col {
    grid-template-rows: repeat(3, minmax(220px, auto));
  }

  .head {
    position: static;
    background: none;
    padding-bottom: 10px;
  }

  .head-actions {
    justify-content: flex-start;
  }

  .book-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .half {
    grid-column: span 2;
  }

  .preview-group {
    grid-template-columns: 1fr;
  }

  .single-preview {
    width: 100%;
    max-width: 220px;
  }
}

@media (max-width: 700px) {
  .book-form {
    grid-template-columns: 1fr;
  }

  .half {
    grid-column: 1 / -1;
  }

  .head h1 {
    font-size: 1.45rem;
  }

  .head-sub,
  .panel-note {
    font-size: 0.78rem;
  }
}

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