:root {
  --ink: #12263a;
  --muted: #526476;
  --line: #d6e0e7;
  --paper: #f5f8fa;
  --card: #ffffff;
  --navy: #12334b;
  --cyan: #61cdd4;
  --yellow: #f9d866;
  --amber: #f5b82e;
  --orange: #ec7e27;
  --red: #cf4c3d;
  --shadow: 0 12px 28px rgba(19, 48, 70, .08);
}

* { box-sizing: border-box; }

body {
  min-width: 320px;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(145deg, rgba(97, 205, 212, .09), transparent 30rem),
    var(--paper);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}

button, input, select { font: inherit; }

.container {
  width: min(1180px, calc(100% - 2rem));
  margin: 0 auto;
}

.simulator { padding: clamp(1.5rem, 4vw, 4rem) 0 3rem; }

.page-header { max-width: 760px; margin-bottom: 1.7rem; }

.eyebrow, .section-kicker {
  margin: 0 0 .3rem;
  color: #2d7b85;
  font-size: .78rem;
  font-weight: 750;
  letter-spacing: .11em;
  text-transform: uppercase;
}

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

h1 {
  max-width: 850px;
  margin-bottom: .65rem;
  color: var(--navy);
  font-size: clamp(1.85rem, 4vw, 3.05rem);
  line-height: 1.13;
  letter-spacing: -.04em;
}

h2 {
  margin-bottom: .25rem;
  color: var(--navy);
  font-size: clamp(1.22rem, 2vw, 1.45rem);
  line-height: 1.25;
}

.lede { margin-bottom: 0; color: var(--muted); font-size: 1.06rem; }

.control-panel {
  display: grid;
  grid-template-columns: minmax(6.2rem, .6fr) minmax(9rem, 1fr) minmax(15rem, 1.6fr) auto;
  gap: .85rem;
  align-items: end;
  padding: 1rem;
  margin-bottom: 1.25rem;
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: var(--card);
  box-shadow: var(--shadow);
}

.field { min-width: 0; }

label { display: block; margin-bottom: .35rem; color: var(--muted); font-size: .86rem; font-weight: 700; }

input[type="number"], select {
  width: 100%;
  min-height: 2.65rem;
  padding: .55rem .7rem;
  border: 1px solid #aebfcc;
  border-radius: .5rem;
  color: var(--ink);
  background-color: #fff;
}

select {
  appearance: none;
  padding-right: 2.2rem;
  background-image: linear-gradient(45deg, transparent 50%, #536775 50%), linear-gradient(135deg, #536775 50%, transparent 50%);
  background-position: calc(100% - 1rem) 1.1rem, calc(100% - .7rem) 1.1rem;
  background-size: .3rem .3rem, .3rem .3rem;
  background-repeat: no-repeat;
}

input:focus-visible, select:focus-visible, button:focus-visible {
  outline: 3px solid rgba(45, 157, 166, .4);
  outline-offset: 2px;
}

.input-with-unit { display: flex; align-items: center; gap: .55rem; }
.input-with-unit input { min-width: 0; }
.input-with-unit span { white-space: nowrap; color: var(--muted); font-size: .85rem; }

.secondary-button {
  min-height: 2.65rem;
  padding: .55rem .85rem;
  border: 1px solid #aebfcc;
  border-radius: .5rem;
  color: var(--navy);
  background: #fff;
  font-size: .9rem;
  font-weight: 700;
  cursor: pointer;
}
.secondary-button:hover { border-color: #5da9b2; background: #effafb; }

.canvas-card, .time-card, .details-card {
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: var(--card);
  box-shadow: var(--shadow);
}

.canvas-card { padding: clamp(1rem, 2.5vw, 1.6rem); }
.card-heading, .time-heading, .section-title { display: flex; align-items: start; justify-content: space-between; gap: 1rem; }
.calculation-date { margin: .25rem 0 0; color: var(--muted); font-size: .9rem; text-align: right; }

.diagram-wrap { width: 100%; margin-top: .4rem; overflow: hidden; }
#solarSvg { display: block; width: 100%; min-width: 530px; height: auto; margin: 0 auto; }

.legend { display: flex; flex-wrap: wrap; gap: .5rem 1rem; justify-content: center; margin-top: .35rem; color: var(--muted); font-size: .8rem; }
.legend span { display: inline-flex; align-items: center; gap: .35rem; }
.legend-swatch { width: 1.05rem; height: .46rem; border-radius: 3px; }
.no-sun { background: #94a3b8; }.low-sun { background: #fde68a; }.medium-sun { background: #facc15; }.high-sun { background: #f97316; }.very-high-sun { background: #dc2626; }
.legend-note { margin: .65rem 0 0; color: var(--muted); font-size: .78rem; text-align: center; }

.time-card { padding: 1.25rem 1.4rem; margin-top: 1.25rem; }
.time-readout { color: #996100; font-size: 1.15rem; font-weight: 800; white-space: nowrap; }
input[type="range"] { width: 100%; margin: .85rem 0 .28rem; accent-color: #e9a616; }
.time-scale { display: flex; justify-content: space-between; color: var(--muted); font-size: .76rem; }
.current-sun-info { margin: .8rem 0 0; color: var(--ink); font-size: .94rem; }

.facades-section { margin-top: 2.1rem; }
.section-title { margin-bottom: 1rem; }
.section-title > p { max-width: 360px; margin: .2rem 0 0; color: var(--muted); font-size: .86rem; text-align: right; }
.facade-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: .8rem; }
.facade-card {
  min-width: 0;
  padding: 1rem;
  border: 1px solid var(--line);
  border-top: .35rem solid var(--edge-color, #94a3b8);
  border-radius: .75rem;
  background: var(--card);
  box-shadow: 0 7px 18px rgba(19, 48, 70, .05);
}
.facade-card.is-active { background: #fffbed; box-shadow: 0 0 0 2px rgba(245, 184, 46, .5), 0 7px 18px rgba(19, 48, 70, .05); }
.facade-side { margin: 0 0 .1rem; color: var(--muted); font-size: .74rem; font-weight: 750; letter-spacing: .07em; text-transform: uppercase; }
.facade-name { margin: 0 0 .7rem; font-size: 1rem; font-weight: 800; }
.facade-time { margin: 0 0 .35rem; color: var(--navy); font-size: 1rem; font-weight: 750; }
.facade-duration { margin: 0; color: var(--muted); font-size: .84rem; }
.facade-empty { color: var(--muted); font-style: italic; }

.details-grid { display: grid; grid-template-columns: minmax(17rem, .9fr) minmax(20rem, 1.3fr); gap: 1.25rem; margin-top: 1.25rem; }
.details-card { padding: 1.35rem; }
.metrics { display: grid; grid-template-columns: 1fr auto; gap: .48rem 1rem; margin: .9rem 0 0; }
.metrics dt { color: var(--muted); font-size: .9rem; }.metrics dd { margin: 0; color: var(--navy); font-size: .92rem; font-weight: 750; text-align: right; }
.method-card p { margin-bottom: .75rem; color: var(--muted); font-size: .92rem; }.method-card p:last-child { margin-bottom: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

@media (max-width: 820px) {
  .control-panel { grid-template-columns: repeat(2, 1fr); }
  .secondary-button { width: 100%; }
  .facade-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 620px) {
  .container { width: min(100% - 1rem, 1180px); }
  .simulator { padding-top: 1rem; }
  .control-panel { grid-template-columns: 1fr; gap: .7rem; }
  .diagram-wrap { overflow-x: auto; }
  .canvas-card { padding: .85rem; }
  .card-heading, .time-heading, .section-title { flex-direction: column; gap: .3rem; }
  .calculation-date, .section-title > p { text-align: left; }
  .details-grid { grid-template-columns: 1fr; gap: .9rem; }
}
@media (max-width: 410px) { .facade-grid { grid-template-columns: 1fr; } }
