:root {
  --bg: #12141c;
  --surface: #191c27;
  --surface-2: #21243250;
  --border: #2c3042;
  --text: #e8e8f0;
  --text-dim: #9498ab;
  --accent: #7c8cff;
  --accent-2: #2fe0c5;
  --danger: #ff6b6b;
  --radius: 14px;
  --font-display: "Fraunces", "Georgia", serif;
  --font-body: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: radial-gradient(circle at 15% 0%, #1c2033 0%, var(--bg) 55%);
  color: var(--text);
  font-family: var(--font-body);
  min-height: 100vh;
}

.app { max-width: 1180px; margin: 0 auto; padding: 32px 20px 60px; }

.app-header { text-align: center; margin-bottom: 36px; }
.brand { display: flex; align-items: center; justify-content: center; gap: 10px; }
.brand-mark {
  font-size: 22px; color: var(--accent-2);
  text-shadow: 0 0 18px rgba(47, 224, 197, 0.6);
}
.app-header h1 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(28px, 4vw, 40px);
  margin: 0;
  letter-spacing: -0.01em;
}
.tagline { color: var(--text-dim); margin-top: 6px; font-size: 15px; }

.layout {
  display: grid;
  grid-template-columns: 1.1fr 1.7fr 0.55fr;
  gap: 20px;
  align-items: start;
}

@media (max-width: 920px) {
  .layout { grid-template-columns: 1fr; }
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
}

.panel h2 {
  font-family: var(--font-display);
  font-size: 19px;
  margin: 0 0 16px;
  font-weight: 600;
}

label {
  display: block;
  font-size: 13px;
  color: var(--text-dim);
  margin: 14px 0 6px;
}
label:first-of-type { margin-top: 0; }
.optional { color: #5c6079; }

select, textarea, input[type="text"] {
  width: 100%;
  background: #0f1119;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  padding: 10px 12px;
  font-family: inherit;
  font-size: 14px;
  resize: vertical;
}
select:focus, textarea:focus, input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

input[type="range"] { width: 100%; accent-color: var(--accent); margin-top: 6px; }

#submitBtn {
  margin-top: 20px;
  width: 100%;
  background: linear-gradient(135deg, var(--accent), #5a67e8);
  color: #fff;
  border: none;
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
#submitBtn:hover { transform: translateY(-1px); box-shadow: 0 8px 20px rgba(124, 140, 255, 0.35); }
#submitBtn:disabled { opacity: 0.6; cursor: progress; transform: none; box-shadow: none; }

.hint { color: #5c6079; font-size: 12px; margin-top: 10px; }

.result-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.result-header h2 { margin: 0; }

.secondary-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
}
.secondary-btn:hover:not(:disabled) { border-color: var(--accent); color: var(--text); }
.secondary-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.result-box {
  min-height: 280px;
  max-height: 520px;
  overflow-y: auto;
  line-height: 1.6;
  font-size: 14.5px;
}
.result-box .placeholder, .history-list .placeholder { color: #5c6079; font-size: 14px; }
.result-box strong { color: var(--accent-2); }
.result-box ol, .result-box ul { padding-left: 20px; }
.result-box .cursor {
  display: inline-block; width: 7px; height: 15px;
  background: var(--accent-2); margin-left: 2px;
  animation: blink 1s step-start infinite; vertical-align: middle;
}
@keyframes blink { 50% { opacity: 0; } }

.history-panel { padding: 18px; }
.history-panel h2 { font-size: 16px; }

.history-list { display: flex; flex-direction: column; gap: 6px; max-height: 560px; overflow-y: auto; }

/* Compact single-line "recents" style row */
.history-item {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #0f1119;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 12.5px;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.history-item:hover { border-color: var(--accent); background: #141726; }

.history-item .h-cat {
  color: var(--accent-2);
  text-transform: capitalize;
  font-weight: 600;
  flex-shrink: 0;
}
.history-item .h-prefs {
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}
.history-item .h-chevron { color: #5c6079; flex-shrink: 0; }

/* Full-page detail "tab" shown when a saved item is opened */
.history-detail-view { padding-top: 4px; }
.history-detail-view.hidden { display: none; }

.back-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  margin-bottom: 18px;
}
.back-btn:hover { border-color: var(--accent); color: var(--text); }

.detail-card { max-width: 820px; margin: 0 auto; }
.detail-meta { display: flex; justify-content: space-between; margin-bottom: 10px; }
.detail-card h3 {
  font-family: var(--font-display);
  font-size: 15px;
  margin: 18px 0 6px;
  color: var(--accent);
}
.detail-text { color: var(--text-dim); font-size: 14px; line-height: 1.6; }
.detail-result { min-height: 0; max-height: none; }
.danger-btn { margin-top: 22px; color: var(--danger); border-color: var(--border); }
.danger-btn:hover { border-color: var(--danger); }

.app-footer { text-align: center; color: #4a4e63; font-size: 12px; margin-top: 40px; }
