:root {
  --ink: #14181c;
  --paper: #e7ebe8;
  --mist: #c5cec9;
  --copper: #b86a2e;
  --copper-soft: #d4894a;
  --muted: #5a6560;
  --line: rgba(20, 24, 28, 0.12);
  --user-bg: #1f2a24;
  --agent-bg: rgba(255, 255, 255, 0.55);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  min-height: 100vh;
  font-family: "Source Serif 4", Georgia, serif;
  color: var(--ink);
  background:
    radial-gradient(1200px 700px at 12% -10%, rgba(184, 106, 46, 0.18), transparent 55%),
    radial-gradient(900px 600px at 100% 0%, rgba(90, 101, 96, 0.2), transparent 50%),
    linear-gradient(160deg, #f3f5f2 0%, var(--paper) 45%, #dfe6e1 100%);
  line-height: 1.55;
}

.shell {
  width: min(1080px, calc(100% - 2.5rem));
  margin: 0 auto;
  padding: 1.75rem 0 3.5rem;
}

.chat-shell {
  width: min(820px, calc(100% - 1.5rem));
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding-bottom: 1.5rem;
}

.top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--line);
}

.top-end {
  justify-content: flex-end;
}

.brand {
  font-family: "Bricolage Grotesque", system-ui, sans-serif;
  font-weight: 800;
  font-size: clamp(1rem, 2.2vw, 1.25rem);
  letter-spacing: -0.02em;
}

.top a, .linkish {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.95rem;
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
}

.top a:hover, .linkish:hover { color: var(--ink); }

.top-right {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.user-pill {
  font-family: "Bricolage Grotesque", system-ui, sans-serif;
  font-size: 0.85rem;
  font-weight: 700;
  padding: 0.25rem 0.7rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.45);
  border: 1px solid var(--line);
}

.hero {
  display: grid;
  gap: 1.25rem;
  padding: clamp(3.5rem, 12vh, 7rem) 0 3rem;
}

.kicker {
  font-family: "Bricolage Grotesque", system-ui, sans-serif;
  font-weight: 500;
  font-size: 0.85rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--copper);
}

h1 {
  font-family: "Bricolage Grotesque", system-ui, sans-serif;
  font-weight: 800;
  font-size: clamp(2.2rem, 7vw, 3.8rem);
  line-height: 0.98;
  letter-spacing: -0.03em;
  max-width: 14ch;
}

.lede {
  max-width: 42ch;
  font-size: 1.1rem;
  color: var(--muted);
}

.actions { display: flex; flex-wrap: wrap; gap: 0.75rem; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.85rem 1.35rem;
  border-radius: 999px;
  text-decoration: none;
  font-family: "Bricolage Grotesque", system-ui, sans-serif;
  font-weight: 700;
  font-size: 0.95rem;
  border: none;
  cursor: pointer;
  transition: transform 0.2s, background 0.2s;
}

.btn:hover { transform: translateY(-2px); }
.btn:disabled { opacity: 0.55; cursor: wait; transform: none; }

.btn.btn-review-sent:disabled {
  cursor: not-allowed;
  pointer-events: auto;
}

.btn-primary {
  background: var(--ink);
  color: var(--paper);
}

.error-box {
  margin: 1rem 0;
  padding: 0.9rem 1rem;
  border-radius: 12px;
  background: #fde8e4;
  border: 1px solid #e8a090;
  color: #6b2b1f;
}

footer {
  margin-top: 3rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.9rem;
}

.messages {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  padding: 1.25rem 0;
  overflow-y: auto;
  max-height: calc(100vh - 320px);
}

.bubble {
  max-width: 85%;
  padding: 0.85rem 1rem;
  border-radius: 16px;
  border: 1px solid var(--line);
  white-space: pre-wrap;
  word-break: break-word;
}

.bubble.user {
  align-self: flex-end;
  background: var(--user-bg);
  color: #f2f5f3;
}

.bubble.assistant {
  align-self: flex-start;
  background: var(--agent-bg);
}

.bubble-meta {
  font-family: "Bricolage Grotesque", system-ui, sans-serif;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.7;
  margin-bottom: 0.35rem;
}

.img-tag {
  margin-left: 0.4rem;
  color: var(--copper-soft);
}

.composer {
  display: grid;
  gap: 0.75rem;
  margin-top: auto;
  padding-top: 0.75rem;
  border-top: 1px solid var(--line);
}

.dropzone {
  position: relative;
  display: block;
  padding: 1.1rem 1.15rem;
  border: 1px dashed var(--mist);
  border-radius: 12px;
  color: var(--muted);
  font-size: 0.95rem;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.35);
  text-align: center;
}

.dropzone input[type="file"] {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.dropzone.dragover {
  border-color: var(--copper);
  background: rgba(184, 106, 46, 0.08);
}

textarea {
  width: 100%;
  resize: vertical;
  min-height: 4.5rem;
  padding: 0.85rem 1rem;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.65);
  font: inherit;
  color: var(--ink);
}

.composer-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.status { color: var(--muted); font-size: 0.9rem; }

.preview {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.preview img {
  max-height: 96px;
  border-radius: 10px;
  border: 1px solid var(--line);
}

.preview.hidden { display: none; }

.clear-img {
  font-size: 0.85rem;
  color: var(--copper);
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
}

.hero-simple {
  min-height: 70vh;
  place-content: center;
  justify-items: center;
  text-align: center;
}

.lede-center {
  max-width: 28ch;
  font-size: clamp(1.35rem, 3.5vw, 1.85rem);
  color: var(--ink);
  font-weight: 600;
}

.actions-center { justify-content: center; }

.page-title {
  font-family: "Bricolage Grotesque", system-ui, sans-serif;
  font-weight: 800;
  font-size: clamp(1.35rem, 3.2vw, 2.2rem);
  letter-spacing: -0.02em;
  margin: 1.5rem 0 0.5rem;
  white-space: nowrap;
}

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

.estimate-form {
  display: grid;
  gap: 1rem;
  margin-top: 1.5rem;
}

.field {
  display: grid;
  gap: 0.35rem;
  font-size: 0.95rem;
}

.field-label {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-family: "Bricolage Grotesque", system-ui, sans-serif;
  font-weight: 600;
  font-size: 0.85rem;
}

.field-label label {
  font: inherit;
  color: inherit;
}

.hint {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.2rem;
  height: 1.2rem;
  padding: 0;
  margin: 0;
  border: none;
  background: transparent;
  cursor: help;
  flex-shrink: 0;
}

.hint-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.2rem;
  height: 1.2rem;
  border-radius: 999px;
  border: 1px solid rgba(20, 24, 28, 0.28);
  background: rgba(255, 255, 255, 0.75);
  color: var(--muted);
  font-family: "Bricolage Grotesque", system-ui, sans-serif;
  font-size: 0.75rem;
  font-weight: 800;
  line-height: 1;
}

.hint-popup {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 0.55rem);
  transform: translateX(-50%);
  width: min(17rem, 72vw);
  padding: 0.7rem 0.8rem;
  border-radius: 10px;
  background: var(--ink);
  color: #f2f5f3;
  font-family: "Source Serif 4", Georgia, serif;
  font-size: 0.82rem;
  font-weight: 400;
  line-height: 1.4;
  text-align: left;
  box-shadow: 0 8px 24px rgba(20, 24, 28, 0.18);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.15s ease, visibility 0.15s;
  z-index: 30;
  white-space: normal;
}

.hint-popup::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  margin-left: -6px;
  border: 6px solid transparent;
  border-top-color: var(--ink);
}

.hint:hover .hint-popup,
.hint:focus .hint-popup,
.hint:focus-visible .hint-popup {
  opacity: 1;
  visibility: visible;
}

.field input[type="number"],
.field input[type="text"],
.field textarea {
  width: 100%;
  padding: 0.75rem 0.9rem;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.65);
  font: inherit;
}

.dropzone.active {
  border-color: var(--copper);
  background: rgba(184, 106, 46, 0.08);
}

.previews {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.preview-item {
  position: relative;
  width: 96px;
  height: 96px;
}

.preview-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid var(--line);
  cursor: zoom-in;
}

.preview-pdf {
  width: 100%;
  height: 100%;
  display: grid;
  place-content: center;
  gap: 0.25rem;
  padding: 0.35rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(20, 24, 28, 0.06);
  cursor: zoom-in;
  font-family: "Bricolage Grotesque", system-ui, sans-serif;
  color: var(--ink);
}

.preview-pdf-label {
  font-weight: 800;
  font-size: 0.85rem;
  letter-spacing: 0.04em;
}

.preview-pdf-name {
  font-size: 0.62rem;
  line-height: 1.2;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
}

.preview-rm {
  position: absolute;
  top: -0.35rem;
  right: -0.35rem;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 999px;
  border: none;
  background: var(--ink);
  color: #fff;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  z-index: 2;
}

.preview-rm:disabled,
.previews-locked .preview-rm {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

body.lightbox-open {
  overflow: hidden;
}

.preview-lightbox {
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: grid;
  place-items: center;
  padding: 1.25rem;
  background: rgba(20, 24, 28, 0.88);
  cursor: zoom-out;
}

.preview-lightbox-hint {
  position: absolute;
  top: 1.1rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2;
  margin: 0;
  padding: 0.55rem 0.95rem;
  border-radius: 999px;
  background: rgba(20, 24, 28, 0.92);
  color: #f4f1ea;
  font-family: "Bricolage Grotesque", system-ui, sans-serif;
  font-size: 0.88rem;
  font-weight: 600;
  line-height: 1.3;
  text-align: center;
  pointer-events: none;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
  opacity: 1;
  transition: opacity 0.28s ease;
}

.preview-lightbox-hint.is-hiding {
  opacity: 0;
}

.preview-lightbox-hint[hidden] {
  display: none !important;
}

.preview-lightbox[hidden] {
  display: none !important;
}

.preview-lightbox img {
  max-width: min(96vw, 1400px);
  max-height: 92vh;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
  background: #fff;
}

.preview-lightbox iframe {
  width: min(96vw, 1100px);
  height: min(92vh, 900px);
  border: none;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
}

.status {
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.5);
  border: 1px solid var(--line);
}

.status.error {
  background: #fde8e4;
  border-color: #e8a090;
  color: #6b2b1f;
}

.result {
  margin-top: 2rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--line);
  display: grid;
  gap: 1rem;
}

.clarify-box {
  margin-top: 0;
  margin-bottom: 0.25rem;
  padding: 1rem 1.1rem;
  border-radius: 14px;
  border: 1px solid rgba(184, 106, 46, 0.35);
  background: rgba(255, 248, 240, 0.9);
  display: grid;
  gap: 0.85rem;
}

.clarify-box h2 {
  font-family: "Bricolage Grotesque", system-ui, sans-serif;
  font-size: 1.05rem;
  font-weight: 800;
}

.card-note {
  margin: 0 0 0.75rem;
  padding: 0.65rem 0.75rem;
  border-radius: 10px;
  background: rgba(184, 106, 46, 0.1);
  color: var(--ink);
  font-size: 0.9rem;
  line-height: 1.4;
}

.clarify-box[hidden],
.result[hidden],
.status[hidden],
.result-details[hidden] {
  display: none !important;
}

.result-summary {
  display: grid;
  gap: 0.35rem;
  padding: 1rem;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid var(--line);
  font-family: "Bricolage Grotesque", system-ui, sans-serif;
}

.result-meta {
  color: var(--muted);
  margin-bottom: 0.25rem;
}

.result-cards {
  display: grid;
  gap: 1rem;
}

.info-card {
  padding: 1rem 1.1rem;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--line);
}

.info-card h3 {
  font-family: "Bricolage Grotesque", system-ui, sans-serif;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.85rem;
}

.card-row {
  display: grid;
  grid-template-columns: minmax(10rem, 42%) 1fr;
  gap: 0.75rem;
  padding: 0.55rem 0;
  border-top: 1px solid var(--line);
  align-items: start;
}

.card-label {
  color: var(--muted);
  font-size: 0.92rem;
}

.card-value {
  font-family: "Bricolage Grotesque", system-ui, sans-serif;
  font-weight: 700;
  font-size: 0.98rem;
  word-break: break-word;
}

.result-details {
  margin-top: 0.5rem;
}

.result-details summary {
  cursor: pointer;
  color: var(--muted);
  font-family: "Bricolage Grotesque", system-ui, sans-serif;
  font-weight: 600;
}

.result-details-hint {
  margin: 0.65rem 0 0.5rem;
  line-height: 1.4;
}

.result-md {
  word-break: break-word;
  padding: 1rem;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.4);
  border: 1px solid var(--line);
  line-height: 1.5;
}

.result-md p {
  margin: 0 0 0.75rem;
}

.result-md p:last-child {
  margin-bottom: 0;
}

.result-md ul {
  margin: 0 0 0.75rem;
  padding-left: 1.25rem;
}

.result-md ul:last-child {
  margin-bottom: 0;
}

.result-md li {
  margin: 0.2rem 0;
}

.result-md strong {
  font-weight: 700;
}

.result-md .md-heading {
  margin: 0.85rem 0 0.45rem;
  font-family: "Bricolage Grotesque", system-ui, sans-serif;
  font-weight: 700;
  font-size: 1.02rem;
}

.result-md .md-heading:first-child {
  margin-top: 0;
}

.result-md code {
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 0.9em;
  background: rgba(20, 24, 28, 0.06);
  padding: 0.1em 0.35em;
  border-radius: 4px;
}

.review-box {
  margin-top: 0.75rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--line);
  display: grid;
  gap: 0.85rem;
  justify-items: start;
}

.review-cta {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.review-hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.35;
  text-align: left;
}

.review-status {
  margin: 0;
  text-align: left;
  font-family: "Bricolage Grotesque", system-ui, sans-serif;
  font-weight: 600;
  font-size: 0.95rem;
}

.review-status.ok {
  color: #1f6b3a;
}

.review-status.error {
  color: #6b2b1f;
}

body.modal-open {
  overflow: hidden;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 1.25rem;
}

.modal[hidden] {
  display: none !important;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(20, 24, 28, 0.48);
}

.modal-panel {
  position: relative;
  z-index: 1;
  width: min(100%, 26rem);
  padding: 1.5rem 1.35rem 1.35rem;
  border-radius: 16px;
  background: #f7f8f6;
  border: 1px solid var(--line);
  box-shadow: 0 18px 48px rgba(20, 24, 28, 0.22);
  display: grid;
  gap: 0.9rem;
}

.modal-title {
  font-family: "Bricolage Grotesque", system-ui, sans-serif;
  font-size: 1.15rem;
  font-weight: 800;
  margin: 0;
  padding-right: 1.5rem;
}

.modal-close {
  position: absolute;
  top: 0.7rem;
  right: 0.75rem;
  width: 2rem;
  height: 2rem;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
}

.modal-close:hover {
  color: var(--ink);
  background: rgba(20, 24, 28, 0.06);
}

.modal-fields {
  display: grid;
  gap: 0.75rem;
}

.modal-panel .btn {
  width: 100%;
}

.modal-panel .review-hint {
  text-align: center;
}

.modal-panel .review-status {
  text-align: center;
}

@media (max-width: 640px) {
  .shell, .chat-shell { width: min(100% - 1.25rem, 1080px); }
  .messages { max-height: calc(100vh - 380px); }
  .bubble { max-width: 95%; }
}
