:root {
  --bg: #0f172a;
  --surface: #1e293b;
  --primary: #3b82f6;
  --secondary: #8b5cf6;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --border: #334155;
  --radius: 1rem;
  --radius-xl: 1.5rem;
  --shadow: 0 20px 40px rgba(2,6,23,0.5);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Fira Sans", "Droid Sans", "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background: radial-gradient(1200px 600px at 10% 10%, rgba(59,130,246,0.08), transparent),
              radial-gradient(1000px 500px at 90% 20%, rgba(139,92,246,0.08), transparent),
              var(--bg);
}

.site-header {
  padding: 3rem 1rem 2rem;
  text-align: center;
  background: linear-gradient(135deg, rgba(59,130,246,0.15), rgba(139,92,246,0.15));
}
.header { text-align: center; margin-bottom: 3rem; }
.brand-super { font-size: 1rem; font-weight: 600; color: var(--muted); letter-spacing: 0.05em; text-transform: uppercase; margin-bottom: -0.5rem; }
.tool-name { font-size: 3.5rem; font-weight: 800; background: linear-gradient(135deg, var(--primary), var(--secondary)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; margin: 0.5rem 0; line-height: 1; }
.tagline { color: var(--muted); font-size: 1.2rem; font-weight: 400; margin-top: 0.5rem; }

.page { max-width: 960px; margin: 0 auto; padding: 0 1rem 2rem; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  padding: 1.25rem;
}
.card.input { margin-top: -2rem; }

textarea#question-input {
  width: 100%;
  padding: 1rem;
  background: #0b1220;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  resize: vertical;
  min-height: 160px;
}

.actions { display: flex; justify-content: flex-end; margin-top: 0.75rem; }
button#explain-btn {
  padding: 0.9rem 1.2rem;
  font-weight: 600;
  color: var(--text);
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  box-shadow: 0 12px 24px rgba(59,130,246,0.3);
}
button#explain-btn:hover { filter: brightness(1.05); }
button#explain-btn:disabled { opacity: 0.7; cursor: not-allowed; }

.loading { display: flex; align-items: center; gap: 0.75rem; margin-top: 1rem; color: var(--muted); }
.spinner { width: 20px; height: 20px; border-radius: 50%; border: 3px solid var(--border); border-top-color: var(--primary); animation: spin 0.8s linear infinite; }
@keyframes spin { from { transform: rotate(0); } to { transform: rotate(360deg); } }

.examples { display: grid; grid-template-columns: 1fr; gap: 0.75rem; margin: 1rem 0; }
.example-btn { text-align: left; background: #121a2b; color: var(--text); border: 1px solid var(--border); padding: 0.8rem 1rem; border-radius: var(--radius); cursor: pointer; }
.example-btn:hover { border-color: var(--primary); }

.card.results { margin-top: 1rem; }
.card.results h2 { margin: 0 0 0.75rem; }

.dashboard-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  align-items: stretch;
}
.panel {
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 0.75rem 1rem;
  box-shadow: var(--shadow);
}
.panel h3 {
  margin: 0 0 0.5rem 0;
  font-size: 1.1rem;
  color: var(--text);
}
.analysis-panel {
  background: linear-gradient(0deg, rgba(59,130,246,0.10), rgba(59,130,246,0.10)), var(--surface);
}
.guide-panel {
  background: linear-gradient(0deg, rgba(16,185,129,0.10), rgba(16,185,129,0.10)), var(--surface);
}
.panel-content {
  max-height: 50vh;
  overflow: auto;
}

.history-indicator {
  display: inline-block;
  font-size: 0.9rem;
  color: var(--muted);
  background: #0b1220;
  border: 1px solid var(--border);
  padding: 0.25rem 0.5rem;
  border-radius: 0.5rem;
  margin-bottom: 0.5rem;
}
.card.results.from-history {
  box-shadow: 0 0 0 2px rgba(59,130,246,0.5), var(--shadow);
}

.card.history { margin-top: 1rem; }
.card.history.collapsed .history-list { display: none; }
.history-header { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; }
.history-actions { display: flex; gap: 0.5rem; }
.history-actions .secondary {
  padding: 0.6rem 0.8rem;
  font-weight: 600;
  color: var(--text);
  background: #121a2b;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
}
.history-actions .secondary:hover { border-color: var(--primary); }
.history-list { list-style: none; padding: 0; margin: 0.5rem 0 0; }
.history-item {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.5rem 0.75rem;
  align-items: center;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  background: #0b1220;
  margin-bottom: 0.5rem;
  cursor: pointer;
}
.history-item:hover { border-color: var(--primary); }
.history-time { color: var(--muted); font-size: 0.85rem; }
.history-text { color: #e2e8f0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.history-empty { color: var(--muted); padding: 0.5rem; }

.markdown-output { line-height: 1.75; }
.markdown-output h1, .markdown-output h2, .markdown-output h3 { color: var(--text); }
.markdown-output h1 { font-size: 1.6rem; margin: 1.4rem 0 0.75rem; }
.markdown-output h2 { font-size: 1.3rem; margin: 1rem 0 0.5rem; }
.markdown-output h3 { font-size: 1.15rem; margin: 0.8rem 0 0.4rem; }
.markdown-output p { margin: 0.5rem 0; color: #e2e8f0; }
.markdown-output strong { color: #fafafa; }
.markdown-output em { color: #e5e7eb; }
.markdown-output hr { border: none; border-top: 1px solid var(--border); margin: 1rem 0; }
.markdown-output ul, .markdown-output ol { margin: 0.6rem 0 0.6rem 1.25rem; }
.markdown-output ul li { list-style: none; position: relative; padding-left: 0.75rem; }
.markdown-output ul li::before { content: ""; position: absolute; left: -0.75rem; top: 0.6rem; width: 8px; height: 8px; border-radius: 50%; background: var(--primary); }
.markdown-output ol { counter-reset: item; }
.markdown-output ol li { list-style: none; counter-increment: item; }
.markdown-output ol li::before { content: counter(item) "."; color: var(--secondary); margin-right: 0.5rem; }
.markdown-output code { background: #0b1220; padding: 0.15rem 0.35rem; border-radius: 6px; border: 1px solid var(--border); }
.markdown-output pre { background: #0b1220; border: 1px solid var(--border); padding: 1rem; border-radius: var(--radius); overflow: auto; }
.markdown-output a { color: var(--primary); text-decoration: none; }
.markdown-output a:hover { text-decoration: underline; }

.site-footer { text-align: center; color: var(--muted); padding: 2rem 1rem; }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }

@media (min-width: 640px) {
  .examples { grid-template-columns: repeat(3, 1fr); }
  .actions { justify-content: flex-end; }
}

@media (max-width: 768px) {
  .brand-super { font-size: 0.9rem; }
  .tool-name { font-size: 2.8rem; }
  .tagline { font-size: 1.1rem; }
  .dashboard-container { grid-template-columns: 1fr; }
}

@media (min-width: 768px) {
  .dashboard-container {
    grid-template-columns: 1fr 1fr;
    align-items: stretch;
  }
  .panel { height: 100%; }
}

/* ====== ENHANCED MAIN INPUT READABILITY ====== */
/* Targets the primary question input field */
#question-input {
  font-size: 1.15rem;       /* Increased base size for readability */
  line-height: 1.5;         /* Better vertical spacing between lines */
  padding: 14px 16px;       /* Comfortable internal padding */
  font-family: inherit;     /* Matches the rest of the site's font */
  min-height: 160px;        /* Keeps the existing comfortable height */
  resize: vertical;         /* Allows users to resize if needed */
}

/* Improves the placeholder text visibility */
#question-input::placeholder {
  font-size: 1rem;          /* Slightly smaller than active text */
  color: #6b7280;           /* Accessible, readable gray */
  opacity: 1;               /* Normalize placeholder opacity across browsers */
}

/* Enhance focus state for better UX */
#question-input:focus {
  outline: 2px solid var(--primary); /* Clear focus indicator aligned with theme */
  outline-offset: 2px;
}
