:root {
  --bg: #f7f4ed;
  --ink: #19140f;
  --card: #fffdf9;
  --accent: #2f6f5f;
  --accent-ink: #ffffff;
  --muted: #6a6259;
  --border: #d9d0c4;
}

* {
  box-sizing: border-box;
}

.hidden {
  display: none !important;
}

body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 10% 0%, #ebe2d5 0, transparent 50%),
    radial-gradient(circle at 90% 100%, #efe7db 0, transparent 45%),
    var(--bg);
  min-height: 100vh;
  padding: 24px 16px;
}

.wrap {
  width: min(920px, 100%);
  margin: 0 auto;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.06);
}

h1 {
  margin: 0 0 8px;
  font-size: clamp(22px, 4vw, 32px);
  line-height: 1.1;
}

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

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

.logo {
  width: 86px;
  height: 86px;
  border-radius: 18px;
  border: 1px solid var(--border);
  display: block;
  background: radial-gradient(circle at 25% 20%, #fff5e6 0%, #f1e2cf 58%, #e3d2bc 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
  overflow: hidden;
  flex: 0 0 auto;
}

.logo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

h2 {
  margin: 0 0 10px;
  font-size: 17px;
}

p {
  margin: 0 0 14px;
  color: var(--muted);
}

textarea {
  width: 100%;
  min-height: 96px;
  resize: vertical;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  font-size: 16px;
  font-family: inherit;
  color: var(--ink);
  background: #fff;
}

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

.tabs {
  display: flex;
  gap: 10px;
  margin: 10px 0 14px;
}

.workspace-divider {
  margin: 14px 0 10px;
  border-top: 1px solid var(--border);
}

.tab {
  border-color: var(--border);
  background: #fff;
  color: var(--ink);
}

.tab.active {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
}

.panel {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  background: #fff;
  margin-top: 12px;
}

.tab-panel {
  background: #fffdfa;
}

.settings {
  background: #faf8f3;
}

.api-key-panel {
  background: #f9f7f2;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.panel-toggle {
  min-width: 84px;
}

.quick-edit {
  margin-top: 16px;
  border-color: #b9d8cd;
  background: #f4fbf7;
}

.quick-edit-kicker {
  margin: 0 0 8px;
  padding-top: 2px;
  padding-bottom: 8px;
  border-bottom: 1px solid #cfe3da;
  color: #3f6d5f;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

label {
  font-size: 14px;
  color: var(--muted);
}

select,
input,
button,
.download {
  border-radius: 10px;
  border: 1px solid var(--border);
  padding: 10px 12px;
  font-size: 15px;
  font-family: inherit;
}

select,
input {
  background: #fff;
  color: var(--ink);
}

input[type="number"] {
  width: 90px;
}

.settings-grid {
  margin-top: 8px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}

.settings-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.settings-field select,
.settings-field input {
  width: 100%;
}

.settings-field-small {
  max-width: 140px;
}

button {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
  cursor: pointer;
}

button.secondary {
  border-color: var(--border);
  background: #fff;
  color: var(--ink);
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.download {
  text-decoration: none;
  color: var(--ink);
  background: #fff;
  display: none;
}

.status {
  margin-top: 12px;
  min-height: 24px;
  color: var(--muted);
  font-size: 14px;
}

.status.inline {
  margin-top: 6px;
}

.canvas {
  margin-top: 14px;
  border: 1px dashed var(--border);
  border-radius: 12px;
  overflow: hidden;
  min-height: 120px;
  background: #fff;
  display: grid;
  place-items: center;
}

.canvas.hidden {
  display: none;
}

.canvas.small {
  min-height: 90px;
  max-width: 260px;
}

#preview,
#externalPreview,
#externalResultPreview {
  max-width: 100%;
  display: none;
}

.history {
  margin-top: 14px;
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
}

.thumb {
  position: relative;
  border: 2px solid transparent;
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  background: #fff;
  padding: 0;
}

.thumb.active {
  border-color: var(--accent);
}

.thumb-delete {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  border: 1px solid rgba(0, 0, 0, 0.2);
  background: rgba(255, 255, 255, 0.95);
  color: #2d2925;
  font-size: 14px;
  line-height: 1;
  padding: 0;
}

.thumb img {
  display: block;
  width: 100%;
  height: 96px;
  object-fit: cover;
}

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

.upload-input {
  max-width: 300px;
  background: #fff;
}

.api-key-input {
  min-width: min(420px, 100%);
  flex: 1 1 320px;
}

.saved-key {
  color: #4d463f;
  background: #f3eee6;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
}

.interest-amount-input {
  min-width: min(280px, 100%);
  flex: 1 1 280px;
}

#contactEmail,
#contactMessage {
  width: min(560px, 100%);
}

.honeypot {
  position: absolute !important;
  left: -9999px !important;
  top: auto !important;
  width: 1px !important;
  height: 1px !important;
  overflow: hidden !important;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(12, 10, 8, 0.55);
  display: grid;
  place-items: center;
  padding: 16px;
  z-index: 999;
}

.modal-card {
  width: min(680px, 100%);
  background: #fffdf9;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  position: relative;
}

.modal-close {
  position: absolute;
  top: 10px;
  right: 10px;
  border-color: var(--border);
  background: #fff;
  color: var(--ink);
  width: 34px;
  height: 34px;
  border-radius: 999px;
  padding: 0;
}

.footer-note {
  margin-top: 16px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
}
