:root {
  --petrol: #0d4f4b;
  --teal: #176f66;
  --deep: #102f2d;
  --cream: #f7f3e9;
  --paper: #fffdf8;
  --sage-soft: #e5eddf;
  --ink: #17312e;
  --muted: #64756e;
  --line: #dfe4d9;
  --green: #4f8a5c;
  --amber: #b98224;
  --red: #bd5a52;
  --shadow: 0 16px 38px rgba(13, 79, 75, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--cream);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.55;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 14px clamp(18px, 5vw, 64px);
  background: rgba(247, 243, 233, 0.95);
  border-bottom: 1px solid rgba(13, 79, 75, 0.12);
  backdrop-filter: blur(14px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--petrol);
  color: var(--paper);
  font-weight: 800;
}

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

.brand small {
  color: var(--muted);
  font-size: 0.74rem;
}

.top-nav {
  display: flex;
  gap: 6px;
  color: var(--muted);
  font-size: 0.92rem;
}

.top-nav a {
  padding: 8px 11px;
  border-radius: 8px;
}

.top-nav a:hover,
.top-nav a[aria-current="page"] {
  background: var(--sage-soft);
  color: var(--deep);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--teal);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 16px;
  color: var(--deep);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2rem, 4vw, 3.8rem);
  line-height: 1.04;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 8px;
  color: var(--deep);
  font-size: clamp(1.25rem, 2vw, 1.65rem);
  line-height: 1.2;
}

h3 {
  margin-bottom: 6px;
  color: var(--deep);
  font-size: 1rem;
}

p {
  color: var(--muted);
}

.home-page,
.about-page {
  max-width: 1120px;
  margin: 0 auto;
  padding: clamp(42px, 8vw, 92px) 22px 52px;
  text-align: center;
}

.home-hero {
  display: grid;
  gap: 28px;
  justify-items: center;
  min-height: 64vh;
}

.hero-content {
  max-width: 650px;
  margin: 0 auto;
}

.intro {
  max-width: 560px;
  margin-left: auto;
  margin-right: auto;
  font-size: 1.04rem;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin-top: 24px;
}

.primary-link,
.secondary-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 15px;
  border-radius: 8px;
  font-weight: 800;
}

.primary-link {
  background: var(--petrol);
  color: var(--paper);
}

.secondary-link {
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--deep);
}

.quiet-panel,
.trust-strip,
.search-card,
.result-card,
.journey-card,
.interaction-card-large,
.about-grid article {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.quiet-panel {
  width: min(100%, 520px);
  padding: 22px;
}

.summary-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.summary-list li {
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  color: var(--deep);
  font-weight: 800;
}

.summary-list li:last-child {
  border-bottom: 0;
}

.trust-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  justify-content: center;
  width: min(100%, 720px);
  margin-top: 28px;
  margin-left: auto;
  margin-right: auto;
  padding: 16px 18px;
  box-shadow: none;
}

.trust-strip span {
  color: var(--muted);
}

.about-hero {
  max-width: 720px;
  margin-left: auto;
  margin-right: auto;
  margin-bottom: 28px;
}

.about-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.about-grid article {
  padding: 20px;
  box-shadow: none;
}

.search-page {
  max-width: 980px;
  margin: 0 auto;
  padding: 30px 18px 48px;
  text-align: center;
}

.search-card,
.result-card,
.journey-card,
.interaction-card-large {
  padding: clamp(18px, 3vw, 26px);
}

.search-card {
  margin-bottom: 16px;
}

.page-title {
  max-width: 620px;
  margin-left: auto;
  margin-right: auto;
}

.search-form {
  max-width: 680px;
  margin: 18px auto 0;
  text-align: left;
}

.search-form label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 800;
}

.search-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.search-row input {
  min-width: 0;
  width: 100%;
  padding: 12px 13px;
  border: 1px solid #c8d1c4;
  border-radius: 8px;
  background: #fcfaf2;
  color: var(--ink);
}

.search-row input:focus,
button:focus-visible,
.upload-button:focus-within {
  outline: 3px solid rgba(23, 111, 102, 0.18);
  outline-offset: 2px;
}

.search-row button,
.quick-picks button,
.upload-button,
#add-medicine,
.interaction-head button,
.medicine-pill button {
  border-radius: 8px;
  font-weight: 800;
}

.search-row button,
#add-medicine {
  border: 0;
  background: var(--petrol);
  color: var(--paper);
}

.search-row button {
  padding: 0 14px;
}

.form-message {
  min-height: 22px;
  margin: 8px 0 0;
  color: var(--teal);
  font-size: 0.88rem;
  font-weight: 700;
}

.upload-row {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-top: 10px;
}

.upload-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 190px;
  height: 56px;
  min-height: 56px;
  padding: 0 14px;
  line-height: 1;
  text-align: center;
  align-self: center;
  appearance: none;
  vertical-align: top;
}

.upload-button {
  gap: 8px;
  border: 1px dashed var(--teal);
  background: #edf4ea;
  color: var(--deep);
}

.button-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  height: 100%;
  line-height: 1;
  white-space: nowrap;
}

#label-upload {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.quick-picks button,
.interaction-head button,
.medicine-pill button {
  border: 0;
  background: var(--sage-soft);
  color: var(--deep);
}

.upload-row .upload-button {
  border-width: 1px;
  border-style: solid;
  margin: 0;
}

.upload-preview {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: center;
  width: min(100%, 680px);
  margin-top: 12px;
  margin-left: auto;
  margin-right: auto;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fcfaf2;
  text-align: left;
}

.upload-preview.no-image {
  display: flex;
  max-width: 680px;
  padding: 14px 16px;
  text-align: left;
}

.upload-preview > div {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-width: 0;
  max-width: 100%;
}

.upload-preview strong {
  flex: 0 0 auto;
}

.upload-preview img {
  width: 56px;
  height: 56px;
  border-radius: 8px;
  object-fit: cover;
  background: var(--sage-soft);
}

.upload-preview img:not([src]) {
  display: none;
}

.upload-preview p {
  margin-bottom: 0;
  font-size: 0.86rem;
  white-space: normal;
}

.quick-picks {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-top: 16px;
}

.quick-picks button {
  padding: 7px 10px;
  font-size: 0.86rem;
}

.result-card {
  margin-bottom: 16px;
}

.journey-card {
  margin-bottom: 16px;
}

.profile-first-card {
  background: #fcfaf2;
}

.profile-first-card h1 {
  max-width: 720px;
  margin-left: auto;
  margin-right: auto;
  font-size: clamp(1.85rem, 3vw, 2.7rem);
}

.profile-first-card .profile-panel {
  margin-bottom: 0;
}

.output-journey-card .journey-head {
  max-width: 720px;
}

.journey-head {
  display: grid;
  gap: 8px;
  justify-items: center;
  max-width: 680px;
  margin: 0 auto 18px;
}

.profile-purpose {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  align-items: center;
  margin-bottom: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #eef4e9;
  text-align: left;
}

.profile-purpose p {
  margin: 4px 0 0;
}

.profile-purpose button {
  min-height: 40px;
  padding: 0 14px;
  border: 0;
  border-radius: 8px;
  background: var(--petrol);
  color: var(--paper);
  font-weight: 800;
}

.profile-impact {
  margin-bottom: 12px;
  padding: 11px 12px;
  border-radius: 8px;
  background: #fcfaf2;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.profile-panel {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 10px;
  max-height: 360px;
  overflow: auto;
  padding: 4px 4px 12px;
  margin-bottom: 18px;
  text-align: left;
}

.profile-panel.is-collapsed {
  display: none;
}

.profile-panel label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 800;
}

.profile-panel select,
.profile-panel textarea {
  min-width: 0;
  width: 100%;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fcfaf2;
  color: var(--deep);
  font: inherit;
}

.profile-panel textarea {
  resize: vertical;
  line-height: 1.45;
}

.profile-wide {
  grid-column: 1 / -1;
}

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

.journey-step {
  position: relative;
  display: grid;
  gap: 6px;
  min-height: 142px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fcfaf2;
  text-align: left;
}

.journey-step span {
  color: var(--teal);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.journey-step strong {
  color: var(--deep);
}

.journey-step p {
  margin-bottom: 0;
  font-size: 0.9rem;
}

.profile-step {
  grid-column: 1 / -1;
  min-height: 0;
  background: #eef4e9;
}

.muted-step {
  grid-column: 1 / -1;
  min-height: 0;
}

.simulation-note {
  margin: 14px 0 0;
  font-size: 0.88rem;
}

.result-header,
.interaction-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
  text-align: left;
}

.result-header h2,
.interaction-head h2 {
  margin-bottom: 0;
}

#add-medicine {
  min-height: 40px;
  padding: 0 14px;
}

.result-summary {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  padding: 14px;
  border-radius: 8px;
  background: #eef4e9;
  text-align: left;
}

.system-dot {
  display: inline-block;
  width: 14px;
  height: 14px;
  margin-top: 5px;
  border-radius: 50%;
  background: var(--teal);
}

.system-map {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin: 14px 0 16px;
}

.medicine-facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  margin: 12px 0 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--line);
  text-align: left;
}

.medicine-facts div {
  min-width: 0;
  padding: 11px 12px;
  background: #fcfaf2;
}

.medicine-facts dt {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
}

.medicine-facts dd {
  margin: 3px 0 0;
  overflow-wrap: anywhere;
  color: var(--deep);
  font-size: 0.92rem;
  font-weight: 700;
}

.system-node {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fcfaf2;
  color: var(--muted);
  font-size: 0.84rem;
}

.system-node.active {
  border-color: rgba(23, 111, 102, 0.52);
  background: var(--sage-soft);
  color: var(--deep);
}

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

details {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fcfaf2;
  text-align: left;
}

summary {
  padding: 12px 14px;
  color: var(--deep);
  cursor: pointer;
  font-weight: 900;
}

details p {
  margin: 0;
  padding: 0 14px 14px;
}

@media (max-width: 620px) {
  .medicine-facts {
    grid-template-columns: 1fr;
  }
}

.medicine-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-bottom: 14px;
}

.medicine-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 9px 8px 11px;
  border-radius: 999px;
  background: #edf4ea;
  color: var(--deep);
  font-weight: 800;
}

.medicine-pill button {
  padding: 4px 7px;
  font-size: 0.78rem;
}

.empty-text {
  margin: 0;
  color: var(--muted);
}

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

.interaction-card {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fcfaf2;
  text-align: left;
}

.status-dot {
  width: 12px;
  height: 12px;
  margin-top: 5px;
  border-radius: 50%;
}

.status-green {
  background: var(--green);
}

.status-amber {
  background: var(--amber);
}

.status-red {
  background: var(--red);
}

.interaction-card strong {
  display: block;
  margin-bottom: 3px;
  color: var(--deep);
}

.interaction-card p {
  margin-bottom: 0;
}

@media (max-width: 860px) {
  .about-grid,
  .profile-panel,
  .journey-flow {
    grid-template-columns: 1fr;
  }

  .home-hero {
    min-height: auto;
  }
}

@media (max-width: 620px) {
  .site-header {
    position: static;
    align-items: flex-start;
    flex-direction: column;
  }

  .top-nav {
    width: 100%;
    overflow-x: auto;
  }

  .search-row {
    grid-template-columns: 1fr;
  }

  .search-row button,
  #add-medicine {
    min-height: 40px;
  }

  .result-header,
  .interaction-head,
  .profile-purpose {
    align-items: flex-start;
    grid-template-columns: 1fr;
    flex-direction: column;
  }
}
