:root {
  --ink: #142820;
  --muted: #64736c;
  --paper: #f5f7f3;
  --white: #fff;
  --line: #dce4de;
  --green: #176a4a;
  --green-dark: #0e5037;
  --green-pale: #e6f2eb;
  --amber: #a65d17;
  --amber-pale: #fff1dc;
  --red: #a33a36;
  --shadow: 0 18px 50px rgba(26, 53, 42, .09);
  --radius: 22px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; color: var(--ink); background: var(--paper); font: 16px/1.5 Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
button, textarea, input { font: inherit; }
button { color: inherit; }
.is-hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

.site-header { max-width: 1180px; height: 76px; margin: auto; padding: 0 24px; display: flex; align-items: center; justify-content: space-between; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); font-size: 19px; font-weight: 780; text-decoration: none; letter-spacing: -.02em; }
.brand-mark, .assistant-avatar { display: grid; place-items: center; color: white; background: var(--green); border-radius: 10px; font-weight: 800; }
.brand-mark { width: 34px; height: 34px; transform: rotate(-3deg); }
.header-note { color: var(--muted); font-size: 13px; }
main { min-height: calc(100vh - 150px); }

.hero { max-width: 860px; margin: 55px auto 76px; padding: 0 24px; text-align: center; }
.eyebrow { color: var(--green); font-size: 12px; font-weight: 800; letter-spacing: .11em; text-transform: uppercase; }
.live-dot { display: inline-block; width: 8px; height: 8px; margin-right: 5px; border-radius: 50%; background: #42a275; box-shadow: 0 0 0 5px rgba(66,162,117,.11); }
.hero h1 { max-width: 700px; margin: 18px auto 20px; font-family: Georgia, "Times New Roman", serif; font-size: clamp(48px, 8vw, 86px); font-weight: 500; line-height: .95; letter-spacing: -.055em; }
.hero-copy { max-width: 600px; margin: 0 auto 36px; color: var(--muted); font-size: 18px; }
.device-card { width: min(100%, 560px); margin: auto; padding: 18px; display: flex; align-items: center; gap: 17px; border: 1px solid var(--line); border-radius: var(--radius); background: white; box-shadow: var(--shadow); text-align: left; cursor: pointer; transition: transform .2s, box-shadow .2s, border-color .2s; }
.device-card:hover { transform: translateY(-3px); border-color: #a8c4b5; box-shadow: 0 22px 55px rgba(26,53,42,.14); }
.device-card:focus-visible, button:focus-visible, textarea:focus-visible, summary:focus-visible { outline: 3px solid rgba(23,106,74,.25); outline-offset: 3px; }
.device-icon { width: 66px; height: 66px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 18px; background: var(--green-pale); }
.device-icon svg { width: 47px; fill: none; stroke: var(--green); stroke-width: 2; stroke-linecap: round; }
.device-copy { display: flex; flex: 1; flex-direction: column; }
.device-copy strong { font-size: 18px; }
.device-copy small { color: var(--green); }
.arrow { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 50%; background: var(--ink); color: white; font-size: 20px; }
.trust-row { margin-top: 28px; display: flex; justify-content: center; gap: 28px; color: var(--muted); font-size: 13px; }
.trust-row span::before { content: "✓"; margin-right: 7px; color: var(--green); font-weight: 800; }

.diagnostic-shell { max-width: 1180px; margin: 24px auto 80px; padding: 0 24px; }
.diagnostic-topbar { display: flex; align-items: end; justify-content: space-between; margin-bottom: 22px; }
.diagnostic-topbar h1 { margin: 3px 0 0; font: 500 42px/1.05 Georgia, serif; letter-spacing: -.035em; }
.text-button { padding: 7px 0; border: 0; border-bottom: 1px solid currentColor; color: var(--muted); background: transparent; cursor: pointer; }
.progress-card { padding: 17px 20px; margin-bottom: 24px; border: 1px solid var(--line); border-radius: 16px; background: rgba(255,255,255,.7); }
.progress-copy { display: flex; justify-content: space-between; margin-bottom: 10px; font-size: 13px; }
.progress-copy strong { color: var(--green); }
.progress-track { height: 5px; overflow: hidden; border-radius: 5px; background: #dfe7e1; }
.progress-track span { display: block; height: 100%; width: 10%; border-radius: inherit; background: var(--green); transition: width .5s; }
.step-dots { display: none; }
.diagnostic-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; align-items: start; gap: 24px; }
.conversation-column > * + * { margin-top: 16px; }
.welcome-card, .current-check, .conclusion-card, .composer, .feedback-card, .state-panel { border: 1px solid var(--line); background: var(--white); box-shadow: 0 8px 28px rgba(26,53,42,.05); }
.welcome-card { display: flex; gap: 15px; padding: 22px; border-radius: 18px; }
.welcome-card p { margin: 3px 0 0; color: var(--muted); }
.assistant-avatar { width: 34px; height: 34px; flex: 0 0 auto; border-radius: 50%; }
.conversation { padding: 0; margin: 0; list-style: none; }
.message { display: flex; gap: 11px; margin: 16px 0; }
.message.user { justify-content: flex-end; }
.message-bubble { max-width: 78%; padding: 13px 16px; border-radius: 16px 16px 16px 4px; background: white; border: 1px solid var(--line); white-space: pre-wrap; }
.message.user .message-bubble { border-color: var(--green); border-radius: 16px 16px 4px 16px; color: white; background: var(--green); }
.message-label { display: block; margin-bottom: 3px; color: var(--muted); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; }
.message.user .message-label { color: rgba(255,255,255,.7); }
.message-images { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 9px; }
.message-images img { width: 82px; height: 62px; object-fit: cover; border-radius: 8px; }

.current-check { padding: 24px; border-width: 2px; border-color: #a9cdbb; border-radius: var(--radius); position: relative; overflow: hidden; }
.current-check::after { content: "?"; position: absolute; top: -35px; right: 12px; color: var(--green-pale); font: 130px/1 Georgia, serif; pointer-events: none; }
.check-label { position: relative; z-index: 1; display: flex; justify-content: space-between; align-items: center; color: var(--green); font-size: 12px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.safe-badge { padding: 5px 9px; border-radius: 20px; background: var(--green-pale); letter-spacing: 0; text-transform: none; }
.safe-badge.caution { color: var(--amber); background: var(--amber-pale); }
.safe-badge.technician { color: var(--red); background: #fbe8e7; }
.current-check h2 { position: relative; z-index: 1; margin: 15px 0 5px; font-size: 21px; }
.current-check > p { position: relative; z-index: 1; margin: 0; color: #42564d; font-size: 17px; }
.check-caution { margin-top: 12px !important; padding: 10px 12px; border-radius: 10px; color: var(--amber) !important; background: var(--amber-pale); font-size: 14px !important; }

.composer { padding: 12px; border-radius: 18px; }
.composer textarea { width: 100%; min-height: 72px; max-height: 180px; padding: 8px 10px; resize: vertical; border: 0; outline: 0; background: transparent; color: var(--ink); }
.composer textarea::placeholder { color: #89978f; }
.composer-actions { display: flex; align-items: center; gap: 11px; border-top: 1px solid #edf0ed; padding: 10px 4px 0; }
.attach-button { display: inline-flex; align-items: center; gap: 7px; color: var(--green); font-size: 14px; font-weight: 700; cursor: pointer; }
.attach-button svg { width: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.photo-count { margin-right: auto; color: var(--muted); font-size: 12px; }
.send-button { display: inline-flex; align-items: center; gap: 20px; padding: 10px 14px 10px 18px; border: 0; border-radius: 11px; color: white; background: var(--ink); font-weight: 700; cursor: pointer; }
.send-button:disabled { opacity: .55; cursor: wait; }
.image-previews { display: flex; gap: 8px; padding: 0 8px; overflow-x: auto; }
.image-preview { position: relative; flex: 0 0 auto; }
.image-preview img { width: 72px; height: 58px; border-radius: 9px; object-fit: cover; }
.image-preview button { position: absolute; top: -5px; right: -5px; width: 20px; height: 20px; padding: 0; border: 2px solid white; border-radius: 50%; color: white; background: var(--ink); cursor: pointer; line-height: 15px; }
.form-error { margin: 10px 8px 0; color: var(--red); font-size: 13px; }

.state-panel { position: sticky; top: 16px; padding: 21px; border-radius: var(--radius); }
.state-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding-bottom: 15px; border-bottom: 1px solid var(--line); }
.state-head h2 { margin: 0; font-size: 17px; }
.state-status { padding: 4px 8px; border-radius: 12px; color: var(--green); background: var(--green-pale); font-size: 11px; }
.facts-list { margin: 9px 0 0; }
.facts-list div { display: grid; grid-template-columns: 76px 1fr; gap: 10px; padding: 9px 0; }
.facts-list dt { color: var(--muted); font-size: 13px; }
.facts-list dd { margin: 0; font-size: 13px; font-weight: 700; text-align: right; }
.state-group { padding-top: 15px; margin-top: 8px; border-top: 1px solid var(--line); }
.state-group h3, .hypotheses summary { margin: 0 0 8px; font-size: 12px; color: var(--muted); font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.state-group ul, .hypotheses ul { padding-left: 17px; margin: 0; font-size: 13px; }
.state-group li + li, .hypotheses li + li { margin-top: 7px; }
.muted { color: #89978f; }
.checks-count { font: 500 30px Georgia, serif; color: var(--green); }
.hypotheses { padding-top: 15px; margin-top: 15px; border-top: 1px solid var(--line); }
.hypotheses summary { display: flex; justify-content: space-between; cursor: pointer; }
.hypotheses summary span { display: grid; place-items: center; min-width: 22px; height: 22px; margin-top: -3px; border-radius: 12px; background: var(--green-pale); color: var(--green); }
.hypotheses ul { margin-top: 12px; }

.conclusion-card { padding: 26px; border-radius: var(--radius); border-color: #a9cdbb; }
.conclusion-head { display: flex; align-items: center; gap: 14px; }
.result-icon { width: 45px; height: 45px; display: grid; place-items: center; border-radius: 50%; color: white; background: var(--green); font-size: 23px; }
.conclusion-head h2 { margin: 3px 0 0; font: 500 25px Georgia, serif; }
.cause-row { margin: 22px 0; padding: 16px; display: flex; justify-content: space-between; align-items: center; gap: 12px; border-radius: 13px; background: var(--green-pale); }
.cause-row span { padding: 5px 9px; border-radius: 15px; color: white; background: var(--green); font-size: 11px; white-space: nowrap; }
.conclusion-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.conclusion-grid h3, .technician-note strong { font-size: 14px; }
.conclusion-grid ul, .conclusion-card details ul { padding-left: 19px; margin-bottom: 0; color: #4f6259; font-size: 14px; }
.conclusion-grid li + li { margin-top: 7px; }
.technician-note { margin-top: 22px; padding: 15px 17px; border-left: 3px solid var(--amber); background: var(--amber-pale); }
.technician-note p { margin: 4px 0 0; color: #6f5334; font-size: 14px; }
.conclusion-card details { margin-top: 18px; }
.conclusion-card summary { color: var(--muted); cursor: pointer; font-size: 14px; font-weight: 700; }

.feedback-card { padding: 24px; border-radius: var(--radius); text-align: center; }
.feedback-card h2 { margin: 0; font: 500 25px Georgia, serif; }
.feedback-card > p { margin: 4px 0 18px; color: var(--muted); }
.feedback-options { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.feedback-options button { padding: 12px; border: 1px solid var(--line); border-radius: 11px; background: white; cursor: pointer; text-align: left; }
.feedback-options button:hover { border-color: var(--green); background: var(--green-pale); }
.feedback-options button span { margin-right: 7px; color: var(--green); font-weight: 800; }
.feedback-thanks { color: var(--green) !important; font-weight: 700; }

.ad-placeholder { max-width: 760px; min-height: 88px; margin: 45px auto; padding: 18px; display: flex; flex-direction: column; align-items: center; justify-content: center; border: 1px dashed #c9d2cc; border-radius: 14px; color: #8b9790; text-transform: uppercase; letter-spacing: .1em; font-size: 10px; }
.ad-placeholder small { margin-top: 3px; text-transform: none; letter-spacing: 0; }
.privacy-note { max-width: 760px; margin: 0 auto 60px; padding: 0 24px; display: flex; gap: 13px; color: var(--muted); }
.privacy-note > span { font-size: 25px; color: var(--green); }
.privacy-note strong { color: var(--ink); font-size: 14px; }
.privacy-note p { margin: 2px 0 0; font-size: 13px; }
footer { max-width: 1180px; margin: auto; padding: 26px 24px; display: flex; gap: 24px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }
footer a { color: inherit; }
footer span:last-child { margin-left: auto; }
.toast { position: fixed; left: 50%; bottom: 24px; z-index: 20; max-width: calc(100vw - 32px); padding: 11px 18px; border-radius: 9px; color: white; background: var(--ink); opacity: 0; transform: translate(-50%, 20px); pointer-events: none; transition: .25s; }
.toast.visible { opacity: 1; transform: translate(-50%, 0); }

/* Admin */
.admin-main { max-width: 1180px; margin: 34px auto 80px; padding: 0 24px; }
.admin-title { display: flex; justify-content: space-between; align-items: end; margin-bottom: 24px; }
.admin-title h1 { margin: 0; font: 500 44px Georgia, serif; }
.admin-login { max-width: 430px; margin: 90px auto; padding: 28px; border: 1px solid var(--line); border-radius: var(--radius); background: white; box-shadow: var(--shadow); }
.admin-login h1 { margin: 0; font: 500 30px Georgia, serif; }
.admin-login p { color: var(--muted); }
.admin-login input { width: 100%; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; }
.primary-button { margin-top: 12px; padding: 11px 17px; border: 0; border-radius: 10px; color: white; background: var(--green); cursor: pointer; font-weight: 700; }
.analytics-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 13px; margin-bottom: 22px; }
.metric-card { min-height: 120px; padding: 17px; border: 1px solid var(--line); border-radius: 16px; background: white; }
.metric-card span { color: var(--muted); font-size: 12px; }
.metric-card strong { display: block; margin-top: 14px; font: 500 31px Georgia, serif; }
.admin-table-wrap { overflow: hidden; border: 1px solid var(--line); border-radius: 17px; background: white; }
.table-heading { padding: 18px 20px; display: flex; justify-content: space-between; border-bottom: 1px solid var(--line); }
.table-heading h2 { margin: 0; font-size: 17px; }
.table-heading button { border: 0; color: var(--green); background: transparent; cursor: pointer; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 13px 15px; border-bottom: 1px solid #edf0ed; text-align: left; }
th { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .05em; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: #f8faf8; }
.status-pill { padding: 4px 8px; border-radius: 12px; color: var(--green); background: var(--green-pale); font-size: 11px; }
.admin-empty { padding: 35px; text-align: center; color: var(--muted); }
.admin-detail { width: min(860px, calc(100% - 32px)); max-height: calc(100vh - 40px); padding: 0; border: 0; border-radius: 20px; box-shadow: 0 20px 80px rgba(0,0,0,.2); }
.admin-detail::backdrop { background: rgba(12,26,20,.45); }
.detail-head { position: sticky; top: 0; padding: 19px 22px; display: flex; justify-content: space-between; border-bottom: 1px solid var(--line); background: white; }
.detail-head h2 { margin: 0; font-size: 18px; }
.detail-head button { border: 0; background: transparent; cursor: pointer; font-size: 23px; }
.detail-body { padding: 22px; }
.detail-section { margin-bottom: 24px; }
.detail-section h3 { font-size: 13px; color: var(--muted); text-transform: uppercase; }
.json-view { overflow: auto; padding: 15px; border-radius: 12px; color: #d7efe4; background: #142820; font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre-wrap; }
.trace-card { margin-top: 10px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; }
.trace-card summary { cursor: pointer; color: var(--green); font-weight: 700; }
.trace-content { padding-top: 12px; }
.trace-content strong { display: block; margin: 12px 0 5px; font-size: 12px; text-transform: uppercase; color: var(--muted); }

@media (max-width: 850px) {
  .diagnostic-layout { grid-template-columns: 1fr; }
  .state-panel { position: static; grid-row: 1; }
  .analytics-grid { grid-template-columns: repeat(2, 1fr); }
  .admin-table-wrap { overflow-x: auto; }
  table { min-width: 760px; }
}

@media (max-width: 560px) {
  .site-header { height: 64px; padding: 0 17px; }
  .header-note { display: none; }
  .hero { margin-top: 40px; padding: 0 17px; }
  .hero h1 { font-size: 51px; }
  .hero-copy { font-size: 16px; }
  .trust-row { flex-direction: column; gap: 6px; }
  .diagnostic-shell { margin-top: 12px; padding: 0 13px; }
  .diagnostic-topbar h1 { font-size: 34px; }
  .text-button { font-size: 13px; }
  .progress-card { padding: 14px; }
  .message-bubble { max-width: 90%; }
  .state-panel { padding: 17px; }
  .current-check, .conclusion-card, .feedback-card { padding: 19px; }
  .conclusion-grid, .feedback-options { grid-template-columns: 1fr; }
  .cause-row { align-items: flex-start; flex-direction: column; }
  .attach-button span { display: none; }
  .send-button { gap: 9px; }
  footer { flex-wrap: wrap; }
  footer span:last-child { width: 100%; margin-left: 0; }
  .analytics-grid { grid-template-columns: 1fr 1fr; }
  .admin-main { padding: 0 14px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
