:root {
  --bg: #f5f7fa;
  --panel: #ffffff;
  --line: #d8dee8;
  --text: #17202c;
  --muted: #697386;
  --accent: #0f766e;
  --accent-2: #2563eb;
  --danger: #b91c1c;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Inter, "Segoe UI", system-ui, sans-serif;
  color: var(--text);
  background: var(--bg);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  border-radius: 6px;
  padding: 0.55rem 0.75rem;
  cursor: pointer;
}

button:hover {
  border-color: var(--accent);
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.55rem 0.65rem;
  background: #fff;
  color: var(--text);
}

textarea {
  resize: vertical;
  line-height: 1.45;
}

label {
  display: grid;
  gap: 0.35rem;
  font-size: 0.82rem;
  color: var(--muted);
}

.is-hidden {
  display: none !important;
}

.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem;
}

.login__box {
  width: min(360px, 100%);
  display: grid;
  gap: 0.85rem;
  padding: 1.3rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.login__box h1 {
  margin: 0 0 0.3rem;
  font-size: 1.4rem;
}

.error {
  min-height: 1.2rem;
  color: var(--danger);
  margin: 0;
}

.workspace {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px minmax(360px, 0.9fr) minmax(520px, 1.4fr);
  grid-template-rows: 56px 1fr;
}

.topbar {
  grid-column: 1 / 4;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0 1rem;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.topbar span {
  margin-left: 0.8rem;
  color: var(--muted);
  font-size: 0.86rem;
}

.searchbar {
  display: grid;
  grid-template-columns: minmax(360px, 42vw) auto auto;
  gap: 0.5rem;
}

.sidebar,
.results,
.editor {
  min-height: 0;
  overflow: auto;
  padding: 1rem;
}

.sidebar {
  background: #eef2f7;
  border-right: 1px solid var(--line);
  display: grid;
  align-content: start;
  gap: 0.75rem;
}

.sidebar h2,
.sources-panel h2,
.preview h2 {
  margin: 0.7rem 0 0.2rem;
  font-size: 0.82rem;
  text-transform: uppercase;
  color: var(--muted);
  letter-spacing: 0.04em;
}

#sections {
  display: grid;
  gap: 0.25rem;
}

.section-btn {
  text-align: left;
  background: transparent;
}

.section-btn.is-active {
  background: #dbeafe;
  border-color: #93c5fd;
}

.results {
  border-right: 1px solid var(--line);
}

.results__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.7rem;
}

.list {
  display: grid;
  gap: 0.55rem;
}

.item-row {
  display: grid;
  gap: 0.4rem;
  text-align: left;
  padding: 0.75rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.item-row.is-active {
  border-color: var(--accent-2);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.12);
}

.item-row strong {
  font-size: 0.96rem;
}

.item-row span,
.item-row small {
  color: var(--muted);
}

.empty-state {
  display: grid;
  gap: 0.35rem;
  padding: 1rem;
  background: var(--panel);
  border: 1px dashed var(--line);
  border-radius: 8px;
}

.empty-state span {
  color: var(--muted);
  line-height: 1.4;
}

.editor {
  background: var(--panel);
}

.empty {
  color: var(--muted);
  padding: 2rem 0;
}

.item-form {
  display: grid;
  gap: 0.8rem;
}

.editor__head {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.8rem;
  align-items: start;
}

.editor__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  justify-content: flex-end;
}

.title-input {
  font-size: 1.15rem;
  font-weight: 700;
}

.grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.65rem;
}

.grid--hotel {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.score-filter {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.preview,
.sources-panel {
  border-top: 1px solid var(--line);
  padding-top: 0.6rem;
}

pre {
  margin: 0;
  white-space: pre-wrap;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.82rem;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.75rem;
}

.source-card,
.version-card {
  display: grid;
  gap: 0.3rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.65rem;
  margin-bottom: 0.5rem;
  background: #fbfdff;
}

.source-card small,
.version-card small {
  color: var(--muted);
}

@media (max-width: 1100px) {
  .workspace {
    grid-template-columns: 240px 1fr;
    grid-template-rows: 56px 46vh 1fr;
  }

  .topbar {
    grid-column: 1 / 3;
  }

  .editor {
    grid-column: 1 / 3;
  }
}

@media (max-width: 760px) {
  .workspace {
    display: block;
  }

  .topbar,
  .searchbar,
  .editor__head,
  .grid,
  .grid--hotel {
    display: grid;
    grid-template-columns: 1fr;
  }
}
