:root {
  color-scheme: light;
  --bg: #f4f7f8;
  --surface: #ffffff;
  --surface-strong: #ffffff;
  --text: #1f2528;
  --muted: #647178;
  --line: #d5dde2;
  --accent: #176b63;
  --accent-dark: #0d4f49;
  --danger: #9e2f2f;
  --shadow: 0 16px 40px rgba(20, 35, 42, 0.08);
}

* {
  box-sizing: border-box;
}

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

button,
input,
textarea {
  font: inherit;
}

button {
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  min-height: 42px;
  padding: 0 16px;
}

button:hover {
  background: var(--accent-dark);
}

button.secondary {
  border: 1px solid var(--line);
  background: var(--surface-strong);
  color: var(--text);
}

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  max-width: 1180px;
  margin: 0 auto;
  padding: 32px 20px 18px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent-dark);
  font-size: 0.76rem;
  font-weight: 750;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(2rem, 5vw, 4.25rem);
  line-height: 0.95;
}

h2 {
  font-size: 1.15rem;
  line-height: 1.25;
}

.admin-button {
  min-height: 38px;
  border: 1px solid var(--line);
  background: var(--surface-strong);
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.admin-button:hover {
  border-color: var(--accent);
  background: var(--surface-strong);
  color: var(--accent-dark);
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 760px);
  justify-content: center;
  gap: 24px;
  max-width: 1180px;
  margin: 0 auto;
  padding: 18px 20px 48px;
}

body.admin-mode .layout {
  grid-template-columns: minmax(320px, 0.92fr) minmax(0, 1.35fr);
}

.composer,
.reader {
  min-width: 0;
}

.composer {
  position: sticky;
  top: 18px;
  align-self: start;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 18px;
}

form,
.settings {
  display: grid;
  gap: 14px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

label {
  display: grid;
  gap: 7px;
  min-width: 0;
}

label span {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 650;
}

input,
textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-strong);
  color: var(--text);
  outline: none;
  padding: 11px 12px;
}

textarea {
  min-height: 180px;
  resize: vertical;
  line-height: 1.65;
}

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

.form-actions,
.searchbar,
.post-header,
.post-actions,
.meta,
.tags {
  display: flex;
  align-items: center;
}

.form-actions {
  flex-wrap: wrap;
  gap: 10px;
}

#formStatus {
  color: var(--muted);
  font-size: 0.92rem;
}

.reader {
  display: grid;
  gap: 14px;
  width: 100%;
}

.searchbar {
  gap: 10px;
}

.searchbar label {
  flex: 1;
}

.stats {
  color: var(--muted);
  font-size: 0.9rem;
}

.post-list {
  display: grid;
  gap: 14px;
}

.post,
.empty {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  padding: 18px;
}

.post-header {
  justify-content: space-between;
  gap: 12px;
}

.paper-id {
  margin-bottom: 4px;
  color: var(--accent-dark);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-weight: 750;
}

.post-actions {
  flex-shrink: 0;
  gap: 8px;
}

button.small {
  min-height: 34px;
  padding: 0 10px;
  background: #e7f0ee;
  color: var(--accent-dark);
}

button.small:hover {
  background: #d3e6e3;
}

button.danger {
  background: #f4e3df;
  color: var(--danger);
}

button.danger:hover {
  background: #ecd0ca;
}

.meta {
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.87rem;
}

.meta span + span::before {
  content: "/";
  margin-right: 8px;
  color: #b2aa9e;
}

.insight {
  margin-top: 14px;
  white-space: pre-wrap;
  line-height: 1.75;
}

.tags {
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.tags button {
  min-height: 30px;
  border: 1px solid #cfe0dd;
  background: #f2f8f7;
  color: var(--accent-dark);
  padding: 0 9px;
  font-size: 0.85rem;
}

.paper-link {
  display: inline-flex;
  margin-top: 14px;
  color: var(--accent-dark);
  font-weight: 700;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

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

dialog {
  width: min(420px, calc(100vw - 32px));
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}

dialog::backdrop {
  background: rgba(19, 29, 33, 0.35);
}

.settings h2 {
  font-size: 1.25rem;
}

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

  .composer {
    position: static;
  }
}

@media (max-width: 560px) {
  .topbar {
    padding-top: 22px;
  }

  .layout {
    padding-inline: 14px;
  }

  .form-grid,
  .searchbar {
    grid-template-columns: 1fr;
  }

  .form-grid {
    display: grid;
  }

  .searchbar {
    display: grid;
  }

  .post-header {
    align-items: flex-start;
    flex-direction: column;
  }
}
