:root {
  color-scheme: light;
  --bg: #f5f6f4;
  --panel: #ffffff;
  --ink: #20241f;
  --muted: #6e766b;
  --line: #d9ded5;
  --accent: #286b57;
  --accent-ink: #ffffff;
  --warn: #a33b27;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
  border-radius: 6px;
  padding: 9px 13px;
  cursor: pointer;
}

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

.hidden {
  display: none !important;
}

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

.login-panel {
  width: min(390px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 28px;
}

.login-panel h1 {
  margin: 0 0 22px;
  font-size: 28px;
}

label {
  display: grid;
  gap: 8px;
  margin: 14px 0;
  color: var(--muted);
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 11px 12px;
  outline: none;
}

input:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(40, 107, 87, 0.14);
}

.error {
  color: var(--warn);
  min-height: 22px;
}

.app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
}

.sidebar {
  border-right: 1px solid var(--line);
  background: #eef1ec;
  padding: 16px;
  overflow: auto;
  max-height: 100vh;
}

.brand,
.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: space-between;
}

.brand strong {
  font-size: 20px;
}

.brand button {
  padding: 7px 10px;
  background: transparent;
  color: var(--accent);
}

.search {
  margin: 16px 0 12px;
}

.brain-panel {
  background: #ffffff;
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 12px;
}

.brain-panel strong {
  display: block;
  margin-bottom: 7px;
  font-size: 14px;
}

.brain-panel pre {
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0 0 10px;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.45;
  font-family: inherit;
}

.brain-block {
  margin-top: 8px;
}

.brain-block b {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 4px;
}

.brain-block ul {
  margin: 0;
  padding-left: 17px;
}

.brain-block li {
  font-size: 12px;
  line-height: 1.45;
  margin: 4px 0;
}

.brain-block span {
  color: var(--muted);
}

.facets {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 14px;
}

.chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  padding: 5px 9px;
  font-size: 13px;
  cursor: pointer;
}

.entry-list {
  display: grid;
  gap: 8px;
}

.entry-card {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 8px;
  padding: 12px;
  cursor: pointer;
}

.entry-card.active {
  border-color: var(--accent);
  box-shadow: inset 3px 0 0 var(--accent);
}

.entry-card h3 {
  margin: 0 0 6px;
  font-size: 15px;
  line-height: 1.35;
}

.entry-card p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 9px;
}

.meta span {
  font-size: 12px;
  color: var(--muted);
  background: #f2f4f0;
  border-radius: 999px;
  padding: 3px 7px;
}

.workspace {
  display: grid;
  grid-template-rows: auto auto minmax(360px, 1fr) auto;
  gap: 12px;
  padding: 18px;
  min-width: 0;
}

.toolbar {
  justify-content: flex-start;
}

#status {
  color: var(--muted);
}

.title-input {
  font-size: 22px;
  font-weight: 650;
}

textarea {
  resize: none;
  min-height: 420px;
  line-height: 1.6;
}

.analysis {
  display: grid;
  gap: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.analysis-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.field {
  min-width: 0;
}

.field strong {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 5px;
}

.field div {
  word-break: break-word;
}

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

  .sidebar {
    max-height: 45vh;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

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