@import url('https://fonts.googleapis.com/css2?family=Sora:wght@400;600;700;800&family=JetBrains+Mono:wght@400;600&display=swap');

:root {
  --bg: #f5f7f8;
  --bg-accent: #d9f0f1;
  --panel: #ffffffcc;
  --panel-solid: #ffffff;
  --text: #0f1a24;
  --muted: #526271;
  --line: #d8e0e7;
  --brand: #006f86;
  --brand-strong: #035164;
  --ok-bg: #e7f7ee;
  --ok-tx: #157347;
  --err-bg: #ffebee;
  --err-tx: #9f1239;
  --shadow: 0 16px 40px rgba(14, 32, 50, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--text);
  font-family: "Sora", "Avenir Next", "Segoe UI", sans-serif;
  background:
    radial-gradient(900px 600px at 10% -10%, var(--bg-accent), transparent 58%),
    radial-gradient(700px 500px at 95% 10%, #ffe9d2, transparent 52%),
    var(--bg);
}

.container {
  width: min(1220px, 94vw);
  margin: 28px auto 48px;
  display: grid;
  gap: 18px;
}

.hero {
  display: grid;
  gap: 8px;
  position: relative;
}

.brand-chip {
  width: fit-content;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid #b4d7df;
  color: #014b5c;
  background: linear-gradient(135deg, #e8fbff, #f3fbff);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.brand-mark {
  position: absolute;
  right: 0;
  top: -4px;
  width: 92px;
  height: 92px;
  border-radius: 20px;
  background:
    linear-gradient(135deg, #0b6f87 0%, #2fb7b5 100%);
  box-shadow: 0 16px 24px rgba(0, 86, 103, 0.24);
}

.brand-mark::before,
.brand-mark::after {
  content: "";
  position: absolute;
  background: #fff;
}

.brand-mark::before {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  left: 14px;
  top: 14px;
}

.brand-mark::after {
  width: 48px;
  height: 12px;
  border-radius: 8px;
  right: 12px;
  bottom: 14px;
}

h1 {
  margin: 0;
  font-size: clamp(34px, 6vw, 58px);
  line-height: 1;
  letter-spacing: -0.03em;
}

p {
  margin: 0;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.ad-card {
  display: grid;
  gap: 10px;
}

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

.consent-ad {
  display: block;
  min-height: 110px;
  border: 1px dashed var(--line);
  border-radius: 12px;
  background: #fff;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(620px, 1.45fr) minmax(340px, 1fr);
  gap: 18px;
}

.workspace-left,
.workspace-right {
  display: grid;
  gap: 14px;
}

.upload-form,
.editor-block {
  display: grid;
  gap: 10px;
}

label {
  font-size: 14px;
  font-weight: 700;
}

input[type="file"],
textarea,
button,
.clear-btn,
.history-actions button {
  border-radius: 12px;
  border: 1px solid var(--line);
}

input[type="file"],
textarea {
  width: 100%;
  padding: 12px;
  background: var(--panel-solid);
  color: var(--text);
}

textarea {
  min-height: 240px;
  resize: vertical;
  font-family: "JetBrains Mono", "Fira Code", monospace;
  font-size: 12px;
  line-height: 1.45;
}

button,
.primary-btn,
.preview-btn,
.clear-btn,
.history-actions button {
  padding: 12px 14px;
  font-family: inherit;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, var(--brand), var(--brand-strong));
  cursor: pointer;
}

button:hover,
.primary-btn:hover,
.preview-btn:hover,
.clear-btn:hover,
.history-actions button:hover {
  filter: brightness(1.04);
}

.actions-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.download {
  color: #0050b3;
  font-weight: 700;
}

.cta-download {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  padding: 12px 16px;
  border-radius: 12px;
  color: #fff;
  background: linear-gradient(135deg, #0f9d58, #087a44);
  border: 1px solid #056239;
  box-shadow: 0 8px 18px rgba(8, 122, 68, 0.28);
}

.cta-download:hover {
  filter: brightness(1.05);
}

.msg {
  padding: 12px;
  border-radius: 12px;
  border: 1px solid transparent;
}

.msg.ok {
  background: var(--ok-bg);
  color: var(--ok-tx);
  border-color: #b9e8ca;
}

.msg.error {
  background: var(--err-bg);
  color: var(--err-tx);
  border-color: #fecdd3;
}

.workspace-right h2,
.card h2 {
  margin: 0;
  font-size: 26px;
}

.preview-toolbar {
  display: grid;
  gap: 8px;
}

.preview-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.preview-group button {
  padding: 9px 12px;
  font-size: 13px;
}

#page-indicator {
  font-weight: 700;
  color: var(--text);
  font-size: 13px;
  min-width: 64px;
  text-align: center;
}

.preview-wrap {
  border: 1px solid var(--line);
  border-radius: 16px;
  background:
    linear-gradient(180deg, #eff4f8 0%, #f9fcff 100%);
  padding: 12px;
  min-height: 920px;
}

#preview-canvas-wrap {
  width: 100%;
  height: 894px;
  overflow: auto;
  border-radius: 12px;
  border: 1px solid #cfd8e3;
  background:
    linear-gradient(45deg, #f6f8fb 25%, #eef2f8 25%, #eef2f8 50%, #f6f8fb 50%, #f6f8fb 75%, #eef2f8 75%, #eef2f8 100%);
  background-size: 20px 20px;
  display: grid;
  place-items: start center;
  padding: 12px;
}

#preview-canvas {
  width: 100%;
  max-width: 100%;
  height: auto;
  background: #fff;
  box-shadow: 0 10px 24px rgba(15, 26, 36, 0.18);
}

.hint,
.empty,
footer small {
  color: var(--muted);
  font-size: 13px;
}

.site-footer {
  display: grid;
  gap: 8px;
}

.consent-banner {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: 16px;
  z-index: 1200;
}

.consent-banner.hidden {
  display: none;
}

.consent-content {
  width: min(980px, 100%);
  margin: 0 auto;
  background: #0f1a24;
  color: #fff;
  border-radius: 14px;
  border: 1px solid #2f3f4f;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.28);
  padding: 12px 14px;
  display: flex;
  gap: 14px;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
}

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

.consent-actions button.secondary {
  background: #243546;
  border-color: #3b5167;
}

.footer-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.footer-main strong {
  font-size: 15px;
}

.footer-main span {
  font-size: 13px;
  color: var(--muted);
}

.history-list {
  display: grid;
  gap: 10px;
  margin: 12px 0;
  padding: 0;
  list-style: none;
}

.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  background: var(--panel-solid);
}

.history-main {
  min-width: 0;
}

.history-item h3 {
  margin: 0 0 8px;
  font-size: 16px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-item p {
  margin: 0;
}

.history-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.history-actions a {
  font-weight: 700;
}

.empty {
  border: 1px dashed var(--line);
  border-radius: 12px;
  padding: 12px;
}

.preview-modal {
  width: min(1000px, 96vw);
  height: min(90vh, 900px);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0;
}

.preview-modal::backdrop {
  background: rgba(0, 0, 0, 0.65);
}

.preview-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: #f8f6f1;
}

#preview-frame {
  width: 100%;
  height: calc(100% - 48px);
  border: 0;
}

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

  .brand-mark {
    display: none;
  }

  .preview-wrap {
    min-height: 680px;
  }

  #preview-canvas-wrap {
    height: 652px;
  }

  .history-item {
    flex-direction: column;
    align-items: flex-start;
  }

  .history-actions {
    width: 100%;
  }
}

@media (max-width: 640px) {
  .container {
    width: min(100%, 96vw);
    margin: 16px auto 24px;
    gap: 12px;
  }

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

  #preview-canvas-wrap {
    height: 520px;
  }
}
