@import url("https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,600;9..144,700&family=Space+Grotesk:wght@400;500;600;700&display=swap");

:root {
  --bg: #f7f0e8;
  --bg-accent: #e3f1f0;
  --ink: #1c1b1a;
  --muted: #5a5753;
  --surface: #ffffff;
  --surface-2: #fff7ee;
  --brand: #0f6f6a;
  --brand-2: #e9843a;
  --border: #e4d9cf;
  --shadow: 0 18px 45px rgba(30, 35, 36, 0.12);
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: "Space Grotesk", "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--bg);
  min-height: 100vh;
  line-height: 1.5;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background: transparent;
  pointer-events: none;
  z-index: -1;
}

.page {
  max-width: 1100px;
  margin: 0 auto;
  padding: 48px 24px 64px;
  display: flex;
  flex-direction: column;
  gap: 32px;
}

/* ── Hero ─────────────────────────────────── */

.status-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
}

.meta {
  background: rgba(28, 27, 26, 0.06);
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 14px;
}

.meta::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #3bb078;
  margin-right: 8px;
  vertical-align: middle;
}

/* ── Panel ─────────────────────────────────── */

.panel {
  background: var(--surface);
  border-radius: 24px;
  padding: 32px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

/* ── Search Form ──────────────────────────── */

.search {
  display: grid;
  grid-template-columns: 1fr 180px 220px 140px;
  gap: 16px;
  align-items: end;
}

.search__field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.search__field label {
  font-size: 14px;
  color: var(--muted);
}

.search__input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.search__icon {
  position: absolute;
  left: 14px;
  color: var(--muted);
  pointer-events: none;
}

.search__input-wrapper input {
  width: 100%;
  border-radius: 14px;
  border: 1px solid var(--border);
  padding: 14px 80px 14px 40px;
  font-size: 16px;
  font-family: inherit;
  background: var(--surface-2);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.search__input-wrapper input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(15, 111, 106, 0.15);
}

.search__kbd {
  position: absolute;
  right: 12px;
  background: rgba(28, 27, 26, 0.06);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2px 8px;
  font-size: 11px;
  font-family: inherit;
  color: var(--muted);
  pointer-events: none;
}

.search select {
  border-radius: 14px;
  border: 1px solid var(--border);
  padding: 14px 16px;
  font-size: 16px;
  font-family: inherit;
  background: var(--surface-2);
}

.search__field--mode {
  min-width: 0;
}

.search__mode-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 13px 14px;
  background: var(--surface-2);
  color: var(--ink);
  font-size: 14px;
  cursor: pointer;
  user-select: none;
}

.search__mode-toggle input {
  accent-color: var(--brand);
}

.search__button {
  position: relative;
  border: none;
  border-radius: 14px;
  padding: 14px 16px;
  font-size: 16px;
  font-weight: 600;
  background: var(--brand);
  color: white;
  cursor: pointer;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.search__button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.search__button:not(:disabled):hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 25px rgba(15, 111, 106, 0.24);
}

.search__button:not(:disabled):active {
  transform: scale(0.97);
}

/* ── Spinner ──────────────────────────────── */

.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

/* ── Chips ─────────────────────────────────── */

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 20px 0 10px;
}

.hint {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 16px;
}

.history {
  margin: 8px 0 16px;
}

.history__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.history__header h3 {
  font-size: 14px;
  color: var(--muted);
  font-weight: 600;
}

.history__list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.history__clear {
  border: 1px solid rgba(28, 27, 26, 0.2);
  background: transparent;
  color: var(--muted);
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}

.history__clear:hover {
  background: rgba(28, 27, 26, 0.06);
  color: var(--ink);
}

.chip {
  border: 1px solid rgba(15, 111, 106, 0.2);
  background: #f0fbfa;
  color: var(--brand);
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s ease, background 0.2s ease;
}

.chip:hover {
  background: #e3f7f4;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(15, 111, 106, 0.15);
}

.chip--history {
  border-color: rgba(233, 132, 58, 0.25);
  background: #fff7ee;
  color: #7f481f;
}

.chip--history:hover {
  background: #ffe9d6;
  box-shadow: 0 4px 12px rgba(233, 132, 58, 0.2);
}

/* ── Alert ─────────────────────────────────── */

.alert {
  background: rgba(233, 132, 58, 0.12);
  border: 1px solid rgba(233, 132, 58, 0.3);
  color: #9a4d16;
  padding: 12px 16px;
  border-radius: 12px;
  margin-bottom: 12px;
}

/* ── Results ──────────────────────────────── */

.results {
  margin-top: 18px;
}

.results__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
  gap: 12px;
  color: var(--muted);
}

.results__header h2 {
  font-family: "Fraunces", "Times New Roman", serif;
  font-size: 22px;
  color: var(--ink);
}

.results__empty {
  padding: 40px 20px;
  border: 1px dashed var(--border);
  border-radius: 16px;
  color: var(--muted);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.empty-icon {
  opacity: 0.4;
}

.results__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 18px;
}

.results__grid--search {
  grid-template-columns: 1fr;
}

.results__pagination {
  margin-top: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.pagination__button {
  border: 1px solid rgba(15, 111, 106, 0.2);
  background: #f0fbfa;
  color: var(--brand);
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 15px;
  flex-shrink: 0;
  cursor: pointer;
  font-family: inherit;
  font-weight: 600;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s ease, background 0.2s ease;
}

.pagination__button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.pagination__button:not(:disabled):hover {
  background: #e3f7f4;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(15, 111, 106, 0.15);
}

.pagination__meta {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

/* ── Fade-in Animation ────────────────────── */

.fade-in {
  animation: fadeInUp 0.4s ease both;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ── Cards ─────────────────────────────────── */

.card {
  border-radius: 18px;
  padding: 18px;
  background: #ffffff;
  border: 1px solid rgba(15, 111, 106, 0.12);
  box-shadow: 0 8px 20px rgba(30, 35, 36, 0.08);
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s ease;
}

.card:hover {
  transform: translateY(-3px);
  box-shadow: 0 16px 40px rgba(30, 35, 36, 0.14);
}

.card__header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.card__header h3 {
  font-size: 16px;
}

.card__path {
  font-size: 12px;
  color: var(--muted);
}

.card__link {
  font-size: 12px;
  text-decoration: none;
  color: var(--brand);
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 999px;
  border: 1px solid rgba(15, 111, 106, 0.2);
  white-space: nowrap;
  transition: background 0.2s ease, color 0.2s ease;
}

.card__link:hover {
  background: var(--brand);
  color: white;
}

.card__snippet {
  font-size: 14px;
  color: #2b2a29;
}

.card__snippet--empty {
  color: var(--muted);
}

.card__snippet mark {
  background: rgba(233, 132, 58, 0.25);
  color: #5a2b0c;
  padding: 0 4px;
  border-radius: 6px;
}

.card__summary-preview {
  border-top: 1px dashed rgba(15, 111, 106, 0.2);
  padding-top: 10px;
  color: var(--muted);
  font-size: 13px;
}

.card__summary-markdown {
  margin-top: 6px;
  line-height: 1.55;
}

.card__summary-markdown p {
  margin: 0 0 6px;
}

.card__summary-markdown p:last-child {
  margin-bottom: 0;
}

.card__summary-markdown strong {
  color: var(--ink);
  font-weight: 700;
}

.card__summary-markdown ul,
.card__summary-markdown ol {
  margin: 0 0 6px;
  padding-left: 18px;
}

.card__summary-markdown h1,
.card__summary-markdown h2,
.card__summary-markdown h3,
.card__summary-markdown h4 {
  font-size: inherit;
  font-weight: 700;
  margin: 0 0 4px;
}

.card__summary-toggle {
  border: 1px solid rgba(15, 111, 106, 0.2);
  background: #f0fbfa;
  color: var(--brand);
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  margin-top: 8px;
  transition: background 0.2s ease;
}

.card__summary-toggle:hover {
  background: #e3f7f4;
}

/* ── Skeleton Loading ─────────────────────── */

.skeleton-card {
  pointer-events: none;
}

.skeleton-line {
  height: 14px;
  border-radius: 8px;
  background: linear-gradient(90deg, #e8e3dc 25%, #f5f0e8 50%, #e8e3dc 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s ease infinite;
}

.skeleton-line--title {
  width: 60%;
  height: 18px;
}

.skeleton-line--short {
  width: 40%;
}

.skeleton-line--medium {
  width: 75%;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── Footer ───────────────────────────────── */

.footer {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  padding-top: 10px;
}

/* ── Responsive ───────────────────────────── */

@media (max-width: 820px) {
  .page {
    padding: 16px 6px 32px;
    gap: 16px;
  }

  .panel {
    padding: 16px 10px;
    border-radius: 18px;
  }

  .search {
    grid-template-columns: 1fr;
  }

  .search__button,
  .search__field--small,
  .chips,
  .hint,
  .results__header,
  .results__empty,
  .footer {
    display: none;
  }

  .search__kbd {
    display: none;
  }

  .search__input-wrapper input {
    padding-right: 8px;
  }

  .results__header {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }

  .results__header h2 {
    font-size: 20px;
  }

  .results__header span {
    font-size: 13px;
  }

  .card {
    padding: 14px 12px;
  }

  .history {
    margin-top: 12px;
  }

  .history__header h3 {
    font-size: 13px;
  }

  .history__clear {
    padding: 5px 9px;
    font-size: 11px;
  }

  .card__header {
    align-items: center;
  }

  .card__snippet {
    font-size: 13px;
  }

  .card__summary-markdown {
    font-size: 13px;
  }

  .results__grid {
    grid-template-columns: 1fr;
  }
}

/* ── Saved Decisions ─────────────────────── */

.saved {
  margin: 8px 0 16px;
  padding: 14px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.55);
}

.saved__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.saved__header h3 {
  font-size: 14px;
  color: var(--muted);
  font-weight: 600;
}

.saved__clear {
  border: 1px solid rgba(28, 27, 26, 0.2);
  background: transparent;
  color: var(--muted);
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}

.saved__clear:hover {
  background: rgba(28, 27, 26, 0.06);
  color: var(--ink);
}

.saved__empty {
  color: var(--muted);
  font-size: 13px;
}

.saved__list {
  display: grid;
  gap: 10px;
}

.saved__item {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
  border: 1px solid rgba(15, 111, 106, 0.16);
  border-radius: 12px;
  padding: 10px 12px;
  background: #fffdf9;
}

.saved__meta h4 {
  font-size: 14px;
  margin-bottom: 4px;
}

.saved__meta p {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.saved__actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.saved__remove {
  border: 1px solid rgba(28, 27, 26, 0.2);
  background: transparent;
  color: var(--muted);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}

.saved__remove:hover {
  background: rgba(28, 27, 26, 0.06);
  color: var(--ink);
}

/* ── Card Bookmark Actions ───────────────── */

.card__actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.card__bookmark {
  border: 1px solid rgba(233, 132, 58, 0.35);
  background: #fff7ee;
  color: #7f481f;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.card__bookmark:hover {
  background: #ffe9d6;
}

.card__bookmark--saved {
  background: #f8ede2;
  border-color: rgba(127, 72, 31, 0.35);
  color: #6c3c1a;
}

@media (max-width: 820px) {
  .saved {
    margin-top: 12px;
    padding: 12px 10px;
  }

  .saved__header h3 {
    font-size: 13px;
  }

  .saved__clear {
    padding: 5px 9px;
    font-size: 11px;
  }

  .saved__item {
    flex-direction: column;
    gap: 10px;
  }

  .saved__actions {
    width: 100%;
    justify-content: flex-start;
  }
}
