:root {
  color-scheme: light;
  --ink: #202124;
  --muted: #657078;
  --line: #d9e0e5;
  --panel: #ffffff;
  --surface: #f5f7f8;
  --accent: #e95420;
  --accent-dark: #b53d14;
  --blue: #255c99;
  --green: #24715a;
  --shadow: 0 16px 38px rgba(26, 31, 36, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--surface);
}

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

button {
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0.58rem 0.78rem;
  color: var(--ink);
  background: #fff;
  cursor: pointer;
}

button:hover {
  border-color: #aebac3;
}

button[type="submit"],
#searchButton,
#sendMessage,
#connectReddit {
  border-color: var(--accent);
  color: #fff;
  background: var(--accent);
}

button[type="submit"]:hover,
#searchButton:hover,
#sendMessage:hover,
#connectReddit:hover {
  background: var(--accent-dark);
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0.66rem 0.72rem;
  color: var(--ink);
  background: #fff;
}

textarea {
  resize: vertical;
}

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

.shell {
  width: min(1600px, 100%);
  margin: 0 auto;
  padding: 1.25rem;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.eyebrow {
  margin: 0 0 0.2rem;
  color: var(--accent-dark);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  max-width: 780px;
  margin-bottom: 0;
  font-size: clamp(1.65rem, 3vw, 3rem);
  line-height: 1.03;
}

h2 {
  margin-bottom: 0;
  font-size: 1rem;
}

.auth-panel {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-width: max-content;
}

.auth-panel span {
  color: var(--muted);
  font-size: 0.9rem;
}

.icon-button {
  width: 2.45rem;
  height: 2.45rem;
  padding: 0;
}

.workspace {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr) 340px;
  gap: 1rem;
  align-items: start;
}

.panel,
.search-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.panel {
  padding: 1rem;
}

.sidebar,
.composer {
  display: grid;
  gap: 1rem;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  margin-bottom: 0.85rem;
}

.panel-header span {
  color: var(--muted);
  font-size: 0.82rem;
  text-align: right;
}

.inline-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.5rem;
  margin-bottom: 0.85rem;
}

.check-list,
.template-list,
.account-list {
  display: grid;
  gap: 0.45rem;
}

.check-list {
  max-height: 340px;
  overflow-y: auto;
}

.check-row,
.template-row,
.account-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.5rem;
  align-items: center;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0.45rem 0.5rem;
  background: #fbfcfd;
}

.account-row {
  grid-template-columns: 1fr auto;
}

.account-row span {
  grid-column: 1 / 2;
  color: var(--muted);
  font-size: 0.78rem;
}

.account-row button {
  grid-row: 1 / span 2;
  grid-column: 2;
}

.account-row.is-empty {
  display: block;
  color: var(--muted);
}

.check-row input {
  width: auto;
}

.check-row span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.check-row button {
  width: 2rem;
  height: 2rem;
  padding: 0;
}

.template-row strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.template-actions {
  display: flex;
  gap: 0.3rem;
}

.btn-remove-template {
  width: 2rem;
  height: 2rem;
  padding: 0;
  color: var(--muted);
  font-size: 1.1rem;
  line-height: 1;
}

.btn-remove-template:hover {
  border-color: #e05252;
  color: #e05252;
  background: #fff5f5;
}

.search-card {
  display: grid;
  gap: 0.9rem;
  padding: 1rem;
}

.search-controls {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 0.75rem;
  align-items: end;
}

.results-header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin: 1rem 0;
}

.results-header p {
  margin-bottom: 0;
  color: var(--muted);
}

.results-header input {
  max-width: 280px;
}

.message-bar {
  margin-bottom: 1rem;
  border: 1px solid #f1c99d;
  border-radius: 7px;
  padding: 0.75rem;
  color: #704000;
  background: #fff8ef;
}

.field-note {
  margin: -0.45rem 0 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.35;
}

.oauth-preview {
  max-width: 100%;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0.75rem;
  color: #334049;
  background: #f7fafb;
  font-size: 0.78rem;
  white-space: pre-wrap;
  word-break: break-all;
}

.results {
  display: grid;
  gap: 0.8rem;
}

.result-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 1rem;
  background: #fff;
}

.result-card.is-selected {
  outline: 2px solid var(--blue);
}

.result-card.is-sent {
  opacity: 0.55;
}

.btn-sent {
  color: var(--muted);
  font-size: 0.85rem;
}

.btn-remove-post {
  margin-left: auto;
  color: var(--muted);
  font-size: 0.85rem;
}

.btn-remove-post:hover {
  border-color: #e05252;
  color: #e05252;
  background: #fff5f5;
}

.result-card.is-sent .btn-sent {
  border-color: var(--green);
  color: var(--green);
  background: #edf7f2;
}

.result-top {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.result-card h3 {
  margin: 0.35rem 0;
  font-size: 1.05rem;
}

.result-card p {
  margin-bottom: 0.8rem;
  color: #3f474e;
}

.result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.result-actions a {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0 0.75rem;
  color: var(--blue);
  text-decoration: none;
  background: #f9fbfc;
}

.composer-panel {
  position: sticky;
  top: 1rem;
  display: grid;
  gap: 0.9rem;
}

.settings {
  display: grid;
  gap: 0.9rem;
  width: min(540px, 90vw);
}

dialog {
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

dialog::backdrop {
  background: rgba(19, 24, 28, 0.35);
}

code {
  border-radius: 4px;
  padding: 0.1rem 0.25rem;
  background: #eef2f4;
}

@media (max-width: 1120px) {
  .workspace {
    grid-template-columns: 250px minmax(0, 1fr);
  }

  .composer {
    grid-column: 1 / -1;
  }

  .composer-panel {
    position: static;
  }
}

@media (max-width: 760px) {
  .shell {
    padding: 0.8rem;
  }

  .topbar,
  .results-header {
    align-items: stretch;
    flex-direction: column;
  }

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

  .results-header input {
    max-width: none;
  }
}
