:root {
  --bg: #f3f7f6;
  --surface: #ffffff;
  --surface-2: #e9f8f2;
  --ink: #10202a;
  --muted: #64757c;
  --line: #d5e4e0;
  --blue: #0f766e;
  --blue-dark: #0b5d56;
  --purple: #145374;
  --green: #19a974;
  --danger: #dc2626;
  --navy: #102a43;
  --shadow: 0 18px 42px rgba(15, 42, 55, 0.12);
  --soft-shadow: 0 10px 24px rgba(15, 42, 55, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  background:
    linear-gradient(180deg, #eaf7f2 0, var(--bg) 18rem),
    var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
}

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

button,
input,
select,
textarea {
  -webkit-tap-highlight-color: transparent;
}

button {
  cursor: pointer;
}

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

.is-hidden,
.view {
  display: none;
}

.auth-screen.is-hidden,
.app-shell.is-hidden {
  display: none;
}

.view.is-active {
  display: block;
  min-width: 0;
}

.auth-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1rem;
  background:
    linear-gradient(135deg, rgba(25, 169, 116, 0.18), rgba(16, 42, 67, 0.08)),
    var(--bg);
}

.auth-wrap {
  width: min(100%, 980px);
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  gap: 1rem;
  align-items: stretch;
}

.auth-intro,
.auth-card,
.hero-panel,
.response-card,
.admin-form,
.admin-row,
.variables-grid,
.empty-state {
  border: 1px solid rgba(219, 228, 240, 0.9);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}

.auth-intro {
  padding: clamp(1.2rem, 4vw, 2rem);
  display: flex;
  flex-direction: column;
  justify-content: center;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.98), rgba(233, 248, 242, 0.96));
}

.brand-badge {
  width: 2.9rem;
  height: 2.9rem;
  display: inline-grid;
  place-items: center;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--green), var(--navy));
  color: #fff;
  font-weight: 950;
  box-shadow: 0 10px 22px rgba(37, 99, 235, 0.25);
}

.auth-intro h2 {
  max-width: 13ch;
  margin: 0 0 0.75rem;
  font-size: clamp(2rem, 6vw, 3.5rem);
  line-height: 0.96;
}

.benefit-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
  margin-top: 1rem;
}

.benefit-grid span {
  min-height: 2.4rem;
  display: inline-flex;
  align-items: center;
  border: 1px solid rgba(15, 118, 110, 0.16);
  border-radius: 8px;
  padding: 0.45rem 0.65rem;
  background: #fff;
  color: var(--navy);
  font-size: 0.82rem;
  font-weight: 900;
}

.version-chip {
  width: max-content;
  margin-top: 1rem;
  display: inline-flex;
  align-items: center;
  min-height: 1.8rem;
  border-radius: 999px;
  padding: 0.25rem 0.62rem;
  background: #e9f0ff;
  color: var(--blue);
  font-size: 0.78rem;
  font-weight: 950;
}

.eyebrow {
  margin: 1rem 0 0.3rem;
  color: var(--blue);
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.auth-intro h1,
.topbar h1 {
  margin-bottom: 0.45rem;
  font-size: clamp(2rem, 7vw, 4rem);
  line-height: 0.98;
}

.auth-intro p,
.hero-panel p,
.section-title p,
.user-greeting,
.form-note {
  color: var(--muted);
  line-height: 1.55;
}

.auth-card {
  padding: 1rem;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.45rem;
  margin-bottom: 1rem;
  padding: 0.35rem;
  border-radius: 8px;
  background: #e9f8f2;
}

.auth-tabs button,
.side-nav button,
.bottom-nav button,
.category-strip button {
  min-height: 2.6rem;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-weight: 850;
}

.auth-tabs button.is-active,
.side-nav button.is-active,
.bottom-nav button.is-active,
.category-strip button.is-active {
  background: var(--surface);
  color: var(--blue);
  box-shadow: var(--soft-shadow);
}

form label,
.search-box,
.select-box {
  display: grid;
  gap: 0.4rem;
  color: var(--ink);
  font-size: 0.82rem;
  font-weight: 900;
}

input,
select,
textarea {
  width: 100%;
  min-height: 3rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.78rem 0.85rem;
  background: #fff;
  color: var(--ink);
  outline: 0;
}

textarea {
  min-height: 8.5rem;
  resize: vertical;
  line-height: 1.45;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(37, 99, 235, 0.65);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}

.auth-card form,
.variables-grid,
.admin-form {
  display: grid;
  gap: 0.85rem;
}

.primary-btn,
.secondary-btn,
.ghost-btn,
.copy-btn,
.tone-chip,
.favorite-btn,
.small-btn {
  min-height: 2.75rem;
  border-radius: 8px;
  border: 0;
  padding: 0.7rem 0.95rem;
  font-weight: 900;
}

.primary-btn,
.copy-btn {
  background: linear-gradient(135deg, var(--green), var(--blue));
  color: #fff;
}

.primary-btn:hover,
.copy-btn:hover {
  background: var(--blue-dark);
}

.secondary-btn {
  background: #e9f8f2;
  color: var(--blue);
}

.ghost-btn,
.small-btn {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}

.app-shell {
  min-height: 100vh;
  min-width: 0;
  display: grid;
  grid-template-columns: 17rem 1fr;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 1rem;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(18px);
}

.brand-line {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.brand-line strong,
.brand-line small {
  display: block;
}

.brand-line small {
  margin-top: 0.1rem;
  color: var(--muted);
  font-weight: 750;
}

.side-nav {
  display: grid;
  gap: 0.45rem;
}

.side-nav button {
  text-align: left;
  padding: 0 0.8rem;
  min-height: 3rem;
}

.logout-btn {
  width: calc(100% - 2rem);
  position: absolute;
  left: 1rem;
  bottom: 1rem;
}

.main-area {
  width: 100%;
  max-width: 1180px;
  min-width: 0;
  margin: 0 auto;
  padding: 1rem 1rem 6.5rem;
}

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

.topbar .eyebrow {
  margin-top: 0;
}

.hero-panel {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 1rem;
  align-items: stretch;
  margin-bottom: 1rem;
  padding: 1.1rem;
  overflow: hidden;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.98), rgba(233, 248, 242, 0.96));
}

.hero-panel h2 {
  max-width: 17ch;
  margin: 0.6rem 0 0.55rem;
  font-size: clamp(2rem, 6vw, 3.6rem);
  line-height: 0.98;
}

.hero-summary {
  margin: 0.75rem 0 0;
  color: var(--navy);
  font-weight: 950;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 2rem;
  border-radius: 999px;
  padding: 0.35rem 0.7rem;
  background: #dcfce7;
  color: var(--green);
  font-size: 0.78rem;
  font-weight: 950;
}

.hero-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(6.1rem, 1fr));
  gap: 0.65rem;
}

.hero-metrics article {
  min-height: 6.2rem;
  border-radius: 8px;
  padding: 0.8rem;
  background: linear-gradient(135deg, #102a43, #0f766e);
  color: #fff;
}

.hero-metrics strong {
  display: block;
  font-size: 2rem;
  line-height: 1;
}

.hero-metrics span {
  color: rgba(255, 255, 255, 0.72);
  font-weight: 800;
}

.utility-bar {
  display: grid;
  grid-template-columns: 1fr auto 13rem;
  gap: 0.75rem;
  align-items: end;
  margin-bottom: 1rem;
  border: 1px solid rgba(15, 118, 110, 0.12);
  border-radius: 8px;
  padding: 0.8rem;
  background: rgba(255, 255, 255, 0.84);
  box-shadow: var(--soft-shadow);
}

.search-box input {
  min-height: 3.35rem;
  border-color: rgba(15, 118, 110, 0.28);
  font-size: 1rem;
}

.quick-search {
  display: flex;
  gap: 0.45rem;
  margin: -0.35rem 0 1rem;
  overflow-x: auto;
  padding-bottom: 0.15rem;
}

.quick-search button {
  flex: 0 0 auto;
  min-height: 2.35rem;
  border: 1px solid rgba(15, 118, 110, 0.18);
  border-radius: 999px;
  padding: 0.4rem 0.75rem;
  background: #fff;
  color: var(--blue);
  font-size: 0.82rem;
  font-weight: 900;
}

.clear-search-btn {
  white-space: nowrap;
}

.category-strip {
  display: flex;
  gap: 0.5rem;
  max-width: calc(100% + 2rem);
  margin: 0 -1rem 1rem;
  padding: 0 1rem 0.2rem;
  overflow-x: auto;
}

.category-strip button {
  flex: 0 0 auto;
  min-width: max-content;
  padding: 0 0.8rem;
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: 0 6px 14px rgba(15, 42, 55, 0.04);
}

.response-list,
.admin-list {
  display: grid;
  gap: 0.8rem;
}

.response-card {
  padding: 1rem;
  min-width: 0;
  overflow: hidden;
  border-color: rgba(15, 118, 110, 0.12);
}

.response-head {
  display: flex;
  justify-content: space-between;
  gap: 0.8rem;
  margin-bottom: 0.75rem;
  min-width: 0;
}

.response-head > div {
  min-width: 0;
}

.response-head h3 {
  margin-bottom: 0.35rem;
  font-size: 1.12rem;
  line-height: 1.25;
}

.category-label {
  color: var(--blue);
  font-size: 0.76rem;
  font-weight: 950;
  text-transform: uppercase;
}

.favorite-btn {
  min-width: 3rem;
  padding: 0;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  font-size: 1.35rem;
}

.favorite-btn.is-active {
  border-color: rgba(22, 163, 74, 0.2);
  background: #ecfdf3;
  color: var(--green);
}

.tone-row {
  display: flex;
  gap: 0.45rem;
  max-width: 100%;
  margin-bottom: 0.75rem;
  overflow-x: auto;
  padding-bottom: 0.1rem;
}

.tone-chip {
  flex: 0 0 auto;
  min-height: 2.25rem;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  font-size: 0.82rem;
}

.tone-chip.is-active {
  border-color: rgba(15, 118, 110, 0.22);
  background: #e9f8f2;
  color: var(--blue);
}

.selected-tone {
  margin-bottom: 0.55rem;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.selected-tone strong {
  color: var(--blue);
}

.answer-box {
  border-radius: 8px;
  padding: 0.85rem;
  background: #f8fcfb;
  color: #243249;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.card-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 0.75rem;
}

.copy-btn {
  min-height: 3.1rem;
  width: min(100%, 18rem);
  box-shadow: 0 12px 24px rgba(25, 169, 116, 0.22);
}

.section-title {
  margin: 0.2rem 0 1rem;
}

.section-title h2 {
  margin-bottom: 0.25rem;
  font-size: 1.6rem;
}

.variables-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  padding: 1rem;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.98), rgba(248, 252, 251, 0.98));
}

.variables-grid .primary-btn {
  grid-column: 1 / -1;
}

.admin-form {
  grid-template-columns: 1fr 1fr 7rem;
  margin-bottom: 1rem;
  padding: 1rem;
}

.admin-tools {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(16rem, 1.2fr);
  gap: 0.85rem;
  align-items: start;
  margin-bottom: 1rem;
}

.admin-stats {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.admin-stat-pill {
  min-height: 2.35rem;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.4rem 0.7rem;
  background: #fff;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
}

.admin-stat-main {
  border-color: rgba(15, 118, 110, 0.24);
  background: #e9f8f2;
  color: var(--blue);
}

.tone-editor {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.85rem;
}

.tone-editor label:last-child {
  grid-column: 1 / -1;
}

.admin-actions {
  grid-column: 1 / -1;
  display: flex;
  gap: 0.6rem;
}

.admin-row {
  padding: 0.85rem;
  box-shadow: var(--soft-shadow);
  border-color: rgba(15, 118, 110, 0.12);
}

.admin-row-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.7rem;
}

.admin-row h3 {
  margin-bottom: 0.25rem;
  font-size: 1rem;
}

.admin-row-actions {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.small-btn.danger {
  color: var(--danger);
}

.empty-state {
  padding: 1.15rem;
  color: var(--muted);
  box-shadow: var(--soft-shadow);
  line-height: 1.5;
  background: #fff;
}

.bottom-nav {
  display: none;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 1rem;
  z-index: 20;
  width: min(calc(100% - 2rem), 24rem);
  padding: 0.85rem 1rem;
  border-radius: 8px;
  background: #102a43;
  color: #fff;
  font-weight: 850;
  text-align: center;
  opacity: 0;
  transform: translate(-50%, 1rem);
  pointer-events: none;
  transition: 0.2s ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (max-width: 900px) {
  .auth-wrap,
  .app-shell,
  .hero-panel,
  .utility-bar,
  .admin-form,
  .admin-tools,
  .tone-editor,
  .variables-grid {
    grid-template-columns: 1fr;
  }

  .app-shell,
  .main-area {
    width: 100%;
    max-width: 100%;
  }

  .sidebar {
    display: none;
  }

  .main-area {
    padding-bottom: calc(5.8rem + env(safe-area-inset-bottom));
  }

  .hero-metrics {
    grid-template-columns: repeat(3, 1fr);
  }

  .bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.3rem;
    padding: 0.55rem 0.55rem calc(0.55rem + env(safe-area-inset-bottom));
    border-top: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(16px);
  }

  .bottom-nav.is-user-menu {
    grid-template-columns: repeat(3, 1fr);
  }

  .bottom-nav button {
    min-height: 3rem;
    font-size: 0.72rem;
    display: grid;
    place-items: center;
    gap: 0.12rem;
    padding: 0.35rem 0.2rem;
    line-height: 1.1;
  }

  .bottom-nav button span {
    display: block;
    font-size: 1rem;
  }

  .category-strip {
    max-width: 100%;
    margin: 0 0 1rem;
    padding: 0 0 0.2rem;
  }

  .mobileAdminBtn,
  #mobileAdminBtn {
    display: inline-flex;
  }
}

@media (max-width: 560px) {
  .auth-screen,
  .main-area {
    padding-left: 0.8rem;
    padding-right: 0.8rem;
  }

  .auth-intro,
  .auth-card,
  .hero-panel,
  .response-card,
  .admin-form,
  .variables-grid {
    border-radius: 8px;
  }

  .topbar h1 {
    font-size: 2rem;
  }

  .hero-panel h2 {
    font-size: 2.1rem;
  }

  .hero-metrics {
    gap: 0.45rem;
  }

  .hero-metrics article {
    min-height: 5.2rem;
    padding: 0.65rem;
  }

  .hero-metrics strong {
    font-size: 1.45rem;
  }

  .hero-metrics span {
    font-size: 0.72rem;
  }

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

  .copy-btn {
    width: 100%;
  }

  .response-head,
  .admin-row-head {
    align-items: stretch;
  }
}
