:root {
  color-scheme: dark;
  --bg: #0d1311;
  --bg-soft: #0b0b0b;
  --panel: #121e18;
  --panel-strong: #121c19;
  --border: #26352e;
  --text: #e7ede9;
  --muted: #a0aaa4;
  --dim: #94a29b;
  --green: #52c198;
  --green-soft: #79bfa8;
  --green-faint: #17352a;
  --input: #18221f;
  --surface: #18221f;
  --button-text: #0c241a;
  --control-height: 62px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

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

body {
  min-height: 100vh;
  min-height: 100svh;
  background: var(--bg-soft);
}

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

button {
  cursor: pointer;
}

button,
input,
textarea,
select,
summary {
  transition: border-color 0.2s ease, background-color 0.2s ease, color 0.2s ease;
}

.app-shell {
  width: 100%;
  min-width: 0;
  display: grid;
  place-items: start center;
  padding: 24px;
}

.phone {
  min-width: 0;
  width: min(100%, 1200px);
  min-height: calc(100svh - 48px);
  border-radius: 20px;
  background: var(--bg);
  border: 1px solid var(--border);
  box-shadow: 0 32px 80px rgba(0, 0, 0, 0.55);
  overflow: clip;
  position: relative;
}

.screen-stack {
  position: relative;
}

.app-navigation {
  padding: 16px 18px 0;
  background: var(--bg);
}

.screen {
  min-width: 0;
  display: none;
  animation: fadeIn 0.22s ease;
  padding: 16px 18px 24px;
  background: var(--bg);
}

.screen.active {
  display: block;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.pill-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 10px;
  min-height: 40px;
  padding: 0 2px 12px;
  border-bottom: 1px solid var(--border);
}

.brand-home-container {
  padding: 2px;
  cursor: pointer;
}

.brand-hero {
  margin: 0;
  line-height: 1.1;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  display: inline-flex;
  align-items: center;
}

.brand-icon {
  display: block;
  width: 1.7em;
  height: 1.7em;
  margin-right: 8px;
  flex-shrink: 0;
}

.brand-home {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  color: var(--text);
  text-decoration: none;
}

.brand-accent {
  color: var(--green-soft);
}

.prototype-tag {
  margin-left: auto;
  font-size: 0.65rem;
  text-transform: uppercase;
  color: var(--dim);
  letter-spacing: 0.1em;
  white-space: nowrap;
}

.tab-strip {
  display: flex;
  width: fit-content;
  max-width: 100%;
  gap: 2px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 3px;
  margin-top: 8px;
}

.tab {
  flex: 0 1 auto;
  min-width: 0;
  min-height: 44px;
  border-radius: 6px;
  padding: 0 12px;
  white-space: nowrap;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 0.72rem;
  letter-spacing: -0.02em;
  font-weight: 600;
}

.tab:hover {
  color: var(--text);
}

.tab.active {
  background: var(--panel-strong);
  color: var(--text);
}

.intro-block {
  padding-top: 20px;
  margin-bottom: 14px;
}

.intro-block h2 {
  margin: 0 0 14px;
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 700;
  letter-spacing: -0.025em;
  font-size: clamp(1.65rem, 5vw, 3rem);
  line-height: 1.08;
  max-width: 400px;
}

.intro-block p {
  margin: 0;
  font-size: 0.97rem;
  line-height: 1.55;
  color: var(--muted);
}

.matter-form,
.signup-form {
  margin-top: 12px;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--panel-strong);
}

.field-group {
  min-width: 0;
  margin-bottom: 18px;
}

.field-group label {
  display: block;
  margin-bottom: 8px;
  color: var(--dim);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

textarea,
input:not([type="checkbox"]):not([type="hidden"]),
select.select-box {
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--input);
  color: var(--text);
  padding: 18px 16px;
  font-size: 1rem;
  line-height: 1.5;
  outline: none;
}

input:not([type="checkbox"]):not([type="hidden"]):not([type="file"]),
select.select-box {
  height: var(--control-height);
}

input[type="file"] {
  height: auto;
}

input[type="file"]::file-selector-button {
  margin-right: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  cursor: pointer;
}

textarea {
  resize: vertical;
  min-height: 102px;
}

.field-row {
  display: flex;
  gap: 16px;
}

.field-row .half {
  flex: 1;
  min-width: 0;
}

input:focus-visible,
textarea:focus-visible,
select:focus-visible,
.brand-home:focus-visible,
button:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 3px;
}

select.select-box {
  display: block;
  cursor: pointer;
}

.primary-button,
.secondary-button {
  width: 100%;
  padding: 12px 16px;
  border-radius: 10px;
  overflow-wrap: anywhere;
}

.primary-button {
  margin-top: 4px;
  min-height: 52px;
  border: 1px solid transparent;
  background: var(--green);
  color: var(--button-text);
  font-weight: 700;
  font-size: 1.06rem;
}

.primary-button:hover:not(:disabled) {
  background: var(--green-soft);
}

.secondary-button:hover:not(:disabled) {
  border-color: var(--green-soft);
}

.results-title {
  margin: 0 0 8px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.65rem, 4vw, 2.2rem);
  letter-spacing: -0.025em;
}

.results-count {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 0.875rem;
  line-height: 1.5;
}

#panel-results {
  background: var(--bg);
}

.results-grid {
  display: grid;
  gap: 18px;
  align-items: start;
}

.lawyer-card {
  min-width: 0;
  overflow-wrap: anywhere;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--panel);
  padding: 20px 18px;
}

.card-header {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr);
  align-items: start;
  gap: 14px;
  margin-bottom: 12px;
}

.card-identity {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 56px;
}

.card-identity .profile-picture {
  width: 56px;
  height: 56px;
  flex-basis: 56px;
  border: 2px solid var(--border);
}

.card-identity .score-ring {
  width: 42px;
  height: 42px;
  border: 2px solid var(--panel);
}

.score-ring {
  position: relative;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: conic-gradient(var(--green) 0deg calc(var(--score) * 3.6deg), var(--border) 0deg 360deg);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.score-ring::before {
  content: "";
  position: absolute;
  inset: 4px;
  background: var(--panel);
  border-radius: 50%;
}

.score-ring span {
  position: relative;
  z-index: 1;
  font-size: 0.75rem;
  color: var(--text);
  font-weight: 700;
}

.profile-meta {
  min-width: 0;
}

.name-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
}

.name-line h3 {
  flex-basis: 100%;
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.08rem;
  line-height: 1.2;
  font-weight: 700;
  letter-spacing: normal;
}

.demo-pill {
  display: inline-block;
  font-size: 0.64rem;
  border-radius: 5px;
  border: 1px solid var(--green-faint);
  background: var(--green-faint);
  color: var(--green-soft);
  padding: 4px 8px;
  text-transform: none;
}

.profile-meta p {
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.5;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.tags span {
  display: inline-flex;
  align-items: center;
  border-radius: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 0.75rem;
  padding: 5px 7px;
}

.tags .matched-tag {
  background: var(--green);
  color: var(--button-text);
  border-color: transparent;
}

.fee-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
  font-size: 0.8rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-weight: 600;
  color: var(--text);
}

.fee-badge {
  font-size: 0.65rem;
  font-family: system-ui, sans-serif;
  font-weight: 400;
  text-transform: lowercase;
  color: var(--muted);
  margin-left: 4px;
}

.long-copy {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 0.875rem;
  line-height: 1.6;
}

.details-box {
  border-top: 1px solid var(--border);
  padding-top: 10px;
}

.meta-label {
  margin: 14px 0 8px;
  color: var(--dim);
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.meta-label span {
  text-transform: none;
  letter-spacing: normal;
  color: var(--text);
  font-size: 0.75rem;
}

.details-box ul {
  margin: 0;
  padding-left: 18px;
  color: var(--text);
  line-height: 1.5;
  font-size: 0.8rem;
}

.reported-cases {
  font-family: Georgia, "Times New Roman", serif;
  font-style: italic;
}

.match-explanation {
  margin-top: 20px;
  border-top: 1px dashed var(--border);
  padding-top: 4px;
  font-size: 0.875rem;
}

.match-explanation summary {
  display: list-item;
  min-height: 44px;
  padding-block: 12px;
  color: var(--green-soft);
  font-weight: 600;
  cursor: pointer;
}

summary:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 4px;
}

.request-button {
  width: auto;
  min-height: 44px;
  margin-top: 16px;
  padding: 6px 14px;
  border-radius: 10px;
  font-size: 0.8rem;
}

.retainer-note {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.5;
}

#introduction-dialog {
  width: min(90vw, 380px);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 24px;
  background: var(--panel);
  color: var(--text);
  max-height: calc(100svh - 32px);
  overflow-y: auto;
}

#introduction-dialog::backdrop {
  background: rgba(0, 0, 0, 0.7);
}

#introduction-dialog h2 {
  font-family: Georgia, "Times New Roman", serif;
}

#introduction-dialog p {
  color: var(--muted);
  line-height: 1.6;
}

.signup-body {
  padding-top: 8px;
}

.signup-body h2 {
  margin: 0 0 12px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.65rem, 5vw, 2.8rem);
  line-height: 1.08;
  letter-spacing: -0.025em;
}

.signup-intro p {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.5;
}

.field-help,
.score-breakdown {
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.6;
}

.signup-body .field-help {
  margin: 8px 0 0;
}

.practice-fieldset .field-help {
  margin: 0 0 12px;
}

.saved-profiles {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.saved-profiles h3 {
  margin: 0 0 8px;
  font-size: 1rem;
}

.saved-profile-entry {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
}

.saved-profile-entry .secondary-button {
  flex: 1;
  margin: 0;
}

.profile-picture {
  display: inline-grid;
  width: 52px;
  height: 52px;
  flex: 0 0 52px;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface);
  object-fit: cover;
}

.profile-picture.small {
  width: 44px;
  height: 44px;
  flex-basis: 44px;
}

.profile-initials {
  border: 4px solid transparent;
  background:
    linear-gradient(var(--surface), var(--surface)) padding-box,
    conic-gradient(var(--green) 0deg 360deg) border-box;
  color: var(--green-soft);
  font-size: 0.8rem;
  font-weight: 600;
}

.photo-preview {
  display: flex;
  align-items: center;
  min-height: 52px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.8rem;
}

.preview-picture {
  width: 88px;
  height: 88px;
  flex-basis: 88px;
}

.form-message {
  margin: 0 0 18px;
  padding: 12px;
  border: 1px solid var(--green-soft);
  border-radius: 8px;
  overflow-wrap: anywhere;
}

.form-message[role="alert"] {
  border-color: #d99b83;
  color: #f0c4b2;
}

button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.practice-fieldset {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
}

.practice-fieldset legend {
  color: var(--dim);
  font-size: 0.75rem;
}

.practice-options {
  display: grid;
  gap: 4px;
  max-height: 260px;
  overflow-y: auto;
}

.practice-options .practice-choice {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  margin: 0;
  font-size: 0.875rem;
  text-transform: none;
  letter-spacing: normal;
  color: var(--text);
  border-radius: 6px;
  padding: 6px;
}

.practice-choice:hover,
.practice-choice:focus-within {
  background: var(--surface);
}

.practice-choice input {
  flex: 0 0 20px;
  width: 20px;
  height: 20px;
  margin: 0;
  accent-color: var(--green);
}

.signup-form .checkbox-row {
  min-height: 44px;
  margin-bottom: 18px;
}

.secondary-button {
  min-height: 44px;
  margin-top: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}

.unverified-pill {
  display: inline-block;
  color: var(--muted);
  font-size: 0.7rem;
  padding: 4px 0;
}

.results-context,
.empty-results {
  color: var(--muted);
  overflow-wrap: anywhere;
  line-height: 1.6;
}

.results-context {
  margin: 0 0 24px;
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel-strong);
  font-size: 0.875rem;
}

.score-breakdown {
  margin: 8px 0 0;
  padding-left: 18px;
}

.score-breakdown li + li {
  margin-top: 8px;
}

.checkbox-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  color: var(--text);
  font-size: 0.92rem;
}

.checkbox-row input {
  width: 18px;
  height: 18px;
  accent-color: var(--green);
  margin: 2px 0 0;
}

.how-layout {
  margin-top: 18px;
  padding: 18px 8px;
}

.how-layout h2 {
  margin: 0 0 14px;
  font-size: 2.2rem;
  line-height: 1.1;
  letter-spacing: -0.025em;
  font-family: Georgia, "Times New Roman", serif;
}

.how-layout ol {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.7;
  font-size: 1rem;
}

.how-layout li + li {
  margin-top: 24px;
}

.how-layout strong {
  color: var(--text);
}

@media (min-width: 768px) {
  .app-navigation {
    padding: 24px 40px 16px;
  }

  .brand-hero {
    font-size: 1.65rem;
  }

  .tab {
    padding-inline: 20px;
    font-size: 0.9rem;
  }

  .screen {
    padding: 32px 40px 40px;
  }

  .intro-block {
    padding-top: 24px;
  }

  .lawyer-card {
    padding: 24px;
  }

  .long-copy,
  .details-box ul,
  .profile-meta p {
    font-size: 0.875rem;
  }

  .how-layout {
    max-width: 760px;
    margin: 0 auto;
    padding: 32px 0;
  }
}

@media (min-width: 1024px) {
  #panel-clients.active,
  .signup-body {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr);
    align-items: start;
    gap: 40px;
  }

  .intro-block h2 {
    max-width: none;
  }

  .matter-form,
  .signup-form {
    margin-top: 0;
    padding: 24px;
  }

  .results-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 24px;
  }
}

@media (max-width: 767px) {
  .app-shell {
    padding: 0 env(safe-area-inset-right) 0 env(safe-area-inset-left);
  }

  .phone {
    border-radius: 0;
    min-height: 100vh;
    min-height: 100svh;
    width: 100%;
    border: none;
    box-shadow: none;
    padding-bottom: env(safe-area-inset-bottom);
  }

  .app-navigation {
    padding-top: calc(16px + env(safe-area-inset-top));
  }

  .screen,
  .app-navigation {
    max-width: 600px;
    margin-inline: auto;
  }

  .tab-strip {
    width: 100%;
  }

  .tab {
    flex: 1 1 auto;
    padding-inline: 8px;
    font-size: clamp(0.65rem, 2.6vw, 0.8rem);
  }
}

@media (max-width: 359px) {
  .pill-title-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 6px 10px;
  }

  .prototype-tag {
    grid-column: 1;
    grid-row: 2;
    margin-left: 0;
  }

  .screen,
  .app-navigation {
    padding-inline: 12px;
  }

  .matter-form,
  .signup-form,
  .lawyer-card {
    padding: 16px 12px;
  }

  .prototype-tag {
    font-size: 0.5rem;
  }
}

@media (max-width: 479px) {
  .signup-form .field-row {
    flex-direction: column;
    gap: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .screen {
    animation: none;
  }

  button,
  input,
  textarea,
  select,
  summary {
    transition: none;
  }
}
