:root {
  --bg: #eef2fb;
  --ink: #1f2533;
  --muted: #64708b;
  --panel: #ffffff;
  --line: #d6deef;
  --brand: #1848d6;
  --brand-2: #0b2e9b;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Manrope", sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at 10% 20%, #f7f9ff 0%, #e6ecfb 40%, #e0e7f8 100%);
  overflow: hidden;
}

.app-shell {
  height: 100vh;
  display: grid;
  grid-template-columns: 72px 1fr;
}

.left-rail {
  background: linear-gradient(180deg, #042873 0%, #031f5a 100%);
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.brand {
  width: 48px;
  height: 48px;
  margin: 4px auto 12px;
  border-radius: 12px;
  background: linear-gradient(135deg, #f9ba32, #3ac7f7 50%, #6c6cf9);
  color: white;
  font-weight: 800;
  display: grid;
  place-items: center;
}

.rail-item {
  border: 0;
  border-radius: 10px;
  padding: 9px 6px;
  color: #d8e3ff;
  background: transparent;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}

.rail-item.active,
.rail-item:hover {
  background: rgba(101, 147, 255, 0.35);
}

.workspace {
  display: grid;
  grid-template-rows: auto 1fr;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.topbar {
  height: 82px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.topbar h1 {
  margin: 0;
  font-size: 26px;
}

.topbar p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.actions {
  display: flex;
  gap: 10px;
}

.upload-btn,
.primary {
  border-radius: 12px;
  border: 1px solid #1f56f1;
  padding: 11px 15px;
  font-weight: 700;
  cursor: pointer;
  font-size: 14px;
}

.upload-btn {
  background: white;
  color: #1143cc;
}

.upload-btn input {
  display: none;
}

.primary {
  background: var(--brand);
  color: white;
}

.primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.primary.is-loading {
  position: relative;
  padding-right: 34px;
}

.primary.is-loading::after {
  content: "";
  position: absolute;
  right: 12px;
  top: 50%;
  width: 12px;
  height: 12px;
  margin-top: -6px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: spin 0.85s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.editor-area {
  min-height: 0;
  display: grid;
  grid-template-columns: 252px 1fr;
  overflow: hidden;
}

.thumb-list {
  border-right: 1px solid var(--line);
  background: linear-gradient(180deg, #d2dcef 0%, #c8d4ea 100%);
  overflow: auto;
  padding: 12px 10px 26px;
}

.thumb-card {
  width: 165px;
  margin: 0 auto;
  position: relative;
  padding-bottom: 28px;
}

.thumb-card.selected {
}

.thumb-paper {
  background: #edf3ff;
  border: 1px solid #b7c6e8;
  border-radius: 2px;
  padding: 6px;
  box-shadow: inset 0 0 0 1px #d6e0f6;
}

.thumb-card.selected .thumb-paper {
  border-color: #6f99ff;
  box-shadow: inset 0 0 0 1px #d6e0f6, 0 0 0 2px #bdd0ff;
}

.thumb-canvas {
  width: 100%;
  display: block;
  border-radius: 2px;
  background: #fff;
}

.thumb-meta {
  margin-top: 26px;
  font-size: 20px;
  color: #2d3b61;
  text-align: center;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.tool-row {
  position: absolute;
  left: 50%;
  bottom: 52px;
  transform: translateX(-50%);
  display: flex;
  gap: 0;
  border: 1px solid #d7deec;
  background: #f8fbff;
  border-radius: 8px;
  padding: 5px;
  box-shadow: 0 4px 12px rgba(32, 48, 92, 0.12);
}

.mini-btn {
  width: 24px;
  height: 24px;
  border: 0;
  background: transparent;
  color: #3a4f83;
  border-radius: 6px;
  padding: 0;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  display: grid;
  place-items: center;
}

.mini-btn.delete {
  color: #8e2234;
}

.mini-btn:hover {
  background: #e9effc;
}

.between-add {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 0;
  background: #79a6ff;
  color: #fff;
  font-size: 24px;
  line-height: 1;
  margin: 8px auto 16px;
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: 0 3px 8px rgba(52, 92, 182, 0.26);
}

.between-add:hover {
  background: #5e90f2;
}

.preview-area {
  min-width: 0;
  min-height: 0;
  padding: 26px;
  overflow: hidden;
}

.preview-frame {
  width: min(980px, 100%);
  height: 100%;
  margin: 0 auto;
  background: linear-gradient(155deg, #f9fbff 0%, #e6ecfb 100%);
  border: 1px solid #cfd8ed;
  border-radius: 22px;
  display: grid;
  place-items: center;
  padding: 20px;
  position: relative;
  overflow: hidden;
}

#mainPreview {
  max-width: 100%;
  max-height: 100%;
  border-radius: 10px;
  box-shadow: 0 16px 40px rgba(17, 33, 74, 0.2);
  background: white;
}

.preview-hint {
  color: #5f6d91;
  position: absolute;
}

.empty-state {
  color: #47567f;
  background: rgba(255, 255, 255, 0.6);
  border: 1px dashed #adc0ea;
  border-radius: 12px;
  padding: 18px;
  text-align: center;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .left-rail {
    display: none;
  }

  .editor-area {
    grid-template-columns: 1fr;
  }

  .thumb-list {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .thumb-card {
    margin-bottom: 0;
  }
}
