* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f5f5f7;
  color: #1d1d1f;
  line-height: 1.6;
}

.container { max-width: 1000px; margin: 0 auto; padding: 24px 20px 60px; }

header { text-align: center; padding: 40px 0 32px; }
header h1 { font-size: 32px; font-weight: 700; }
.subtitle { color: #86868b; margin-top: 8px; font-size: 16px; }

/* API Key */
.api-key-section { text-align: right; margin-bottom: 16px; }
.btn-text { background: none; border: none; color: #86868b; cursor: pointer; font-size: 14px; padding: 4px 8px; }
.btn-text:hover { color: #1d1d1f; }
#apiKeyPanel {
  background: white; border-radius: 12px; padding: 16px; margin-top: 8px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}
#apiKeyPanel.hidden { display: none; }
.api-info {
  background: #f0f7ff; border-radius: 8px; padding: 12px 16px; margin-bottom: 12px;
  font-size: 13px; color: #515154; line-height: 1.7;
}
.api-info a { color: #0071e3; }
.api-input-row { display: flex; align-items: center; gap: 10px; }
.api-input-row label { font-size: 14px; color: #86868b; white-space: nowrap; }
.api-input-row input { flex: 1; padding: 8px 12px; border: 1px solid #d2d2d7; border-radius: 8px; font-size: 14px; }
#apiStatus { font-size: 13px; color: #34c759; }

/* Input Section */
.input-section {
  background: white; border-radius: 16px; padding: 24px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.form-row { display: flex; gap: 16px; margin-bottom: 16px; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 6px; color: #515154; }
.form-group input[type="text"],
.form-group select {
  width: 100%; padding: 10px 14px; border: 1px solid #d2d2d7;
  border-radius: 10px; font-size: 15px; font-family: inherit;
}
.form-group input[type="color"] {
  width: 100%; height: 40px; border: 1px solid #d2d2d7; border-radius: 10px; cursor: pointer; padding: 2px;
}
.form-group input:focus, .form-group select:focus {
  outline: none; border-color: #0071e3; box-shadow: 0 0 0 3px rgba(0,113,227,0.1);
}
.flex-2 { flex: 2; }
.flex-1 { flex: 1; }

/* Buttons */
.btn-primary {
  background: #0071e3; color: white; border: none; border-radius: 10px;
  padding: 10px 24px; font-size: 15px; font-weight: 600; cursor: pointer; transition: background 0.2s;
}
.btn-primary:hover { background: #0077ed; }
.btn-primary:disabled { background: #a1c9f5; cursor: not-allowed; }
.btn-lg { padding: 14px 40px; font-size: 17px; width: 100%; margin-top: 8px; }
.btn-sm { padding: 6px 16px; font-size: 13px; }
.btn-outline {
  background: white; color: #0071e3; border: 2px solid #0071e3; border-radius: 10px;
  padding: 10px 24px; font-size: 15px; font-weight: 600; cursor: pointer;
  transition: all 0.2s;
}
.btn-outline:hover { background: #0071e3; color: white; }

/* Loading */
#loading { text-align: center; padding: 40px; color: #86868b; }
#loading.hidden { display: none; }
.loading-detail { font-size: 13px; color: #a1a1a6; margin-top: 4px; }

.spinner {
  width: 32px; height: 32px; border: 3px solid #e8e8ed; border-top-color: #0071e3;
  border-radius: 50%; animation: spin 0.8s linear infinite; margin: 0 auto 12px;
}
@keyframes spin { to { transform: rotate(360deg); } }

#error { background: #fff2f0; border: 1px solid #ffccc7; color: #cf1322; border-radius: 12px; padding: 16px; margin-top: 16px; }
#error.hidden { display: none; }

#result { margin-top: 24px; }
#result.hidden { display: none; }

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

/* Preview Area */
.preview-area { background: white; border-radius: 16px; padding: 24px; box-shadow: 0 1px 4px rgba(0,0,0,0.06); }

.preview-tabs { display: flex; gap: 8px; margin-bottom: 16px; }
.preview-tab {
  padding: 6px 16px; border: 1px solid #d2d2d7; border-radius: 8px;
  background: white; font-size: 13px; cursor: pointer; font-weight: 500;
}
.preview-tab.active { border-color: #0071e3; color: #0071e3; background: #f0f7ff; }

.preview-bg {
  border-radius: 12px; min-height: 220px; display: none; align-items: center;
  justify-content: center; padding: 32px 28px;
}
.preview-bg.active { display: flex; }
.preview-bg.light { background: #ffffff; border: 2px dashed #d2d2d7; }
.preview-bg.dark { background: #1d1d1f; }

/* Click to zoom cursor on all preview areas */
.preview-bg.dark,
.preview-bg.light,
.preview-bg.mockup .mockup-card {
  cursor: zoom-in;
}

.preview-bg.dark svg { max-width: 100%; max-height: 140px; }
.preview-bg.light svg { max-width: 100%; max-height: 160px; }

/* ── Zoom Modal ────────────────────────────────── */
.zoom-modal {
  position: fixed; inset: 0; z-index: 9999;
  display: flex; align-items: center; justify-content: center;
}
.zoom-modal.hidden { display: none; }
.zoom-backdrop {
  position: absolute; inset: 0; background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
}
.zoom-content {
  position: relative; z-index: 1;
  background: white; border-radius: 20px; padding: 40px;
  max-width: 90vw; max-height: 85vh;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  overflow: auto;
}
.zoom-content svg {
  max-width: 100%; max-height: 75vh;
  width: auto; height: auto;
}
.zoom-close {
  position: fixed; top: 20px; right: 24px; z-index: 10001;
  background: rgba(255,255,255,0.15); color: white; border: none;
  width: 44px; height: 44px; border-radius: 50%; font-size: 28px;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: background 0.2s;
}
.zoom-close:hover { background: rgba(255,255,255,0.3); }

/* Brand Kit Mockups (Looka style) */
.preview-bg.mockup { background: #f5f5f7; padding: 16px 12px; }
.mockup-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; width: 100%; }
.mockup-item { text-align: center; }
.mockup-label { font-size: 11px; color: #86868b; margin-bottom: 6px; }
.mockup-card {
  border-radius: 10px; margin: 0 auto;
  display: flex; align-items: center; justify-content: center;
  background: white; box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  padding: 8px;
}
.mockup-card svg { max-width: 95%; max-height: 95%; display: block; }
.mockup-card.biz-card { width: 100%; max-width: 220px; height: 120px; }
.mockup-card.web-header { width: 100%; max-width: 220px; height: 90px; background: #f5f5f7; border: 1px solid #e8e8ed; }
.mockup-card.app-icon { width: 100px; height: 100px; border-radius: 20px; }
.mockup-card.social-card { width: 100%; max-width: 220px; height: 110px; background: #f5f5f7; border: 1px solid #e8e8ed; }

.preview-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }

/* Info Area */
.info-area { display: flex; flex-direction: column; gap: 16px; }

.card {
  background: white; border-radius: 12px; padding: 24px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.card h3 { font-size: 16px; margin-bottom: 12px; color: #1d1d1f; }
.card p, .card li { font-size: 14px; color: #515154; margin-bottom: 6px; }

/* Color Palette */
.color-swatches { display: flex; gap: 10px; flex-wrap: wrap; }
.color-swatch {
  width: 44px; height: 44px; border-radius: 12px; border: 2px solid #e8e8ed;
  position: relative; cursor: pointer;
}
.color-swatch:hover { border-color: #0071e3; transform: scale(1.1); transition: all 0.15s; }
.color-swatch .swatch-hex {
  position: absolute; bottom: -18px; left: 50%; transform: translateX(-50%);
  font-size: 10px; color: #86868b; white-space: nowrap;
}

/* History */
#history { margin-top: 40px; }
#history.hidden { display: none; }
#history h3 { font-size: 20px; margin-bottom: 16px; }
#historyList {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px;
}
.history-item {
  background: white; border-radius: 12px; padding: 16px; cursor: pointer; text-align: center;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06); transition: box-shadow 0.2s;
}
.history-item:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.12); }
.history-item svg { max-width: 100%; max-height: 60px; }
.history-item .name { font-size: 12px; color: #86868b; margin-top: 8px; }

@media (max-width: 768px) {
  .result-layout { grid-template-columns: 1fr; }
  .form-row { flex-direction: column; }
  .mockup-grid { grid-template-columns: 1fr 1fr; }
}

/* Beta tag */
.beta-tag {
  font-size: 13px;
  font-weight: 500;
  color: #0071e3;
  background: #e8f0fe;
  padding: 2px 8px;
  border-radius: 6px;
  vertical-align: top;
  margin-left: 6px;
}

/* Articles section */
.articles-section h2 { font-size: 28px; font-weight: 700; }
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
  margin-top: 20px;
}
.card-grid .card {
  background: white;
  border-radius: 12px;
  padding: 24px;
  text-decoration: none;
  color: #1d1d1f;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
  transition: box-shadow 0.2s, transform 0.2s;
}
.card-grid .card:hover {
  box-shadow: 0 4px 16px rgba(0,0,0,0.1);
  transform: translateY(-2px);
}
.card-grid .card h3 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 8px;
  color: #1d1d1f;
}
.card-grid .card p {
  font-size: 14px;
  color: #86868b;
  line-height: 1.5;
}
.tag {
  font-size: 11px;
  font-weight: 500;
  color: #6e6e73;
  background: #f0f0f2;
  padding: 4px 10px;
  border-radius: 4px;
}
