:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --line: #d9e0ea;
  --line-strong: #c5cfdd;
  --text: #1f2937;
  --muted: #667085;
  --soft: #8a94a6;
  --primary: #1d4ed8;
  --primary-dark: #173f9b;
  --primary-soft: #e8f0ff;
  --green: #16845f;
  --amber: #b7791f;
  --danger: #c2410c;
  --shadow: 0 18px 42px rgba(31, 41, 55, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

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

button,
input,
textarea {
  font: inherit;
}

button {
  color: inherit;
}

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

.app-shell {
  width: min(100%, 720px);
  min-height: 100vh;
  margin: 0 auto;
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow-x: hidden;
}

.club-hero {
  padding: 22px 18px 20px;
  border-bottom: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(232, 240, 255, 0.86), rgba(255, 255, 255, 0.95)),
    var(--surface);
}

.hero-content {
  display: grid;
  gap: 9px;
}

.club-mark {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--primary);
  font-size: 13px;
  font-weight: 800;
}

.mark-flame {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  font-weight: 900;
}

h1 {
  font-size: 30px;
  line-height: 1.05;
  font-weight: 900;
}

.hero-content p,
.home-intro p {
  max-width: 560px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.45;
}

main {
  padding: 18px 14px 94px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.home-intro {
  display: grid;
  gap: 6px;
  margin-bottom: 14px;
}

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

.section-head.compact {
  margin-top: 22px;
}

.eyebrow {
  color: var(--primary);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

h2 {
  margin-top: 2px;
  font-size: 22px;
  line-height: 1.15;
}

h3 {
  font-size: 16px;
  line-height: 1.25;
}

.home-actions {
  display: grid;
  gap: 10px;
}

.task-button {
  width: 100%;
  min-height: 86px;
  display: grid;
  grid-template-columns: 38px 1fr;
  grid-template-rows: auto auto;
  gap: 3px 12px;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  text-align: left;
  cursor: pointer;
}

.task-button span {
  grid-row: 1 / 3;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 900;
}

.task-button b {
  font-size: 16px;
}

.task-button small {
  color: var(--muted);
  font-size: 13px;
}

.task-button.primary {
  border-color: rgba(29, 78, 216, 0.32);
  background: var(--primary-soft);
}

.task-button.primary span {
  background: var(--primary);
  color: #fff;
}

.icon-button {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  cursor: pointer;
}

.progress-panel,
.metric-card,
.scenario-card,
.step-card,
.doc-row,
.law-row,
.chat-message,
.profile-card,
.doc-viewer {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.progress-panel {
  min-height: 104px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px;
  background: linear-gradient(135deg, #eef4ff, #ffffff);
}

.progress-value {
  display: block;
  font-size: 34px;
  font-weight: 900;
}

.progress-panel p,
.metric-card p,
.scenario-card p,
.step-card p,
.doc-row p,
.law-row p,
.doc-viewer p,
.profile-card p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.progress-ring {
  width: 68px;
  height: 68px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background:
    radial-gradient(circle, #fff 55%, transparent 56%),
    conic-gradient(var(--primary) 0deg, var(--primary) 318deg, #dbe4ef 318deg);
}

.progress-ring span {
  color: var(--primary);
  font-weight: 900;
}

.quick-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.metric-card {
  min-height: 98px;
  padding: 14px;
}

.metric-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.metric-icon,
.doc-kind,
.law-number {
  min-width: 34px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 12px;
  font-weight: 900;
}

.metric-card strong {
  display: block;
  margin-top: 12px;
  font-size: 22px;
}

.scenario-list,
.step-list,
.doc-list,
.law-list {
  display: grid;
  gap: 10px;
}

.scenario-card,
.step-card,
.doc-row,
.law-row,
.doc-viewer {
  padding: 14px;
}

.scenario-card {
  display: grid;
  gap: 10px;
}

.scenario-card button,
.primary-action,
.secondary-action,
.suggestions button,
.doc-viewer a,
.doc-viewer button {
  min-height: 40px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 0 14px;
  background: var(--surface);
  color: var(--primary);
  cursor: pointer;
  text-decoration: none;
  font-weight: 800;
}

.step-card {
  display: grid;
  grid-template-columns: 38px 1fr;
  gap: 12px;
  align-items: start;
}

.step-num {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: #fff;
  background: var(--primary);
  font-weight: 900;
}

.step-card ul {
  margin: 10px 0 0;
  padding-left: 17px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.action-band {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 14px;
}

.primary-action,
.chat-form button {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}

.secondary-action {
  background: var(--surface);
}

.search-box {
  height: 46px;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--primary);
}

.search-box input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
}

.download-band {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

.download-band a {
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(29, 78, 216, 0.28);
  border-radius: 8px;
  background: var(--primary-soft);
  color: var(--primary);
  text-decoration: none;
  font-size: 14px;
  font-weight: 900;
}

.doc-viewer {
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
  background: var(--surface-soft);
}

.doc-viewer.active {
  border-color: rgba(29, 78, 216, 0.32);
  background: #fff;
}

.doc-viewer-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.doc-preview {
  max-height: 360px;
  overflow: auto;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
  color: var(--text);
  font-size: 13px;
  line-height: 1.45;
  white-space: pre-wrap;
}

.doc-row,
.law-row {
  width: 100%;
  display: grid;
  grid-template-columns: 40px 1fr;
  gap: 12px;
  align-items: start;
  color: inherit;
  text-decoration: none;
  text-align: left;
  cursor: pointer;
}

.doc-row {
  border: 1px solid var(--line);
}

.doc-row:hover {
  border-color: rgba(29, 78, 216, 0.42);
  background: #fbfdff;
}

.doc-meta,
.law-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: #eef2f7;
  color: #4b5565;
  font-size: 11px;
  font-weight: 800;
}

.chat-panel {
  display: grid;
  gap: 12px;
}

.profile-card {
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
  padding: 12px;
  background: var(--surface-soft);
}

.profile-card button {
  justify-self: start;
  min-height: 34px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 0 12px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
}

.chat-form {
  display: grid;
  gap: 9px;
  padding: 12px;
  border: 1px solid rgba(29, 78, 216, 0.35);
  border-radius: 8px;
  background: var(--primary-soft);
}

.chat-form label {
  color: var(--primary-dark);
  font-size: 13px;
  font-weight: 900;
}

.chat-form textarea {
  width: 100%;
  min-height: 94px;
  resize: vertical;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  outline: 0;
  padding: 12px;
  background: #fff;
  color: var(--text);
  line-height: 1.4;
}

.chat-form button {
  min-height: 44px;
  border-radius: 8px;
  font-weight: 900;
  cursor: pointer;
}

.suggestions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
}

.suggestions button {
  min-height: 36px;
  justify-content: center;
  white-space: normal;
  text-align: center;
  font-size: 13px;
  line-height: 1.2;
}

.chat-feed {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-bottom: 8px;
}

.chat-message {
  max-width: 92%;
  padding: 12px;
  line-height: 1.42;
  font-size: 14px;
}

.chat-message.assistant {
  align-self: flex-start;
  background: var(--surface);
}

.chat-message.user {
  align-self: flex-end;
  border-color: rgba(29, 78, 216, 0.35);
  background: var(--primary-soft);
}

.chat-message strong {
  color: var(--primary-dark);
}

.chat-message ul {
  margin: 8px 0 0;
  padding-left: 18px;
}

.template-links {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.template-link-row {
  display: grid;
  grid-template-columns: 52px 1fr;
  gap: 6px 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
}

.template-link-row span {
  grid-row: 1 / 3;
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 11px;
  font-weight: 900;
}

.template-link-row b {
  font-size: 13px;
  line-height: 1.25;
}

.template-link-row a,
.template-link-row button,
.template-link.wide {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(29, 78, 216, 0.28);
  border-radius: 8px;
  padding: 0 10px;
  background: #fff;
  color: var(--primary);
  text-decoration: none;
  font-size: 12px;
  font-weight: 900;
  cursor: pointer;
}

.template-link-row a {
  grid-column: 2;
}

.template-link-row button {
  grid-column: 2;
}

.template-link.wide {
  width: 100%;
  background: var(--primary-soft);
}

.bottom-nav {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: min(100%, 720px);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(18px);
  z-index: 10;
}

.nav-item {
  min-height: 58px;
  display: grid;
  place-items: center;
  gap: 2px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--soft);
  cursor: pointer;
}

.nav-item span {
  font-size: 18px;
}

.nav-item b {
  font-size: 10px;
}

.nav-item.active {
  color: var(--primary);
  background: var(--primary-soft);
}

@media (min-width: 760px) {
  .app-shell {
    min-height: 92vh;
    margin-top: 24px;
    margin-bottom: 24px;
    border: 1px solid var(--line);
    border-radius: 8px;
  }

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

  .task-button {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
  }

  .task-button span {
    grid-row: auto;
  }

  .bottom-nav {
    border-left: 1px solid var(--line);
    border-right: 1px solid var(--line);
  }
}
