:root {
  --font-ui: "Sora", "Avenir Next", "Segoe UI", sans-serif;
  --font-display: "Space Grotesk", "Sora", "Segoe UI", sans-serif;

  --ink: #10233f;
  --muted: #4c6488;

  --bg-1: #ffe6b9;
  --bg-2: #b8d6ff;
  --bg-3: #f5f9ff;

  --header-bg: rgba(255, 255, 255, 0.9);
  --header-border: rgba(20, 45, 84, 0.2);

  --surface-bg: #ffffff;
  --surface-border: #ccdaef;
  --surface-shadow: 0 12px 24px rgba(17, 43, 80, 0.1);

  --field-bg: #ffffff;
  --field-border: #b8cae5;
  --field-focus: #0b73d0;
  --focus-ring: rgba(11, 115, 208, 0.26);

  --button-bg: #0b73d0;
  --button-bg-hover: #095fad;
  --button-ink: #ffffff;
  --button-secondary: #35557f;

  --feedback-bad-bg: #fff1ea;
  --feedback-bad-border: #d9653d;
  --feedback-neutral-bg: #f1f5fb;
  --feedback-neutral-border: #8ba2c5;
  --feedback-positive-bg: #e9f8ef;
  --feedback-positive-border: #42a06a;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: var(--font-ui);
  background:
    repeating-linear-gradient(
      to right,
      rgba(32, 66, 114, 0.07) 0,
      rgba(32, 66, 114, 0.07) 1px,
      transparent 1px,
      transparent 24px
    ),
    repeating-linear-gradient(
      to bottom,
      rgba(32, 66, 114, 0.07) 0,
      rgba(32, 66, 114, 0.07) 1px,
      transparent 1px,
      transparent 24px
    ),
    radial-gradient(100% 58% at -12% -20%, var(--bg-1) 0%, transparent 66%),
    radial-gradient(90% 56% at 112% -24%, var(--bg-2) 0%, transparent 60%),
    linear-gradient(160deg, var(--bg-3), #eef4ff);
}

.top-design-header {
  position: sticky;
  top: 0;
  z-index: 20;
  height: 48px;
  padding: 0 0.85rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--header-border);
  background: var(--header-bg);
  backdrop-filter: blur(10px);
}

.brand-lockup {
  display: inline-flex;
  align-items: center;
  line-height: 1;
  flex-shrink: 0;
}

.brand-logo {
  display: block;
  width: auto;
  height: 30px;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.page-shell {
  max-width: 1040px;
  margin: 0.9rem auto 2rem;
  padding: 0 1rem;
  display: grid;
  gap: 1rem;
}

.legacy-banner {
  padding: 0.9rem 1rem;
  border-left: 4px solid #c43d1b;
  background: #fff5f1;
}

.legacy-banner p {
  margin: 0;
  color: #7a2913;
  font-size: 0.95rem;
  line-height: 1.5;
}

.legacy-banner a {
  color: #9c2e12;
  font-weight: 700;
}

body.auth-view .header-controls,
body.auth-view .hero,
body.auth-view .app-shell-grid {
  display: none;
}

body.auth-view .page-shell {
  max-width: 460px;
  margin-top: 3.25rem;
}

body.auth-view .auth-card {
  padding: 1.35rem 1.3rem;
  border-left: 4px solid var(--button-bg);
}

body.auth-view .auth-actions {
  margin-top: 1rem;
}

body.auth-view .auth-actions button {
  width: 100%;
  font-size: 1.02rem;
  padding: 0.74rem 1rem;
}

body.auth-view .status {
  font-size: 1rem;
  line-height: 1.45;
}

.card {
  background: var(--surface-bg);
  border: 1px solid var(--surface-border);
  border-radius: 10px;
  box-shadow: var(--surface-shadow);
}

.hero {
  display: grid;
  grid-template-columns: 1fr;
  align-items: center;
  padding: 1.1rem 1.2rem;
  border-left: 4px solid var(--button-bg);
}

h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.35rem, 1.1rem + 0.65vw, 1.8rem);
  letter-spacing: -0.01em;
}

.subtitle {
  margin: 0.35rem 0 0;
  color: var(--muted);
}

.auth-card,
.query-card,
.result {
  padding: 1rem 1.05rem;
}

.hard-filters-panel {
  margin-top: 0.9rem;
}

.hard-filters-panel h3 {
  margin: 0 0 0.4rem;
  font-family: var(--font-display);
  font-size: 0.98rem;
}

.hard-filters-list {
  padding: 0.8rem 0.9rem;
  border: 1px solid var(--surface-border);
  border-radius: 8px;
  background: #f6f9ff;
}

.hard-filters-line {
  margin: 0;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.5;
}

.hard-filters-line + .hard-filters-line {
  margin-top: 0.25rem;
}

.hard-filters-label {
  color: var(--ink);
  font-weight: 700;
}

.auth-card h2,
.result h2 {
  margin: 0 0 0.5rem;
  font-family: var(--font-display);
  font-size: 1.12rem;
}

.auth-card.error {
  border-color: #c43d1b;
  background: #fff5f1;
}

.auth-actions {
  display: flex;
  gap: 0.7rem;
  margin-top: 0.75rem;
}

.app-shell-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.05fr);
  gap: 1rem;
}

label {
  display: block;
  margin-bottom: 0.48rem;
  font-weight: 700;
  font-size: 0.94rem;
}

textarea,
select {
  width: 100%;
  border: 1px solid var(--field-border);
  border-radius: 8px;
  padding: 0.72rem;
  font: inherit;
  color: var(--ink);
  background: var(--field-bg);
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

textarea {
  min-height: 140px;
  resize: vertical;
}

select {
  margin-bottom: 0.35rem;
}

.mode-hint {
  margin: 0 0 1rem;
  color: var(--muted);
  font-size: 0.88rem;
}

button {
  appearance: none;
  border: none;
  border-radius: 8px;
  background: var(--button-bg);
  color: var(--button-ink);
  font: inherit;
  font-weight: 700;
  padding: 0.62rem 1rem;
  cursor: pointer;
  transition: transform 140ms ease, background-color 160ms ease, opacity 160ms ease;
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
  background: var(--button-bg-hover);
}

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

button:disabled {
  opacity: 0.62;
  cursor: wait;
  transform: none;
}

.header-logout {
  font-size: 0.8rem;
  padding: 0.4rem 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

textarea:focus,
select:focus,
button:focus {
  outline: none;
  border-color: var(--field-focus);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.result pre {
  margin: 0;
  border: 1px solid var(--surface-border);
  border-radius: 8px;
  padding: 0.9rem;
  min-height: 8rem;
  background: var(--field-bg);
  white-space: pre-wrap;
}

.feedback-panel {
  margin-top: 0.95rem;
  border: 1px solid var(--surface-border);
  border-radius: 10px;
  padding: 0.8rem;
  background: linear-gradient(145deg, #fbfdff, #f3f8ff);
}

.feedback-panel h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1rem;
}

.feedback-options {
  margin-top: 0.55rem;
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.feedback-chip {
  border: 1px solid #b7c9e2;
  border-radius: 999px;
  background: #eef4ff;
  color: var(--ink);
  padding: 0.36rem 0.82rem;
  font-size: 0.88rem;
  line-height: 1.2;
}

.feedback-chip:hover:not(:disabled) {
  background: #dce9ff;
}

.feedback-chip.is-active[data-feedback-rating='bad'] {
  background: var(--feedback-bad-bg);
  border-color: var(--feedback-bad-border);
  color: #9f3413;
}

.feedback-chip.is-active[data-feedback-rating='neutral'] {
  background: var(--feedback-neutral-bg);
  border-color: var(--feedback-neutral-border);
  color: #324b72;
}

.feedback-chip.is-active[data-feedback-rating='positive'] {
  background: var(--feedback-positive-bg);
  border-color: var(--feedback-positive-border);
  color: #1f6e42;
}

.feedback-form {
  margin-top: 0.75rem;
}

#feedbackText {
  min-height: 92px;
}

.feedback-actions {
  margin-top: 0.55rem;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex-wrap: wrap;
}

.feedback-status {
  min-height: 1.2em;
}

.status {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.status.error {
  color: #b0381a;
}

ul {
  margin: 0.55rem 0 0;
  padding-left: 1.2rem;
}

li {
  margin: 0.2rem 0;
}

@media (max-width: 980px) {
  .app-shell-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 680px) {
  .page-shell {
    padding: 0 0.75rem;
    margin-top: 0.75rem;
  }

  .hero {
    grid-template-columns: 1fr;
    gap: 0.6rem;
  }

  .top-design-header {
    padding: 0 0.55rem;
  }

  .brand-logo {
    height: 24px;
  }

  body.auth-view .page-shell {
    margin-top: 1.25rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    transition-duration: 1ms !important;
    scroll-behavior: auto !important;
  }
}
