:root {
  color-scheme: dark;
  --bg: #11100e;
  --bg-soft: #171512;
  --panel: #1f1c18;
  --panel-2: #28231e;
  --line: rgba(245, 239, 226, 0.12);
  --line-strong: rgba(245, 239, 226, 0.22);
  --text: #f5efe2;
  --muted: #aaa197;
  --soft: #d8cbb6;
  --gold: #c6a15b;
  --green: #76aa8f;
  --red: #c96b5b;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.34);
  --radius: 8px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100%;
  margin: 0;
  background:
    radial-gradient(circle at 18% 0%, rgba(198, 161, 91, 0.08), transparent 28rem),
    linear-gradient(180deg, #11100e 0%, #171512 46%, #100f0e 100%);
  color: var(--text);
}

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

button {
  cursor: pointer;
}

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

.app-shell {
  min-height: 100vh;
}

.login {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(100%, 420px);
  padding: 32px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(31, 28, 24, 0.86);
  box-shadow: var(--shadow);
}

.brand-initials,
.brand-mark {
  display: grid;
  width: 46px;
  height: 46px;
  margin-bottom: 22px;
  place-items: center;
  border: 1px solid rgba(198, 161, 91, 0.44);
  border-radius: 50%;
  background: rgba(198, 161, 91, 0.08);
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.26);
  color: var(--gold);
  font-weight: 800;
  letter-spacing: 0;
}

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

h1 {
  margin-bottom: 8px;
  font-size: 2rem;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 18px;
  font-size: 1.35rem;
  letter-spacing: 0;
}

h3 {
  margin-bottom: 12px;
  font-size: 1rem;
  letter-spacing: 0;
}

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

.tiny {
  font-size: 0.8rem;
}

.stack {
  display: grid;
  gap: 14px;
}

.field {
  display: grid;
  gap: 8px;
}

.field label,
.label {
  color: var(--soft);
  font-size: 0.86rem;
}

.field input,
.field textarea,
.field select,
.measure-input {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #13110f;
  color: var(--text);
  outline: none;
  padding: 11px 13px;
}

.field textarea {
  min-height: 92px;
  resize: vertical;
}

.field input:focus,
.field textarea:focus,
.field select:focus,
.measure-input:focus {
  border-color: rgba(198, 161, 91, 0.65);
  box-shadow: 0 0 0 3px rgba(198, 161, 91, 0.12);
}

.button,
.ghost-button,
.danger-button,
.subtle-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 10px 14px;
  text-decoration: none;
  transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.button {
  background: var(--gold);
  color: #15120d;
  font-weight: 760;
}

.ghost-button {
  border-color: var(--line);
  background: rgba(245, 239, 226, 0.04);
  color: var(--text);
}

.subtle-button {
  border-color: transparent;
  background: transparent;
  color: var(--soft);
}

.danger-button {
  border-color: rgba(201, 107, 91, 0.42);
  background: rgba(201, 107, 91, 0.11);
  color: #ffb6aa;
}

.button:hover,
.ghost-button:hover,
.danger-button:hover,
.subtle-button:hover {
  transform: translateY(-1px);
}

.error {
  min-height: 22px;
  color: #ffb6aa;
}

.layout {
  display: grid;
  min-height: 100vh;
  grid-template-columns: 248px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  height: 100vh;
  flex-direction: column;
  justify-content: space-between;
  border-right: 1px solid var(--line);
  background: rgba(17, 16, 14, 0.82);
  padding: 24px 18px;
  backdrop-filter: blur(18px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
}

.brand strong {
  display: block;
  font-size: 1.02rem;
}

.brand span {
  color: var(--muted);
  font-size: 0.78rem;
}

.brand .brand-initials,
.brand .brand-mark {
  flex: 0 0 auto;
  margin-bottom: 0;
}

.nav {
  display: grid;
  gap: 8px;
}

.nav a {
  display: flex;
  min-height: 44px;
  align-items: center;
  border: 1px solid transparent;
  border-radius: var(--radius);
  color: var(--soft);
  padding: 0 12px;
  text-decoration: none;
}

.nav a.active,
.nav a:hover {
  border-color: var(--line);
  background: rgba(245, 239, 226, 0.05);
  color: var(--text);
}

.content {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 32px 34px 72px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 28px;
}

.topbar h1 {
  margin-bottom: 6px;
}

.section {
  margin-top: 28px;
}

.grid {
  display: grid;
  gap: 16px;
}

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

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

.panel,
.metric,
.session-card,
.photo-slot,
.measure-card,
.detail-band {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(31, 28, 24, 0.74);
}

.panel {
  padding: 20px;
}

.metric {
  min-height: 126px;
  padding: 18px;
}

.metric .value {
  margin: 8px 0 0;
  font-size: 2rem;
  font-weight: 780;
  letter-spacing: 0;
}

.metric .delta,
.delta {
  color: var(--green);
  font-weight: 700;
}

.delta.bad {
  color: var(--red);
}

.summary-list {
  display: grid;
  gap: 10px;
}

.summary-row {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 1px solid var(--line);
  padding: 10px 0;
}

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

.notice {
  border: 1px solid rgba(198, 161, 91, 0.34);
  border-radius: var(--radius-sm);
  background: rgba(198, 161, 91, 0.1);
  color: var(--text);
  padding: 12px 14px;
  line-height: 1.45;
}

.readiness {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(245, 239, 226, 0.04);
  padding: 14px;
}

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

.readiness li {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
}

.readiness li span {
  width: 10px;
  height: 10px;
  flex: 0 0 auto;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: transparent;
}

.readiness li.ready {
  color: var(--text);
}

.readiness li.ready span {
  border-color: var(--green);
  background: var(--green);
}

.readiness p {
  margin: 12px 0 0;
}

.topbar.compact {
  margin-bottom: 16px;
}

.comparison-table {
  display: grid;
}

.comparison-row {
  display: grid;
  grid-template-columns: minmax(120px, 1.2fr) repeat(3, minmax(88px, 1fr));
  gap: 12px;
  align-items: center;
  border-bottom: 1px solid var(--line);
  padding: 12px 0;
}

.comparison-row:last-child {
  border-bottom: 0;
}

.comparison-head {
  color: var(--soft);
  font-size: 0.8rem;
  font-weight: 760;
  text-transform: uppercase;
}

.chart {
  display: block;
  width: 100%;
  height: 210px;
}

.chart text {
  fill: var(--muted);
  font-size: 11px;
}

.empty-state {
  display: grid;
  min-height: 280px;
  place-items: center;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  padding: 28px;
  text-align: center;
}

.form-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 18px;
  align-items: start;
}

.measure-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.measure-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 98px;
  gap: 12px;
  align-items: center;
  padding: 14px;
}

.measure-card span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
}

.measure-input {
  min-height: 40px;
  text-align: right;
}

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

.photo-slot {
  overflow: hidden;
}

.photo-preview {
  display: grid;
  min-height: 218px;
  place-items: center;
  background: #13110f;
}

.photo-preview img {
  display: block;
  width: 100%;
  height: 260px;
  object-fit: cover;
}

.photo-empty {
  display: grid;
  width: 100%;
  min-height: 260px;
  place-items: center;
  color: var(--muted);
  text-align: center;
}

.photo-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(92px, 1fr));
  gap: 8px;
  padding: 10px;
}

.session-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 178px;
  gap: 18px;
  padding: 16px;
}

.thumbs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.thumb {
  width: 100%;
  aspect-ratio: 3 / 4;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #13110f;
  object-fit: cover;
}

.view-photo {
  cursor: zoom-in;
}

.pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--soft);
  padding: 6px 10px;
  font-size: 0.82rem;
}

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

.detail-photos img {
  width: 100%;
  aspect-ratio: 3 / 4;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  object-fit: cover;
}

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

.comparison-stack {
  display: grid;
  gap: 18px;
}

.comparison-set {
  display: grid;
  gap: 10px;
}

.comparison-label {
  color: var(--soft);
  font-weight: 760;
}

.comparison-frame {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.comparison-frame img,
.comparison-frame .photo-empty {
  width: 100%;
  aspect-ratio: 3 / 4;
  min-height: 0;
  object-fit: cover;
}

.comparison-frame div:last-child {
  padding: 10px 12px;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.78);
  padding: 18px;
}

.camera-panel {
  width: min(100%, 720px);
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: #0f0e0d;
  box-shadow: var(--shadow);
}

.camera-view {
  position: relative;
  background: #050505;
}

.camera-view video,
.camera-view img {
  display: block;
  width: 100%;
  max-height: 72vh;
  object-fit: contain;
}

.countdown {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.32);
  color: var(--text);
  font-size: 7rem;
  font-weight: 800;
}

.camera-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px;
}

.photo-modal {
  padding: 12px;
}

.photo-viewer {
  display: grid;
  width: min(100%, 980px);
  max-height: calc(100vh - 24px);
  grid-template-rows: auto minmax(0, 1fr) auto;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: #0f0e0d;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.photo-viewer-top,
.photo-viewer-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
}

.photo-viewer img {
  display: block;
  width: 100%;
  max-height: 78vh;
  object-fit: contain;
  background: #050505;
}

.camera-controls .field {
  width: 148px;
}

.hidden {
  display: none !important;
}

@media (max-width: 860px) {
  .layout {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .sidebar {
    position: sticky;
    z-index: 10;
    height: auto;
    align-self: start;
    justify-content: flex-start;
    gap: 12px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 12px;
  }

  .sidebar .subtle-button {
    width: auto;
    min-height: 36px;
    align-self: start;
    padding: 7px 10px;
  }

  .brand {
    margin-bottom: 12px;
  }

  .nav {
    grid-template-columns: repeat(4, minmax(68px, 1fr));
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .nav a {
    justify-content: center;
    min-height: 40px;
    padding: 0 8px;
    text-align: center;
    font-size: 0.82rem;
  }

  .content {
    padding: 22px 16px 88px;
  }

  .topbar {
    display: grid;
    gap: 12px;
    margin-bottom: 18px;
  }

  .empty-state {
    min-height: 220px;
    padding: 22px 16px;
  }

  .grid-2,
  .grid-3,
  .form-grid,
  .measure-grid,
  .photo-grid,
  .detail-photos,
  .comparison-photos {
    grid-template-columns: 1fr;
  }

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

  .panel {
    padding: 16px;
  }

  .photo-preview,
  .photo-empty {
    min-height: 230px;
  }

  .photo-preview img {
    height: 230px;
  }

  .camera-view video,
  .camera-view img {
    max-height: 64vh;
  }

  .metric .value {
    font-size: 1.75rem;
  }
}

@media (max-width: 480px) {
  .login-panel {
    padding: 24px 18px;
  }

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

  .measure-input {
    text-align: left;
  }

  .photo-actions {
    grid-template-columns: 1fr;
  }

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

  .comparison-head {
    display: none;
  }

  .content {
    padding-left: 12px;
    padding-right: 12px;
  }

  .sidebar .subtle-button {
    width: auto;
  }

  .login {
    padding: 16px;
  }

  .button,
  .ghost-button,
  .danger-button,
  .subtle-button {
    width: 100%;
    justify-content: center;
  }

  .pill-row .button,
  .pill-row .ghost-button,
  .pill-row .danger-button,
  .pill-row .subtle-button,
  .camera-controls .button,
  .camera-controls .ghost-button {
    width: auto;
  }

  .photo-viewer-top,
  .photo-viewer-controls,
  .camera-controls {
    display: grid;
  }

  .camera-controls .field {
    width: 100%;
  }
}
