:root {
  --bg: #f3f7f5;
  --ink: #1b2a21;
  --muted: #607069;
  --line: #d8e2dd;
  --panel: #ffffff;
  --green: #1e7a57;
  --blue: #2463b8;
  --amber: #9f6400;
  --red: #b42318;
  --shadow: 0 14px 44px rgba(25, 42, 35, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Arial, "Noto Sans KR", sans-serif;
}

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

.app-shell {
  margin: 0 auto;
  max-width: 1020px;
  min-height: 100vh;
  padding: 22px;
}

.topbar {
  align-items: flex-start;
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr auto;
  margin-bottom: 14px;
}

.top-caption {
  color: var(--muted);
  margin-top: 6px;
}

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

h1,
h2 {
  line-height: 1.18;
}

.topbar h1 {
  margin: 6px 0 0;
  font-size: clamp(26px, 3.5vw, 40px);
}

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

.language-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  gap: 4px;
  padding: 4px;
}

.language-panel button {
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  min-width: 44px;
  padding: 8px 10px;
  font-weight: 800;
  cursor: pointer;
}

.language-panel button.active {
  background: var(--ink);
  color: #fff;
}

.danger {
  background: #fff1f0;
  border: 1px solid #f3c4c7;
  color: #8d1b2f;
}

.notice-band {
  align-items: center;
  background: #edf7f1;
  border: 1px solid #cde4d6;
  border-radius: 10px;
  color: #23413a;
  display: grid;
  gap: 10px;
  margin-bottom: 14px;
  padding: 11px 12px;
}

.notice-band strong {
  color: var(--green);
  font-size: 12px;
  font-weight: 850;
}

.notice-band span {
  color: #2f473e;
  font-size: 13px;
}

.network-band {
  background: #eef4f8;
  border: 1px solid #c8dae7;
  border-radius: 10px;
  color: #243c4b;
  display: grid;
  gap: 6px;
  margin-bottom: 14px;
  padding: 10px 12px;
}

.network-band strong {
  color: var(--blue);
  font-size: 12px;
  font-weight: 850;
}

.network-band span {
  font-size: 13px;
  line-height: 1.45;
}

.network-band.offline {
  background: #fff8e6;
  border-color: #f1cf7a;
  color: #513c08;
}

.network-band.offline strong {
  color: #7a4d00;
}

.comfort-start {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  display: grid;
  gap: 14px;
  margin-bottom: 12px;
  padding: 16px;
}

.comfort-start h2 {
  font-size: 22px;
  margin: 4px 0 6px;
}

.comfort-start p {
  color: var(--muted);
  line-height: 1.5;
  margin: 0;
}

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

.comfort-path {
  background: #f4f8ff;
  border: 1px solid #c8dae7;
  border-radius: 8px;
  color: #243c4b;
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
  padding: 12px;
}

.comfort-path strong {
  color: var(--blue);
  font-size: 13px;
  font-weight: 850;
}

.comfort-path ol {
  display: grid;
  gap: 6px;
  margin: 0;
  padding-left: 20px;
}

.comfort-path li {
  color: #304c5d;
  font-size: 14px;
  line-height: 1.45;
}

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

.comfort-cards article {
  background: #f7faf8;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 5px;
  padding: 10px;
}

.comfort-cards strong {
  color: var(--green);
  font-size: 12px;
}

.comfort-cards span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.pilot-flow-panel {
  background: #f7faf8;
  border: 1px solid var(--line);
  border-radius: 10px;
  margin-bottom: 12px;
  padding: 0;
}

.pilot-flow-panel summary {
  align-items: center;
  color: var(--green);
  cursor: pointer;
  display: flex;
  font-weight: 850;
  min-height: 44px;
  padding: 10px 14px;
}

.pilot-flow-panel[open] {
  background: var(--panel);
  box-shadow: 0 8px 24px rgba(25, 42, 35, 0.07);
}

.pilot-flow-panel[open] summary {
  border-bottom: 1px solid var(--line);
}

.safety-callout {
  background: #fff8e6;
  border: 1px solid #f1cf7a;
  border-radius: 8px;
  color: #513c08;
  display: grid;
  gap: 5px;
  padding: 10px 12px;
}

.safety-callout strong {
  color: #7a4d00;
  font-size: 12px;
  font-weight: 850;
}

.safety-callout span {
  font-size: 13px;
  line-height: 1.45;
}

.choice-strip {
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 8px;
  padding: 10px 12px;
}

.choice-strip strong {
  color: var(--green);
  font-size: 12px;
  font-weight: 850;
}

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

.active-choice {
  background: #17201b;
  border-color: #17201b;
  color: #fff;
}

.mode-status {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  margin: 0;
}

.progress-wrap {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  margin-bottom: 12px;
  padding: 14px;
}

.progress-track {
  display: grid;
  gap: 8px;
}

.progress-bar {
  border: 1px solid var(--line);
  border-radius: 999px;
  height: 10px;
  overflow: hidden;
}

.progress-bar span {
  display: block;
  background: linear-gradient(90deg, #2f7f5c, #1c8cb6);
  height: 100%;
  width: 0;
  transition: width 240ms ease;
}

.step-status-list {
  display: grid;
  gap: 6px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.step-status-pill {
  background: #f7faf8;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 3px;
  min-height: 58px;
  padding: 8px;
}

.step-status-pill strong {
  color: var(--ink);
  font-size: 12px;
}

.step-status-pill em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

.step-status-pill.active {
  background: #eef4f8;
  border-color: #8eb5cf;
}

.step-status-pill.done {
  background: #edf7f1;
  border-color: #b7dbc5;
}

.step-status-pill.done em {
  color: var(--green);
  font-weight: 800;
}

.flow-grid {
  display: grid;
  gap: 12px;
}

.step-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 18px;
}

.step-next {
  align-items: start;
  background: #eef4f8;
  border: 1px solid #c8dae7;
  border-radius: 8px;
  color: #243c4b;
  display: grid;
  gap: 4px;
  margin: 0 0 12px;
  padding: 10px 12px;
}

.step-next strong {
  color: var(--blue);
  font-size: 12px;
}

.step-next span {
  font-size: 14px;
  line-height: 1.45;
}

.step-subtext,
.muted-text {
  color: var(--muted);
  margin: 8px 0 12px;
}

form {
  display: grid;
  gap: 12px;
}

form.stack,
.stack {
  display: grid;
  gap: 12px;
}

fieldset {
  border: 1px solid var(--line);
  border-radius: 8px;
  margin: 0;
  padding: 8px 10px;
}

legend {
  padding: 0 6px;
}

label {
  display: grid;
  gap: 8px;
  font-weight: 650;
}

input,
textarea,
select,
button {
  border-radius: 8px;
}

input,
textarea,
select {
  border: 1px solid var(--line);
  min-height: 44px;
  padding: 10px;
  width: 100%;
}

input[type="number"] {
  appearance: textfield;
}

.checkbox-row,
.inline-2 {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.inline-2 .inline-2 {
  grid-template-columns: 1fr 1fr;
}

.checkbox-row label,
fieldset label {
  align-items: center;
  display: flex;
  font-weight: 500;
  gap: 8px;
}

.file-drop {
  align-items: center;
  border: 1px dashed var(--line);
  border-radius: 10px;
  display: flex;
  gap: 10px;
  justify-content: space-between;
  padding: 12px;
}

button {
  border: 1px solid transparent;
  cursor: pointer;
  min-height: 44px;
  padding: 10px 12px;
}

.primary {
  background: var(--green);
  color: #fff;
}

.secondary {
  background: #ffffff;
  border-color: var(--line);
  color: var(--ink);
}

.outline {
  background: #eef4f1;
  border-color: var(--line);
  color: var(--ink);
}

.small {
  font-size: 12px;
  color: var(--muted);
}

.result-box {
  background: #f6fbf7;
  border: 1px solid #cae3d3;
  border-radius: 10px;
  color: #1d3930;
  margin-top: 10px;
  padding: 11px 12px;
}

.result-box ul {
  margin: 6px 0 0;
  padding-left: 18px;
}

.result-box li {
  line-height: 1.4;
  margin: 5px 0;
}

.emergency-callout {
  color: var(--red);
  font-weight: 700;
  margin: 8px 0 0;
}

#labPreview {
  border-radius: 8px;
  display: none;
  margin-top: 10px;
  max-height: 240px;
  object-fit: cover;
  width: 100%;
}

#labPreview.show {
  display: block;
}

#summaryCards {
  display: grid;
  gap: 10px;
}

.summary-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
}

.summary-card-head {
  align-items: center;
  display: grid;
  gap: 8px;
  grid-template-columns: 1fr auto;
}

.summary-card h3 {
  color: var(--green);
  font-size: 13px;
  margin: 0;
}

.summary-card p {
  margin: 6px 0 0;
  white-space: pre-wrap;
  word-break: break-word;
}

.summary-copy {
  background: #eef4f8;
  border-color: #c8dae7;
  color: #243c4b;
  font-size: 12px;
  font-weight: 800;
  min-width: 44px;
  padding: 8px 10px;
}

.feedback-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 10px;
  padding: 12px;
}

.feedback-panel h3 {
  color: var(--green);
  font-size: 14px;
  margin: 0;
}

.feedback-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.benefit-delta {
  color: var(--green);
  font-size: 13px;
  font-weight: 700;
  margin: 0;
  min-height: 18px;
}

.feedback-command-box {
  display: grid;
  gap: 8px;
}

.pilot-log-fields {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 8px;
  padding: 10px;
}

.pilot-log-fields > strong {
  color: var(--green);
  font-size: 13px;
}

.pilot-log-hint {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
  margin: 0;
}

.feedback-command-output {
  background: #f7faf8;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  font-size: 12px;
  line-height: 1.45;
  margin: 0;
  min-height: 58px;
  overflow-x: auto;
  padding: 10px;
  white-space: pre-wrap;
  word-break: break-word;
}

.voice-row {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pilot-flow-panel {
  border-radius: 8px;
}

.pilot-flow-panel > :not(summary) {
  margin-left: 14px;
  margin-right: 14px;
}

.pilot-flow-panel > :last-child {
  margin-bottom: 14px;
}

.pilot-flow-head {
  align-items: start;
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr auto;
}

.pilot-flow-head h2 {
  color: var(--green);
  font-size: 18px;
  line-height: 1.25;
  margin: 2px 0 0;
}

.pilot-flow-steps {
  counter-reset: pilot-step;
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  list-style: none;
  margin: 0;
  padding: 0;
}

.pilot-flow-steps li {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 6px;
  min-width: 0;
  padding: 10px;
}

.pilot-flow-steps li::before {
  background: #e4f2ea;
  border-radius: 999px;
  color: var(--green);
  content: counter(pilot-step);
  counter-increment: pilot-step;
  display: inline-grid;
  font-size: 12px;
  font-weight: 800;
  height: 24px;
  place-items: center;
  width: 24px;
}

.pilot-flow-steps strong {
  color: var(--ink);
  font-size: 13px;
}

.pilot-flow-steps span,
.pilot-flow-command {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  margin: 0;
}

.pilot-flow-command {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pilot-flow-command code {
  background: #eef4f8;
  border: 1px solid #c8dae7;
  border-radius: 8px;
  color: #243c4b;
  font-size: 12px;
  padding: 6px 8px;
  white-space: normal;
  word-break: break-word;
}

#dictationHint1,
#dictationHint2 {
  color: var(--muted);
  font-size: 12px;
}

button.danger {
  background: #fde8ec;
  border-color: #f5c1ce;
}

.daily-checkin-panel,
.agent-panel,
.share-panel,
.tracking-panel {
  background: #f8fbf9;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 12px;
  padding: 14px;
}

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

.agent-reply,
.share-preview {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  line-height: 1.6;
  min-height: 64px;
  padding: 12px;
  white-space: pre-wrap;
}

.share-preview {
  max-height: 180px;
  overflow: auto;
}

.tracking-graph {
  align-items: end;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(7, minmax(28px, 1fr));
  min-height: 150px;
  padding: 14px 10px 8px;
}

.tracking-bar {
  align-items: center;
  display: grid;
  gap: 6px;
  grid-template-rows: 1fr auto;
  height: 120px;
  justify-items: center;
}

.tracking-bar span {
  align-self: end;
  background: linear-gradient(180deg, #2b8d76, #81c784);
  border-radius: 6px 6px 2px 2px;
  display: block;
  min-height: 12px;
  width: min(34px, 80%);
}

.tracking-bar em {
  color: var(--muted);
  font-size: 11px;
  font-style: normal;
}

.vital-trends {
  display: grid;
  gap: 8px;
}

.vital-trend-row {
  align-items: center;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(88px, 0.8fr) minmax(120px, 2fr) minmax(54px, auto);
  padding: 10px;
}

.vital-trend-row strong,
.vital-trend-row em {
  font-size: 12px;
}

.vital-trend-row em {
  color: var(--muted);
  font-style: normal;
  text-align: right;
}

.vital-trend-line {
  align-items: end;
  display: grid;
  gap: 5px;
  grid-template-columns: repeat(7, minmax(10px, 1fr));
  height: 42px;
}

.vital-trend-point {
  align-self: end;
  background: #256f8f;
  border-radius: 999px 999px 4px 4px;
  display: block;
  min-height: 4px;
}

body.access-locked {
  overflow: hidden;
}

body.access-locked .app-shell {
  filter: blur(10px);
  height: 100vh;
  overflow: hidden;
  pointer-events: none;
  user-select: none;
}

.access-gate {
  align-items: center;
  background: radial-gradient(circle at top left, rgba(67, 137, 122, 0.22), transparent 34%),
    rgba(248, 251, 249, 0.94);
  display: none;
  inset: 0;
  justify-content: center;
  padding: 24px;
  position: fixed;
  z-index: 10000;
}

body.access-locked .access-gate {
  display: flex;
}

.access-card {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 24px 72px rgba(28, 64, 55, 0.18);
  display: grid;
  gap: 14px;
  max-width: 420px;
  padding: 28px;
  width: 100%;
}

.access-card h1 {
  color: var(--ink);
  font-size: clamp(26px, 7vw, 40px);
  letter-spacing: 0;
  line-height: 1.05;
  margin: 0;
}

.access-card p {
  color: var(--muted);
  line-height: 1.6;
  margin: 0;
}

.access-card input {
  font-size: 20px;
  letter-spacing: 0.18em;
  text-align: center;
}

.access-error {
  color: #b4233a !important;
  min-height: 20px;
}

.renalloop-diag-tools {
  display: grid;
  gap: 8px;
  margin-left: auto;
  width: min(320px, 100%);
}

.renalloop-diag-tools .renalloop-diag-status {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.renalloop-diag-output {
  border-radius: 8px;
  border: 1px solid var(--line);
  min-height: 88px;
  padding: 8px;
  width: 100%;
}

@media (max-width: 900px) {
  .topbar {
    grid-template-columns: 1fr;
  }

  .pilot-flow-head,
  .pilot-flow-steps,
  .inline-2,
  .checkbox-row,
  .choice-actions,
  .comfort-actions,
  .comfort-cards,
  .step-status-list,
  .voice-row {
    grid-template-columns: 1fr;
  }

  .file-drop {
    align-items: stretch;
    flex-direction: column;
  }

  .summary-card-head {
    grid-template-columns: 1fr;
  }

  .summary-copy {
    justify-self: start;
  }
}
