:root {
  color-scheme: light;
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-soft: #fafafa;
  --text: #1f2937;
  --muted: #667085;
  --line: #e5e7eb;
  --accent: #e20074;
  --accent-strong: #b9005f;
  --danger: #dc2626;
  --success: #16a34a;
  --shadow: 0 8px 20px rgba(0, 0, 0, 0.10);
  --focus: 0 0 0 3px rgba(226, 0, 116, 0.18);
  font-family: "Segoe UI", Arial, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: inherit;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(226, 0, 116, 0.08), transparent 320px),
    var(--bg);
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 38px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

button:not(:disabled):hover {
  border-color: rgba(226, 0, 116, 0.35);
  background: rgba(226, 0, 116, 0.06);
  color: var(--accent);
}

button:disabled {
  cursor: not-allowed;
  color: var(--muted);
  background: transparent;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  max-width: 1280px;
  min-height: 68px;
  margin: 16px auto 0;
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  position: sticky;
  top: 12px;
  z-index: 10;
}

.brand-wrap {
  display: inline-flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  background: var(--accent);
  border-radius: 8px;
  box-shadow: inset 0 -10px 20px rgba(0, 0, 0, 0.10);
}

.topbar h1 {
  margin: 0 0 2px;
  font-size: 20px;
  font-weight: 800;
  line-height: 1.12;
}

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

.format-toggle {
  display: inline-flex;
  gap: 8px;
}

.format-btn {
  min-height: 34px;
  padding: 7px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.format-btn:not(:disabled):hover {
  color: var(--accent);
  border-color: rgba(226, 0, 116, 0.35);
  background: var(--surface);
}

.format-btn.active,
.format-btn.active:not(:disabled):hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

.workspace {
  max-width: 1280px;
  margin: 0 auto;
  padding: 16px 0 28px;
  display: grid;
  grid-template-columns: minmax(360px, 440px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.tool-panel,
.preview-panel {
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
}

.tool-panel {
  padding: 16px;
}

.tool-panel section + section {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

h2 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0 0 12px;
  font-size: 16px;
  font-weight: 800;
}

.tool-panel h2::after,
.preview-toolbar h2::after {
  content: "";
  height: 1px;
  flex: 1;
  margin-left: 12px;
  background: var(--line);
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.option-field {
  margin-bottom: 12px;
}

.option-label {
  display: block;
  margin-bottom: 6px;
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
}

.option-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.option-btn {
  min-height: 32px;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.option-btn:not(:disabled):hover {
  color: var(--accent);
  border-color: rgba(226, 0, 116, 0.35);
  background: var(--surface);
}

.option-btn.active,
.option-btn.active:not(:disabled):hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

.custom-size {
  margin-bottom: 12px;
}

details.advanced {
  margin-top: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-soft);
  overflow: hidden;
}

details.advanced summary {
  cursor: pointer;
  list-style: none;
  padding: 12px;
  font-size: 13px;
  font-weight: 800;
}

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

details.advanced summary::after {
  content: "+";
  float: right;
  color: var(--accent);
  font-weight: 900;
}

details.advanced[open] summary::after {
  content: "\2212";
}

details.advanced .field-grid {
  border-top: 1px solid var(--line);
  padding: 12px;
}

label {
  display: grid;
  gap: 5px;
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
}

label span {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-weight: 400;
}

input,
select {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: #ffffff;
  color: #111827;
}

input:focus,
select:focus {
  outline: none;
  border-color: rgba(226, 0, 116, 0.55);
  box-shadow: var(--focus);
}

.summary-strip {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 16px;
}

.summary-item {
  padding: 12px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.summary-item span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.summary-item strong {
  display: block;
  margin-top: 4px;
  font-size: 17px;
  color: var(--accent);
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 16px;
}

.primary,
.primary:not(:disabled):hover {
  border: none;
  background: var(--accent);
  color: #ffffff;
}

.primary:not(:disabled):hover {
  background: var(--accent-strong);
}

.status {
  min-height: 20px;
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.status.error {
  color: var(--danger);
  font-weight: 700;
}

.preview-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-height: calc(100vh - 148px);
  overflow: hidden;
}

.preview-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.preview-toolbar h2 {
  margin: 0;
  flex: 1;
}

.preview-toolbar span {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.preview-canvas {
  min-height: 480px;
  overflow: auto;
  padding: 18px;
  background:
    linear-gradient(var(--line) 1px, transparent 1px),
    linear-gradient(90deg, var(--line) 1px, transparent 1px),
    var(--surface-soft);
  background-size: 20px 20px;
}

.preview-canvas svg {
  display: block;
  width: 100%;
  max-width: 1100px;
  height: auto;
  margin: 0 auto;
  background: #ffffff;
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.empty-state {
  display: grid;
  min-height: 300px;
  place-items: center;
  border: 1px dashed var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.76);
  color: var(--muted);
}

.fido-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(17, 24, 39, 0.66);
}

.fido-overlay[hidden] {
  display: none;
}

.fido-box {
  width: min(420px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 28px;
  text-align: center;
}

.fido-mark {
  display: inline-flex;
  min-height: 32px;
  align-items: center;
  margin-bottom: 14px;
  padding: 6px 10px;
  border: 1px solid rgba(226, 0, 116, 0.28);
  border-radius: 8px;
  background: rgba(226, 0, 116, 0.08);
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 900;
}

.fido-box h2 {
  justify-content: center;
  margin-bottom: 8px;
  font-size: 20px;
}

.fido-status {
  min-height: 40px;
  color: var(--muted);
}

.fido-btn,
.fido-btn:not(:disabled):hover {
  min-width: 160px;
  border: none;
  background: var(--accent);
  color: #ffffff;
}

.fido-btn:not(:disabled):hover {
  background: var(--accent-strong);
}

@media (max-width: 1320px) {
  .topbar,
  .workspace {
    margin-left: 16px;
    margin-right: 16px;
  }
}

@media (max-width: 940px) {
  body {
    background: var(--bg);
  }

  .topbar {
    top: 0;
    margin-top: 0;
    border-radius: 0 0 14px 14px;
  }

  .workspace {
    grid-template-columns: 1fr;
    padding: 12px 0 20px;
  }

  .preview-panel {
    min-height: 560px;
  }
}

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

  .field-grid,
  .summary-strip,
  .actions {
    grid-template-columns: 1fr;
  }
}
