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

:root {
  --bg-1: #f2ede7;
  --bg-2: #e7efe8;
  --ink: #1f1b1a;
  --muted: #6d6460;
  --accent: #169b9b;
  --accent-strong: #0f6f6f;
  --accent-warm: #f08a3c;
  --panel: #fefbf7;
  --line: rgba(31, 27, 26, 0.12);
  --shadow: 0 20px 60px rgba(31, 27, 26, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "IBM Plex Sans", "Space Grotesk", sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at top left, var(--bg-1), var(--bg-2));
  min-height: 100vh;
  position: relative;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image: linear-gradient(
      90deg,
      rgba(31, 27, 26, 0.04) 1px,
      transparent 1px
    ),
    linear-gradient(0deg, rgba(31, 27, 26, 0.04) 1px, transparent 1px);
  background-size: 40px 40px;
  pointer-events: none;
  z-index: -1;
}

.page,
.canvas-page {
  min-height: 100vh;
  padding: 32px 40px 64px;
}

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

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

.ghost {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.7);
  color: var(--accent-strong);
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.ghost:hover {
  border-color: rgba(15, 111, 111, 0.35);
}

.topbar-link {
  text-decoration: none;
}

.history-action {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 9px 15px 9px 12px;
  border-color: rgba(22, 155, 155, 0.36);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.96), rgba(231, 239, 232, 0.86)),
    linear-gradient(135deg, rgba(22, 155, 155, 0.18), rgba(240, 138, 60, 0.14));
  color: #0f5f5f;
  box-shadow:
    0 12px 26px rgba(15, 111, 111, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.72);
  overflow: hidden;
  transition:
    transform 0.18s ease,
    border-color 0.18s ease,
    box-shadow 0.18s ease,
    background 0.18s ease;
}

.history-action::before {
  content: "";
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  border-radius: 6px;
  background-color: currentColor;
  mask:
    url("data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2024%2024'%20fill='none'%20stroke='black'%20stroke-width='2'%20stroke-linecap='round'%20stroke-linejoin='round'%3E%3Cpath%20d='M4%206h14a2%202%200%200%201%202%202v10a2%202%200%200%201-2%202H4a2%202%200%200%201-2-2V8a2%202%200%200%201%202-2Z'/%3E%3Cpath%20d='M8%206V4a2%202%200%200%201%202-2h10a2%202%200%200%201%202%202v10a2%202%200%200%201-2%202'/%3E%3Cpath%20d='m4%2016%203.2-3.2a1.4%201.4%200%200%201%202%200L12%2015.6l2.2-2.2a1.4%201.4%200%200%201%202%200L20%2017.2'/%3E%3Ccircle%20cx='8.5'%20cy='10.5'%20r='1.5'/%3E%3C/svg%3E")
    center / contain no-repeat;
}

.history-action::after {
  content: "";
  position: absolute;
  inset: 1px;
  border-radius: inherit;
  background: linear-gradient(120deg, rgba(255, 255, 255, 0.42), transparent 42%);
  pointer-events: none;
}

.history-action:hover {
  transform: translateY(-2px);
  border-color: rgba(15, 111, 111, 0.58);
  box-shadow:
    0 16px 30px rgba(15, 111, 111, 0.16),
    0 6px 14px rgba(240, 138, 60, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.78);
}

.history-action:focus-visible {
  outline: 3px solid rgba(240, 138, 60, 0.34);
  outline-offset: 3px;
}

.dark-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 10px 16px;
  border-radius: 999px;
  border: 1px solid rgba(0, 0, 0, 0.72);
  background: #151515;
  color: #f4f4f4;
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.2px;
  box-shadow: 0 14px 28px rgba(21, 21, 21, 0.18);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.dark-action:hover {
  transform: translateY(-1px);
  box-shadow: 0 18px 32px rgba(21, 21, 21, 0.24);
}

.lang-switch {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
}

.lang-chip {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--muted);
  min-width: 42px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.16s ease, color 0.16s ease;
}

.lang-chip.is-active {
  background: rgba(15, 111, 111, 0.16);
  color: var(--accent-strong);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-family: "Space Grotesk", sans-serif;
  font-size: 28px;
  font-weight: 600;
  letter-spacing: 0.5px;
}

.brand-logo {
  width: 34px;
  height: 34px;
  object-fit: contain;
  flex: 0 0 auto;
  filter: drop-shadow(0 4px 8px rgba(31, 27, 26, 0.14));
}

.subtitle {
  color: var(--muted);
  font-size: 14px;
  margin-top: 6px;
}

.job-pill {
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(22, 155, 155, 0.12);
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 600;
}

.input-layout {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 24px;
}

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

.field-label {
  display: block;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--muted);
  margin-bottom: 8px;
}

.field-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.field-caption {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
  text-align: right;
}

.route-summary {
  display: grid;
  gap: 10px;
  padding: 14px 16px;
  border: 1px solid rgba(15, 111, 111, 0.14);
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(22, 155, 155, 0.08), rgba(255, 255, 255, 0.72));
}

.route-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 14px;
}

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

.route-value {
  font-size: 13px;
  text-align: right;
}

.route-note {
  color: var(--accent-strong);
  font-size: 12px;
  line-height: 1.5;
}

.textarea {
  width: 100%;
  min-height: 320px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: #fff;
  padding: 14px 16px;
  font-size: 15px;
  line-height: 1.5;
  resize: vertical;
}

.field-group {
  margin-bottom: 16px;
}

.choice-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.choice-card,
.choice-pill {
  appearance: none;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  transition:
    transform 0.16s ease,
    border-color 0.16s ease,
    box-shadow 0.16s ease,
    background 0.16s ease;
}

.choice-card:hover,
.choice-pill:hover {
  transform: translateY(-1px);
  border-color: rgba(15, 111, 111, 0.28);
}

.choice-card.is-active,
.choice-pill.is-active {
  border-color: rgba(15, 111, 111, 0.65);
  box-shadow: 0 10px 22px rgba(15, 111, 111, 0.12);
  background: linear-gradient(135deg, rgba(22, 155, 155, 0.14), rgba(255, 255, 255, 0.98));
}

.choice-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  min-height: 84px;
  padding: 14px 16px;
  border-radius: 16px;
  text-align: left;
}

.choice-title {
  font-family: "Space Grotesk", sans-serif;
  font-size: 16px;
  font-weight: 600;
}

.choice-meta {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.choice-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.choice-pill {
  padding: 10px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
}

.field-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
}

.input,
select {
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  font-size: 14px;
}

input[type="checkbox"] {
  accent-color: var(--accent);
}

.advanced {
  margin-top: 8px;
}

.advanced summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--accent-strong);
  margin-bottom: 12px;
}

.upload-zone {
  position: relative;
  border: 1px dashed rgba(31, 27, 26, 0.25);
  border-radius: 14px;
  min-height: 132px;
  padding: 14px 18px;
  background: rgba(255, 255, 255, 0.6);
  color: var(--muted);
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.upload-zone.dragging {
  border-color: var(--accent);
  background: rgba(22, 155, 155, 0.08);
}

.file-input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.upload-text {
  font-size: 13px;
  width: 100%;
  line-height: 1.4;
  pointer-events: none;
}

.upload-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
}

.upload-preview {
  width: 64px;
  height: 64px;
  border-radius: 12px;
  object-fit: cover;
  border: 1px solid var(--line);
  background: #fff;
  display: none;
}

.upload-preview.visible {
  display: block;
}

.stage-preview {
  width: 100%;
  max-height: 420px;
  object-fit: contain;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: #fff;
  display: none;
}

.stage-preview.visible {
  display: block;
}

.hint {
  color: var(--muted);
  font-size: 12px;
  margin-top: 8px;
}

.is-hidden {
  display: none !important;
}

.actions {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 16px;
}

.primary {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 12px 24px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 20px rgba(22, 155, 155, 0.25);
}

.primary:disabled {
  opacity: 0.7;
  cursor: wait;
}

.error {
  color: #c44536;
  font-size: 13px;
}

.canvas-stage {
  height: calc(100vh - 140px);
}

.guide-layout {
  display: grid;
  gap: 24px;
}

.guide-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}

.guide-block,
.guide-item {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.84);
  padding: 16px;
}

.guide-kicker {
  color: var(--accent-strong);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.guide-block-title,
.guide-item-title {
  font-family: "Space Grotesk", sans-serif;
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 8px;
}

.guide-copy {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

.guide-list {
  display: grid;
  gap: 12px;
}

.guide-help-card {
  border-color: rgba(15, 111, 111, 0.22);
  background:
    linear-gradient(90deg, rgba(240, 138, 60, 0.18), rgba(255, 255, 255, 0) 18%),
    linear-gradient(135deg, rgba(22, 155, 155, 0.1), rgba(255, 255, 255, 0.96));
  padding: 18px 20px;
}

.guide-help-banner {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 18px;
}

.guide-help-side {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.guide-help-icon {
  width: 56px;
  height: 56px;
  border-radius: 22px;
  display: grid;
  place-items: center;
  color: #fff;
  background:
    radial-gradient(circle at 30% 20%, rgba(255, 255, 255, 0.22), transparent 32%),
    linear-gradient(145deg, #151515, #0f6f6f);
  box-shadow:
    0 14px 26px rgba(15, 111, 111, 0.24),
    inset 0 1px 8px rgba(255, 255, 255, 0.12);
  flex: 0 0 auto;
}

.guide-help-icon-svg {
  width: 28px;
  height: 28px;
}

.guide-help-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(15, 111, 111, 0.12);
  color: var(--accent-strong);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.guide-help-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.guide-help-title {
  font-family: "Space Grotesk", sans-serif;
  font-size: 24px;
  font-weight: 700;
  line-height: 1.2;
}

.guide-help-copy {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

.guide-help-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 50px;
  padding: 12px 18px;
  border-radius: 16px;
  border: 1px solid rgba(15, 111, 111, 0.42);
  background:
    linear-gradient(135deg, #151515, #0f6f6f);
  color: #fff;
  text-decoration: none;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.24px;
  box-shadow:
    0 14px 24px rgba(21, 21, 21, 0.18),
    0 8px 18px rgba(15, 111, 111, 0.18);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
  white-space: nowrap;
}

.guide-help-button:hover {
  transform: translateY(-2px);
  box-shadow:
    0 18px 28px rgba(21, 21, 21, 0.24),
    0 12px 22px rgba(15, 111, 111, 0.24);
}

.guide-help-button-icon {
  width: 20px;
  height: 20px;
}

.history-layout {
  display: grid;
  gap: 18px;
}

.history-summary {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.78);
  padding: 16px 20px;
  box-shadow: 0 12px 30px rgba(31, 27, 26, 0.08);
}

.history-count {
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 700;
}

.history-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

.history-card {
  display: grid;
  grid-template-rows: 180px 1fr;
  min-height: 330px;
  border: 1px solid var(--line);
  border-radius: 18px;
  overflow: hidden;
  background: var(--panel);
  color: inherit;
  text-decoration: none;
  box-shadow: 0 16px 42px rgba(31, 27, 26, 0.1);
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.history-card:hover {
  transform: translateY(-2px);
  border-color: rgba(15, 111, 111, 0.28);
  box-shadow: 0 20px 48px rgba(31, 27, 26, 0.14);
}

.history-card-media {
  display: grid;
  place-items: center;
  min-width: 0;
  background:
    linear-gradient(135deg, rgba(22, 155, 155, 0.1), rgba(240, 138, 60, 0.08)),
    #fff;
  border-bottom: 1px solid var(--line);
}

.history-card-media img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 12px;
}

.history-card-body {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 8px;
  padding: 14px 16px 16px;
}

.history-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.history-card-title {
  min-width: 0;
  font-family: "Space Grotesk", sans-serif;
  font-size: 15px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.history-status {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 700;
}

.history-status.complete {
  background: rgba(22, 155, 155, 0.14);
  color: var(--accent-strong);
}

.history-status.partial {
  background: rgba(240, 138, 60, 0.16);
  color: #9a511d;
}

.history-card-meta,
.history-card-updated {
  color: var(--muted);
  font-size: 12px;
}

.history-card-action {
  margin-top: auto;
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 700;
}

.history-empty {
  max-width: 640px;
}

@media (max-width: 820px) {
  .guide-help-banner {
    grid-template-columns: 1fr;
    align-items: flex-start;
  }

  .guide-help-side {
    flex-direction: row;
  }

  .guide-help-button {
    width: 100%;
  }
}

.canvas-shell {
  height: 100%;
  border-radius: 24px;
  border: 1px solid var(--line);
  background: #fff;
  overflow: hidden;
  position: relative;
  box-shadow: var(--shadow);
}

.svg-frame {
  width: 100%;
  height: 100%;
  border: none;
  background: #fff;
}

.svg-fallback {
  position: absolute;
  inset: 0;
  padding: 24px;
  background: linear-gradient(135deg, rgba(22, 155, 155, 0.08), rgba(240, 138, 60, 0.08));
  display: none;
  flex-direction: column;
  gap: 12px;
}

.svg-fallback.active {
  display: flex;
}

.fallback-title {
  font-family: "Space Grotesk", sans-serif;
  font-size: 20px;
  font-weight: 600;
}

.fallback-body {
  font-size: 14px;
  color: var(--muted);
}

.fallback-object {
  flex: 1;
  width: 100%;
  border: 1px dashed var(--line);
  border-radius: 16px;
  background: #fff;
}

.fab {
  position: fixed;
  right: 28px;
  bottom: 28px;
  width: 60px;
  height: 60px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.4);
  background: linear-gradient(
    140deg,
    rgba(255, 255, 255, 0.55),
    rgba(255, 255, 255, 0.2)
  );
  box-shadow:
    0 20px 40px rgba(15, 111, 111, 0.2),
    inset 0 1px 6px rgba(255, 255, 255, 0.6);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  color: rgba(245, 245, 245, 0.92);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: transform 0.2s ease;
  z-index: 20;
}

.fab:hover {
  transform: translateY(-2px);
}

.fab-icon {
  width: 26px;
  height: 26px;
  color: currentColor;
}

.artifact-panel {
  position: fixed;
  right: 24px;
  bottom: 100px;
  width: 320px;
  max-height: 60vh;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 12px;
  box-shadow: var(--shadow);
  transform: translateY(30px);
  opacity: 0;
  pointer-events: none;
  transition: all 0.2s ease;
  z-index: 15;
  display: flex;
  flex-direction: column;
}

.log-panel {
  position: fixed;
  left: 24px;
  bottom: 24px;
  width: 420px;
  max-height: 40vh;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 12px;
  box-shadow: var(--shadow);
  transform: translateY(20px);
  opacity: 0;
  pointer-events: none;
  transition: all 0.2s ease;
  z-index: 12;
  display: flex;
  flex-direction: column;
}

.log-panel.open {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
}

.log-body {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
    "Liberation Mono", "Courier New", monospace;
  font-size: 12px;
  color: var(--muted);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px 10px;
  overflow-y: auto;
  white-space: pre-wrap;
  line-height: 1.4;
}

.artifact-panel.open {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
}

.panel-header {
  font-family: "Space Grotesk", sans-serif;
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 10px;
}

.artifact-list {
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.artifact-card {
  display: grid;
  grid-template-columns: 64px 1fr;
  gap: 10px;
  align-items: center;
  padding: 8px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fff;
  text-decoration: none;
  color: inherit;
}

.artifact-card img {
  width: 64px;
  height: 64px;
  object-fit: contain;
  border-radius: 10px;
  background: #f6f6f6;
  border: 1px solid rgba(31, 27, 26, 0.08);
}

.artifact-file-icon {
  width: 64px;
  height: 64px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  border: 1px solid rgba(31, 27, 26, 0.08);
  background: rgba(22, 155, 155, 0.08);
  color: var(--accent-strong);
  font-size: 11px;
  font-weight: 800;
}

.artifact-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.artifact-name {
  font-size: 13px;
  font-weight: 600;
}

.artifact-badge {
  font-size: 11px;
  color: var(--accent-strong);
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

@media (max-width: 900px) {
  .page,
  .canvas-page {
    padding: 22px 18px 56px;
  }

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

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

  .input-layout {
    grid-template-columns: 1fr;
  }

  .canvas-stage {
    height: calc(100vh - 180px);
  }
}
