:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --ink: #101828;
  --muted: #667085;
  --line: #d7dce3;
  --panel: #ffffff;
  --accent: #111827;
  --accent-2: #0f766e;
  --danger: #b42318;
  --warning: #b54708;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}

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

.app {
  width: min(100%, 720px);
  min-height: 100vh;
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 16px 28px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.top-actions {
  display: flex;
  gap: 8px;
}

.kicker {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1.1;
}

.icon-btn {
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  font-size: 22px;
}

.status-panel {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.status-panel div {
  display: grid;
  gap: 3px;
}

.status-panel span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.status-panel strong {
  font-size: 14px;
}

.secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--accent);
  font-size: 14px;
  font-weight: 800;
  text-decoration: none;
  white-space: nowrap;
}

.secondary.disabled {
  border-color: var(--line);
  color: var(--muted);
}

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

.inspiration-panel {
  display: grid;
  gap: 12px;
  margin-top: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

h2 {
  margin: 0;
  font-size: 20px;
  line-height: 1.2;
}

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

.settings-panel {
  display: grid;
  gap: 0;
  margin-bottom: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  overflow: hidden;
}

.section-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 48px;
  border: 0;
  background: transparent;
  padding: 0 14px;
  color: var(--ink);
  font-weight: 800;
}

.section-toggle strong {
  color: var(--muted);
  font-size: 13px;
}

.settings-body {
  display: grid;
  gap: 12px;
  padding: 0 14px 14px;
  border-top: 1px solid var(--line);
}

.divider {
  height: 1px;
  background: var(--line);
  margin: 4px 0;
}

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

.hidden {
  display: none;
}

textarea {
  width: 100%;
  min-height: 132px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  color: var(--ink);
  background: #fbfcfe;
  line-height: 1.5;
}

textarea:focus,
input:focus {
  outline: 2px solid rgba(15, 118, 110, 0.24);
  border-color: var(--accent-2);
}

.meta-row,
.tweet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
}

.field {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  color: var(--ink);
  font-weight: 800;
}

.check-row input {
  width: 20px;
  min-height: 20px;
  accent-color: var(--accent-2);
}

.tag-options {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
}

input {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: #fbfcfe;
  color: var(--ink);
}

select {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: #fbfcfe;
  color: var(--ink);
}

.primary {
  min-height: 48px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  font-weight: 800;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  margin: 16px 0 12px;
}

.tab {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.tab.active {
  border-color: var(--accent);
  background: var(--accent);
  color: white;
}

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

.tweet,
.empty,
.inspiration {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 14px;
}

.tweet p {
  margin: 12px 0;
  white-space: pre-wrap;
  line-height: 1.55;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 0 10px;
  background: #e7f6f3;
  color: #0f766e;
  font-size: 12px;
  font-weight: 800;
}

.published .pill {
  background: #eef4ff;
  color: #3538cd;
}

.failed .pill {
  background: #fef3f2;
  color: var(--danger);
}

.paused .pill {
  background: #fff7ed;
  color: var(--warning);
}

.error,
.remote {
  margin: 8px 0;
  padding: 10px;
  border-radius: 8px;
  background: #fef3f2;
  color: var(--danger);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.remote {
  background: #f2f4f7;
  color: var(--muted);
}

.source-link {
  display: inline-flex;
  margin-top: 8px;
  color: var(--accent-2);
  font-size: 13px;
  font-weight: 800;
}

.source-box,
.template-box {
  margin: 10px 0;
  padding: 10px;
  border-radius: 8px;
  background: #fbfcfe;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.55;
  white-space: pre-wrap;
}

.template-box {
  background: #f2f4f7;
  color: var(--muted);
}

.generated-input {
  min-height: 118px;
}

.inspiration-list {
  margin-top: 12px;
}

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

.tag-library {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
  padding: 10px;
}

.tag-library strong {
  display: block;
  margin-bottom: 4px;
}

.tag-library p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.tag-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(64px, 1fr));
  gap: 8px;
}

.tag-actions button {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
}

.tag-actions .danger {
  color: var(--danger);
}

.inspiration-actions {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

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

.actions button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
}

.actions .danger {
  color: var(--danger);
}

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

.toast {
  position: fixed;
  right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom));
  left: 16px;
  max-width: 420px;
  margin: 0 auto;
  padding: 12px 14px;
  border-radius: 8px;
  background: #111827;
  color: white;
  text-align: center;
  opacity: 0;
  transform: translateY(16px);
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

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

.login-panel {
  display: grid;
  width: min(100%, 420px);
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 18px;
}

@media (max-width: 420px) {
  .status-panel {
    grid-template-columns: 1fr 1fr;
  }

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

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

  .collector-grid,
  .inspiration-actions,
  .tag-library,
  .tag-actions {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 25px;
  }
}
