:root {
  color-scheme: light;
  --bg: #f5f7f8;
  --surface: #ffffff;
  --surface-2: #edf2f4;
  --text: #172026;
  --muted: #66737c;
  --line: #dbe3e7;
  --accent: #116a71;
  --accent-strong: #0b5359;
  --danger: #ad2f34;
  --warning: #9a6500;
  --ok: #176b3a;
  --shadow: 0 18px 40px rgba(23, 32, 38, 0.09);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  min-height: 100vh;
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 22px clamp(18px, 4vw, 52px);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.86);
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(16px);
}

.app-header h1,
.section-head h2,
.modal h3 {
  margin: 0;
  letter-spacing: 0;
}

.app-header h1 {
  font-size: clamp(24px, 4vw, 38px);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.top-actions,
.modal-actions,
.admin-filter {
  display: flex;
  align-items: center;
  gap: 10px;
}

.google-auth {
  min-height: 40px;
}

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 34px auto 80px;
}

.screen {
  display: none;
}

.screen.active {
  display: block;
}

.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 24px;
}

.section-head p {
  max-width: 690px;
  margin: 8px 0 0;
  color: var(--muted);
}

.section-head.split {
  align-items: center;
}

.inline-form {
  display: flex;
  gap: 8px;
  min-width: min(420px, 100%);
}

.admin-tag-form {
  margin: -8px 0 20px;
  max-width: 560px;
}

.admin-tag-form button {
  min-width: 96px;
}

.login-panel,
.setup-panel {
  display: grid;
  gap: 16px;
  width: min(460px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 18px;
  box-shadow: 0 8px 20px rgba(23, 32, 38, 0.05);
}

.setup-shell {
  display: grid;
  min-height: 80vh;
  place-items: center;
}

.setup-panel h1 {
  margin: 0;
  letter-spacing: 0;
}

.notice {
  margin: 0;
  border-radius: 8px;
  padding: 10px 12px;
  font-weight: 750;
}

.notice.ok {
  background: #e5f5eb;
  color: var(--ok);
}

.notice.error {
  background: #fae9ea;
  color: var(--danger);
}

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

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

input:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(17, 106, 113, 0.12);
}

.primary-button,
.text-button,
.inline-form button,
.filter-button {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0 14px;
  font-weight: 750;
  white-space: nowrap;
}

.primary-button,
.inline-form button {
  background: var(--accent);
  color: #fff;
}

.primary-button:hover,
.inline-form button:hover {
  background: var(--accent-strong);
}

.text-button,
.filter-button {
  background: #fff;
  border-color: var(--line);
  color: var(--text);
}

.filter-button.active {
  border-color: var(--accent);
  background: #e7f3f2;
  color: var(--accent-strong);
}

.icon-button {
  display: inline-grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font-size: 20px;
  font-weight: 800;
}

.link-button {
  margin: 0 0 10px;
  border: 0;
  background: transparent;
  color: var(--accent);
  padding: 0;
  font-weight: 800;
}

.tag-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 12px;
}

.tag-card {
  min-height: 112px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 16px;
  text-align: left;
  box-shadow: 0 8px 20px rgba(23, 32, 38, 0.05);
  transition: transform 0.16s ease, border-color 0.16s ease;
}

.tag-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.tag-name {
  display: block;
  font-size: 17px;
  font-weight: 850;
  line-height: 1.3;
}

.tag-count {
  display: block;
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
}

.sentence-list,
.admin-list {
  display: grid;
  gap: 12px;
}

.sentence-card,
.admin-card,
.empty-state {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 16px;
  box-shadow: 0 8px 20px rgba(23, 32, 38, 0.05);
}

.sentence-card p,
.admin-card p {
  margin: 0;
  line-height: 1.6;
}

.qa-card {
  padding: 0;
}

.question-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: 100%;
  min-height: 68px;
  border: 0;
  background: #fff;
  color: var(--text);
  padding: 16px;
  text-align: left;
  font-weight: 850;
  line-height: 1.35;
}

.question-toggle:hover {
  background: #f8fbfb;
}

.toggle-mark {
  display: inline-grid;
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--accent);
  font-size: 18px;
}

.answer-panel {
  border-top: 1px solid var(--line);
  padding: 16px;
  background: #fbfcfc;
}

.admin-question {
  margin: 0 0 8px;
  font-size: 16px;
  line-height: 1.35;
  letter-spacing: 0;
}

.user-vote-meta {
  color: var(--muted);
  font-size: 14px;
}

.source-link {
  display: inline-block;
  color: var(--accent);
  font-weight: 750;
  overflow-wrap: anywhere;
}

.answer-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 12px;
}

.reaction-wrap {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.reaction-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 0 10px;
  font-weight: 800;
}

.reaction-button.active {
  border-color: var(--accent);
  background: #e7f3f2;
  color: var(--accent-strong);
}

.google-user-button {
  min-height: 40px;
  max-width: 210px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 0 12px;
  font-weight: 750;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 50;
  max-width: min(420px, calc(100% - 36px));
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--text);
  color: #fff;
  padding: 12px 14px;
  box-shadow: var(--shadow);
  font-weight: 750;
}

.share-wrap {
  position: relative;
}

.share-button,
.share-menu button,
.share-menu a {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 0 11px;
  font-weight: 750;
  text-decoration: none;
}

.share-button {
  color: var(--accent);
}

.share-menu {
  position: static;
  display: grid;
  min-width: 160px;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 8px;
  margin-top: 8px;
  box-shadow: var(--shadow);
}

.share-menu[hidden] {
  display: none;
}

.share-menu a,
.share-menu button {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  width: 100%;
}

.status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 850;
}

.badge.pending {
  background: #fff4d8;
  color: var(--warning);
}

.badge.approved {
  background: #e5f5eb;
  color: var(--ok);
}

.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.small-button {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 0 11px;
  font-weight: 750;
}

.small-button.approve {
  border-color: rgba(23, 107, 58, 0.28);
  color: var(--ok);
}

.small-button.delete {
  border-color: rgba(173, 47, 52, 0.3);
  color: var(--danger);
}

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

.modal {
  width: min(640px, calc(100% - 24px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  box-shadow: var(--shadow);
}

.modal::backdrop {
  background: rgba(23, 32, 38, 0.42);
}

.modal-panel {
  display: grid;
  gap: 16px;
  padding: 20px;
}

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

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.form-note {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

@media (max-width: 760px) {
  .app-header,
  .section-head,
  .section-head.split {
    align-items: stretch;
    flex-direction: column;
  }

  .top-actions,
  .inline-form,
  .admin-filter {
    width: 100%;
  }

  .inline-form {
    flex-direction: column;
  }

  .top-actions button,
  .admin-filter button,
  .primary-button {
    flex: 1;
  }

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