@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700&family=IBM+Plex+Sans:wght@400;500&display=swap');

:root {
  --bg: #e4f1fb;
  --panel: #ffffff;
  --ink: #1b2a35;
  --muted: #5a6a78;
  --accent: #006ca9;
  --accent-dark: #005287;
  --line: #d0dbe3;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
  --radius: 14px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'IBM Plex Sans', system-ui, sans-serif;
  color: var(--ink);
  background: var(--bg);
  min-height: 100vh;
}

.page {
  max-width: 1280px;
  margin: 0 auto;
  padding: 28px 24px 40px;
  position: relative;
  z-index: 1;
}

.bg-orb {
  display: none;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  margin-bottom: 28px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand-title {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 18px;
}

.brand-sub {
  color: var(--muted);
  font-size: 13px;
}

.top-actions {
  display: flex;
  gap: 12px;
}

.layout {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 24px;
}

.panel {
  background: var(--panel);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
}

.panel.wide {
  grid-column: 2 / 3;
  grid-row: 1 / span 2;
}

h2 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 18px;
  margin: 0 0 16px;
}

.panel-sub {
  color: var(--muted);
  font-size: 13px;
  margin: -8px 0 12px;
}

.upload {
  display: grid;
  gap: 16px;
}

.file-input {
  display: none;
}

.upload-drop {
  border: 2px dashed #b9c8d6;
  border-radius: 16px;
  padding: 16px;
  display: grid;
  gap: 12px;
  align-items: center;
  justify-items: start;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.upload-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.upload-drop.dragover {
  border-color: var(--accent);
  background: #eef6fc;
}

.upload-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: #fbe5de;
  color: var(--accent);
  display: grid;
  place-items: center;
  font-weight: 700;
}

.upload-title {
  font-weight: 600;
}

.upload-sub {
  font-size: 12px;
  color: var(--muted);
}

.label {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.textarea {
  min-height: 120px;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  font-family: inherit;
}

.paste-box {
  display: none;
  gap: 10px;
}

.paste-box.active {
  display: grid;
}

.source-list {
  display: grid;
  gap: 10px;
}

.source-empty {
  padding: 14px;
  border-radius: 12px;
  border: 1px dashed var(--line);
  color: var(--muted);
  font-size: 13px;
  background: #f6f9fc;
}

.source-item {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border-radius: 12px;
  background: #f8fbfe;
  border: 1px solid var(--line);
}

.thumb {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: #efe7df;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 12px;
  overflow: hidden;
}

.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.source-title {
  font-weight: 600;
}

.source-sub {
  font-size: 12px;
  color: var(--muted);
}

.template-accordion {
  display: grid;
  gap: 12px;
}

.template-group {
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}

.template-group summary {
  list-style: none;
  cursor: pointer;
  padding: 12px 14px;
  background: #f2f7fb;
  font-weight: 600;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: background 0.2s ease;
}

.template-group summary::-webkit-details-marker {
  display: none;
}

.template-group summary span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.template-group summary .chevron {
  font-size: 16px;
  color: var(--accent);
  transition: transform 0.2s ease;
  margin-left: 8px;
}

.template-group[open] summary .chevron {
  transform: rotate(180deg);
}

.template-list {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  padding: 12px;
  background: #ffffff;
  animation: templateIn 0.18s ease-out;
}

.template-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  text-align: left;
  background: #ffffff;
  cursor: pointer;
  min-height: 76px;
  display: grid;
  gap: 6px;
}

.template-card.new {
  border-style: dashed;
  background: #f7fbff;
}

.template-plus {
  font-size: 18px;
  font-weight: 700;
  color: var(--accent);
}

.template-card.active {
  border-color: var(--accent);
  box-shadow: 0 10px 24px rgba(213, 43, 30, 0.16);
}

.template-thumb {
  height: 42px;
  border-radius: 8px;
  background: #f3f8fc;
  border: 1px solid #e0e9f0;
  display: grid;
  place-items: center;
  color: #7a8a96;
  font-size: 11px;
}

.template-label {
  font-weight: 600;
  font-size: 13px;
}

.template-meta {
  font-size: 11px;
  color: var(--muted);
}

.input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  margin-bottom: 14px;
  height: 44px;
}

.btn {
  border: none;
  padding: 10px 14px;
  border-radius: 999px;
  font-weight: 600;
  cursor: pointer;
  background: #e7eef4;
}

.btn.primary {
  background: var(--accent);
  color: white;
  box-shadow: 0 12px 24px rgba(0, 108, 169, 0.25);
}

.btn.icon {
  width: 44px;
  height: 44px;
  padding: 0;
  display: grid;
  place-items: center;
}

.btn.icon .arrow {
  font-size: 20px;
  line-height: 1;
}

.btn.ghost.icon {
  background: #ffffff;
  border: 1px solid #c8d6e2;
  color: var(--accent);
}

.generate-btn {
  border-radius: 12px;
  padding: 10px 16px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.generate-btn.secondary {
  background: #ffffff;
  border: 1px solid #c8d6e2;
  color: var(--accent);
  box-shadow: none;
}

.generate-btn .arrow {
  font-size: 16px;
}

.btn.ghost {
  background: transparent;
  border: 1px solid var(--line);
}

.btn.ghost {
  background: transparent;
  border: 1px solid var(--line);
}

.btn.small {
  padding: 8px 12px;
  font-size: 12px;
}

.btn.wide {
  width: 100%;
}

.chip {
  border: 1px solid var(--line);
  background: #f7f4f0;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 11px;
  cursor: pointer;
}

.chip.danger {
  color: var(--accent-dark);
  border-color: #f1c0b9;
  background: #fde9e4;
}

.preview-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 12px;
}

.preview {
  border: 1px solid var(--line);
  border-radius: 18px;
  overflow: hidden;
  background: #fff;
}

.preview-empty {
  min-height: 360px;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 15px;
  background: #f4f9fd;
}

.muted {
  color: var(--muted);
  margin: 0;
}

.footer {
  margin-top: 24px;
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--muted);
}

.footer-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.export-menu {
  position: relative;
}

.export-menu.hidden {
  display: none;
}

.export-menu .caret {
  margin-left: 6px;
  font-size: 12px;
}

.export-list {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  min-width: 180px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 6px;
  display: none;
  z-index: 10;
}

.export-list.open {
  display: grid;
  gap: 4px;
}

.export-list button {
  background: transparent;
  border: none;
  text-align: left;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
  color: var(--ink);
}

.export-list button:hover {
  background: #f1f7fb;
}

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

  .panel.wide {
    grid-column: auto;
    grid-row: auto;
  }

  .preview-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .split {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .top-actions {
    width: 100%;
    justify-content: space-between;
  }
}

.prompt-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  margin-top: 14px;
}

.export-row {
  display: flex;
  justify-content: flex-end;
  margin-top: 12px;
}

@keyframes templateIn {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
