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

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Helvetica Neue', sans-serif;
  background: #f5f5f7;
  color: #111;
  font-size: 14px;
  user-select: none;
}

input, button, select, textarea {
  font: inherit;
  user-select: text;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.topbar {
  height: 38px;
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid #e5e5ea;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px 0 80px;
  -webkit-app-region: drag;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: #444;
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #1a1a2e;
}

.log-btn {
  -webkit-app-region: no-drag;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: #f0f0f3;
  border: 1px solid #d8d8dc;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  color: #333;
  transition: background .12s ease;
}
.log-btn:hover { background: #e6e6eb; }
.log-btn:active { background: #d8d8dc; }

.container {
  flex: 1;
  overflow-y: auto;
  padding: 24px 24px 40px;
  display: flex;
  justify-content: center;
}

.card {
  background: white;
  border-radius: 12px;
  box-shadow: 0 2px 16px rgba(0,0,0,0.08);
  padding: 28px 32px;
  width: 100%;
  max-width: 560px;
}

.card + .card { margin-top: 20px; }

h1 {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 22px;
  color: #111;
}

h2 {
  font-size: 11px;
  font-weight: 600;
  color: #555;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 10px;
}

section + section { margin-top: 22px; }

label {
  display: block;
  font-size: 13px;
  color: #444;
}

label input {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 9px 12px;
  border: 1px solid #d4d4d8;
  border-radius: 7px;
  outline: none;
  font-size: 14px;
  background: white;
  transition: border-color .12s, box-shadow .12s;
}

label input:focus {
  border-color: #1a1a2e;
  box-shadow: 0 0 0 3px rgba(26,26,46,0.12);
}

label input[type="file"] {
  padding: 8px 12px;
  background: #fafafc;
  cursor: pointer;
}

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

.template-saved {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: #f0fdf4;
  border: 1px solid #86efac;
  border-radius: 7px;
  font-size: 13px;
}

.template-saved .name {
  flex: 1;
  color: #166534;
  font-weight: 500;
}

.template-saved button {
  background: none;
  border: none;
  color: #6b7280;
  text-decoration: underline;
  font-size: 12px;
  cursor: pointer;
  padding: 0;
}

.template-saved button:hover { color: #1a1a2e; }

button.primary {
  width: 100%;
  padding: 13px 18px;
  background: #1a1a2e;
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 28px;
  transition: background .12s;
}

button.primary:hover { background: #2a2a4a; }
button.primary:disabled { opacity: 0.5; cursor: not-allowed; }

button.secondary {
  width: 100%;
  padding: 13px 18px;
  background: white;
  color: #1a1a2e;
  border: 1.5px solid #1a1a2e;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

button.secondary:hover { background: #f5f5f7; }

.status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 14px;
  color: #555;
  font-size: 13px;
}

.spinner {
  width: 14px;
  height: 14px;
  border: 2px solid #ccc;
  border-top-color: #1a1a2e;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.hidden { display: none !important; }

.error {
  background: #fef2f2;
  border-left: 4px solid #dc2626;
  padding: 12px 14px;
  margin-bottom: 18px;
  border-radius: 4px;
  font-size: 13px;
  color: #7f1d1d;
  white-space: pre-wrap;
  font-family: ui-monospace, monospace;
  max-height: 200px;
  overflow-y: auto;
}

.success .check {
  font-size: 36px;
  color: #16a34a;
  margin-bottom: 6px;
}

.success h2 {
  font-size: 22px;
  font-weight: 700;
  text-transform: none;
  letter-spacing: 0;
  color: #111;
  margin-bottom: 6px;
}

.success p {
  color: #555;
  margin-bottom: 18px;
}

.success .actions {
  display: flex;
  gap: 10px;
  margin-top: 14px;
}

.success .actions button { margin-top: 0; }

.warn {
  background: #fffbeb;
  border-left: 4px solid #f59e0b;
  padding: 10px 14px;
  margin: 12px 0;
  border-radius: 4px;
  font-size: 13px;
  color: #78350f;
}

/* ── Log panel ─────────────────────────────────────────────────────────── */
.log-panel {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 45%;
  background: #1e1e2e;
  border-top: 1px solid #2d2d3f;
  display: flex;
  flex-direction: column;
  box-shadow: 0 -8px 24px rgba(0,0,0,0.25);
  z-index: 100;
}

.log-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background: #2a2a3e;
  border-bottom: 1px solid #38384f;
}

.log-header h3 {
  font-size: 12px;
  font-weight: 600;
  color: #cdd6f4;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.log-actions {
  display: flex;
  gap: 6px;
}

.log-actions button {
  background: #38384f;
  color: #cdd6f4;
  border: none;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 11px;
  cursor: pointer;
}
.log-actions button:hover { background: #45455e; }

.log-content {
  flex: 1;
  overflow-y: auto;
  padding: 10px 14px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11.5px;
  line-height: 1.55;
  color: #cdd6f4;
}

.log-content .entry {
  margin: 0;
  padding: 1px 0;
  white-space: pre-wrap;
  word-break: break-word;
}

.log-content .entry .ts { color: #6c7086; margin-right: 8px; }
.log-content .entry .level { display: inline-block; width: 50px; font-weight: 600; }
.log-content .entry.INFO  .level { color: #89b4fa; }
.log-content .entry.DEBUG .level { color: #6c7086; }
.log-content .entry.WARN  .level { color: #f9e2af; }
.log-content .entry.ERROR .level { color: #f38ba8; }

.log-content .empty {
  color: #6c7086;
  font-style: italic;
  padding: 8px 0;
}
