@font-face {
  font-family: 'Space Grotesk';
  font-style: normal;
  font-display: swap;
  font-weight: 400;
  src: url('/src/assets/fonts/space-grotesk-latin-400-normal.woff2') format('woff2');
}

@font-face {
  font-family: 'Space Grotesk';
  font-style: normal;
  font-display: swap;
  font-weight: 500;
  src: url('/src/assets/fonts/space-grotesk-latin-500-normal.woff2') format('woff2');
}

@font-face {
  font-family: 'Space Grotesk';
  font-style: normal;
  font-display: swap;
  font-weight: 700;
  src: url('/src/assets/fonts/space-grotesk-latin-700-normal.woff2') format('woff2');
}

@font-face {
  font-family: 'IBM Plex Mono';
  font-style: normal;
  font-display: swap;
  font-weight: 400;
  src: url('/src/assets/fonts/ibm-plex-mono-latin-400-normal.woff2') format('woff2');
}

@font-face {
  font-family: 'IBM Plex Mono';
  font-style: normal;
  font-display: swap;
  font-weight: 600;
  src: url('/src/assets/fonts/ibm-plex-mono-latin-600-normal.woff2') format('woff2');
}

:root {
  --bg: linear-gradient(120deg, #f4efe8 0%, #f8f5f1 42%, #e8f4ef 100%);
  --panel-bg: rgba(255, 255, 255, 0.82);
  --panel-border: #cfcdc6;
  --text-main: #211f1c;
  --text-muted: #5f5a53;
  --brand: #0f7c68;
  --brand-strong: #0a5f51;
  --danger: #ba3a34;
  --surface: #fefefe;
  --shadow: 0 12px 28px rgba(57, 47, 37, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: 'Space Grotesk', 'Segoe UI', sans-serif;
  color: var(--text-main);
  background: var(--bg);
}

.app-shell {
  width: min(1380px, 100% - 2rem);
  margin: 1rem auto 2rem;
}

.topbar {
  display: grid;
  gap: 0.4rem;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid var(--panel-border);
  border-radius: 20px;
  padding: 1.2rem 1.35rem;
  box-shadow: var(--shadow);
}

.topbar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.eyebrow {
  margin: 0;
  font-size: 0.76rem;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--brand);
  font-weight: 600;
}

h1 {
  margin: 0.05rem 0 0;
  font-size: clamp(1.5rem, 2vw, 2.2rem);
}

.subtitle {
  margin: 0;
  color: var(--text-muted);
  max-width: 70ch;
}

.locale-group {
  display: flex;
  align-items: center;
}

.locale-group select {
  min-width: 130px;
}

.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;
}

.layout {
  margin-top: 1rem;
  display: grid;
  grid-template-columns: minmax(300px, 380px) minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
}

.controls,
.workspace {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 20px;
  box-shadow: var(--shadow);
}

.controls {
  padding: 1rem;
  display: grid;
  gap: 0.9rem;
  position: sticky;
  top: 0.8rem;
}

.panel {
  background: var(--surface);
  border: 1px solid #e3e1db;
  border-radius: 14px;
  padding: 0.85rem;
}

.panel h2 {
  margin: 0 0 0.65rem;
  font-size: 1rem;
}

.file-input {
  display: grid;
  gap: 0.5rem;
}

.file-input span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.4rem;
  border-radius: 12px;
  border: 1px dashed #b6b1a8;
  background: #faf8f6;
  font-size: 0.95rem;
}

.file-input input {
  width: 100%;
  font-family: inherit;
}

.row {
  display: grid;
  gap: 0.3rem;
  margin-bottom: 0.55rem;
}

select,
.controls button,
input {
  font: inherit;
}

select,
.controls button {
  min-height: 2.45rem;
  border-radius: 12px;
  border: 1px solid #c9c4ba;
  padding: 0.5rem 0.7rem;
}

.controls button {
  cursor: pointer;
  background: #fff;
}

.controls button:disabled,
select:disabled,
input:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.button-row {
  display: flex;
  gap: 0.45rem;
  margin-top: 0.35rem;
}

.button-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.45rem;
  margin-bottom: 0.45rem;
}

.image-action-grid {
  margin-top: 0.35rem;
  margin-bottom: 0.55rem;
}

.controls button.primary {
  border: none;
  color: #fff;
  background: linear-gradient(140deg, var(--brand) 0%, var(--brand-strong) 100%);
  font-weight: 700;
}

.controls button.ghost {
  background: #fbfbfb;
}

.muted {
  margin: 0.5rem 0 0;
  color: var(--text-muted);
  font-size: 0.88rem;
}

.status {
  margin: 0;
  border-radius: 12px;
  padding: 0.75rem 0.85rem;
  border: 1px solid #cfd8d2;
  background: #f4faf7;
  font-size: 0.9rem;
}

.status[data-type='error'] {
  border-color: #e8c4bf;
  background: #fff3f1;
  color: #84241f;
}

.status[data-type='success'] {
  border-color: #b6d8ca;
  background: #edf7f2;
  color: #134f3f;
}

.workspace {
  padding: 1rem;
  overflow: auto;
  display: flex;
  align-items: stretch;
  justify-content: stretch;
}

.workspace.is-empty {
  overflow: hidden;
  min-height: var(--workspace-empty-min-height, 320px);
}

.workspace-empty-state {
  width: 100%;
  min-height: 100%;
  display: none;
  align-items: center;
  justify-content: center;
  border: 2px dashed #bbb5aa;
  border-radius: 16px;
  padding: 1.2rem;
  text-align: center;
  color: var(--text-muted);
  background: linear-gradient(180deg, #fbf9f5 0%, #f4f1ea 100%);
  font-size: 1rem;
  font-weight: 500;
}

.workspace.is-empty .workspace-empty-state {
  display: flex;
}

.workspace.is-empty .page-list {
  display: none;
}

.workspace.is-empty-drop-target .workspace-empty-state {
  border-color: #2c8a76;
  box-shadow: inset 0 0 0 2px rgba(15, 124, 104, 0.22);
  color: #134f3f;
  background: linear-gradient(180deg, #f0faf6 0%, #e7f3ed 100%);
}

.page-footer {
  margin-top: 1rem;
}

.footer-card {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 20px;
  padding: 1rem 1.1rem;
  box-shadow: var(--shadow);
}

.footer-title {
  font-weight: 700;
  letter-spacing: 0.02em;
  margin-bottom: 0.65rem;
}

.footer-grid {
  display: grid;
  grid-template-columns: auto auto auto 1fr;
  gap: 14px;
  align-items: start;
}

.footer-block {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.footer-label {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.footer-text {
  color: var(--text-main);
  font-size: 14px;
  line-height: 1.5;
}

.footer-text a {
  color: var(--brand);
  text-decoration: none;
}

.footer-text a:hover {
  color: var(--brand-strong);
}

.footer-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-self: end;
  align-self: end;
}

.icon-link {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid #c9c4ba;
  background: #fff;
  color: #1f2522;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  transition: transform 120ms ease, border-color 120ms ease, background 120ms ease;
}

.icon-link:hover {
  transform: translateY(-1px);
  border-color: var(--brand);
  background: #f2faf7;
}

.icon-link .icon {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.page-list {
  display: grid;
  gap: 1rem;
  width: 100%;
  align-content: start;
}

.page-wrapper {
  border: 1px solid #d2cec4;
  border-radius: 16px;
  padding: 0.8rem;
  background: #f9f7f3;
  transition: box-shadow 140ms ease, border-color 140ms ease;
}

.page-wrapper.is-active {
  border-color: #4a8f7f;
  box-shadow: 0 0 0 2px rgba(15, 124, 104, 0.22);
}

.page-wrapper.is-drop-target {
  border-color: #2c8a76;
  box-shadow: 0 0 0 3px rgba(15, 124, 104, 0.24);
}

.page-label {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.82rem;
  color: #5d5952;
  margin-bottom: 0.5rem;
}

.page-stage {
  position: relative;
  display: inline-block;
  max-width: 100%;
}

.page-wrapper.is-drop-target .page-stage::after {
  content: '';
  position: absolute;
  inset: 8px;
  border-radius: 8px;
  border: 2px dashed rgba(15, 124, 104, 0.72);
  background: rgba(15, 124, 104, 0.11);
  pointer-events: none;
}

.pdf-canvas {
  display: block;
  border: 1px solid #c9c5bc;
  border-radius: 8px;
  box-shadow: 0 10px 20px rgba(63, 53, 40, 0.18);
}

.page-overlay {
  position: absolute;
  inset: 0;
  user-select: none;
  touch-action: none;
}

.placement {
  position: absolute;
  left: 0;
  top: 0;
  border: 1px solid rgba(23, 91, 78, 0.66);
  outline: 1px solid rgba(255, 255, 255, 0.85);
  box-shadow: 0 4px 14px rgba(34, 33, 28, 0.25);
  touch-action: none;
  pointer-events: auto;
  overflow: visible;
}

.placement img {
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
}

.placement-grip {
  position: absolute;
  right: 0;
  bottom: 0;
  transform: translate(50%, 50%);
  width: 22px;
  height: 22px;
  min-height: 0;
  padding: 0;
  display: block;
  border-radius: 999px;
  border: 2px solid #fff;
  background: var(--brand);
  box-shadow: 0 0 0 1px rgba(14, 71, 60, 0.5);
  cursor: nwse-resize;
  touch-action: none;
  pointer-events: auto;
}

.placement.is-selected {
  border-color: #0d6757;
  box-shadow: 0 0 0 2px rgba(13, 103, 87, 0.35), 0 8px 18px rgba(34, 33, 28, 0.3);
}

@media (max-width: 1080px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .controls {
    position: static;
  }

  .footer-grid {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .footer-actions {
    justify-content: flex-start;
    justify-self: start;
    align-self: start;
  }
}

@media (max-width: 720px) {
  .app-shell {
    width: min(1380px, 100% - 1rem);
  }

  .topbar-row {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar,
  .controls,
  .workspace {
    border-radius: 14px;
  }

  .panel {
    border-radius: 12px;
  }

  .footer-card {
    border-radius: 14px;
  }
}
