/* Rosecloth — Android look (Material 3, tonal palette from navy seed #1b2a4a). */

:root {
  color-scheme: light dark;
  --primary: #445e91;
  --on-primary: #fff;
  --primary-container: #d7e2ff;
  --on-primary-container: #001a43;
  --secondary-container: #dae2f9;
  --on-secondary-container: #131c2b;
  --tertiary: #705575;
  --surface: #f9f9ff;
  --surface-low: #f3f3fa;
  --surface-container: #ededf4;
  --surface-high: #e7e8ee;
  --surface-highest: #e2e2e9;
  --on-surface: #1a1b20;
  --on-surface-variant: #44474f;
  --outline: #74777f;
  --outline-variant: #c4c6d0;
  --error: #ba1a1a;
  --warn: #8a5100;
  --state: rgba(26, 27, 32, 0.1);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --ease: cubic-bezier(0.2, 0, 0, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --primary: #adc6ff;
    --on-primary: #102f60;
    --primary-container: #2b4678;
    --on-primary-container: #d7e2ff;
    --secondary-container: #3e4759;
    --on-secondary-container: #dae2f9;
    --surface: #111318;
    --surface-low: #191c20;
    --surface-container: #1d2024;
    --surface-high: #282a2f;
    --surface-highest: #33353a;
    --on-surface: #e2e2e9;
    --on-surface-variant: #c4c6d0;
    --outline: #8e9099;
    --outline-variant: #44474f;
    --error: #ffb4ab;
    --warn: #ffb870;
    --state: rgba(226, 226, 233, 0.12);
  }
}

[x-cloak] { visibility: hidden; }
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; background: var(--surface); }
body {
  margin: 0;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  color: var(--on-surface);
  font: 16px/24px Roboto, "Google Sans Text", system-ui, sans-serif;
  letter-spacing: 0.5px;
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--primary); }
b { font-weight: 500; }
.mono { font-variant-numeric: tabular-nums; font-family: "Roboto Mono", ui-monospace, monospace; font-size: 14px; }

/* top app bar */
.app-bar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: calc(64px + var(--safe-t));
  padding: var(--safe-t) 16px 0 4px;
  background: var(--surface);
  transition: background 0.2s;
}
.app-bar-back {
  position: relative;
  width: 48px;
  height: 48px;
  flex: none;
  border-radius: 50%;
  font-size: 0;
  color: var(--on-surface);
}
span.app-bar-back { width: 12px; }
a.app-bar-back::before {
  content: "";
  position: absolute;
  inset: 12px;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20z'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20z'/%3E%3C/svg%3E") center / contain no-repeat;
}
a.app-bar-back:active { background: var(--state); }
.app-bar-title { flex: 1; font-size: 22px; line-height: 28px; letter-spacing: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-bar-step { color: var(--on-surface-variant); font-size: 14px; font-weight: 500; letter-spacing: 0.1px; font-variant-numeric: tabular-nums; }

/* M3 linear progress */
.steps {
  -webkit-appearance: none;
  appearance: none;
  display: block;
  width: calc(100% - 32px);
  height: 4px;
  margin: 0 16px 8px;
  border: 0;
  border-radius: 2px;
  background: var(--secondary-container);
  overflow: hidden;
}
.steps::-webkit-progress-bar { background: var(--secondary-container); border-radius: 2px; }
.steps::-webkit-progress-value { background: var(--primary); border-radius: 2px; transition: width 0.3s var(--ease); }
.steps::-moz-progress-bar { background: var(--primary); border-radius: 2px; }

/* content */
.content { flex: 1; width: 100%; max-width: 680px; margin: 0 auto; padding: 8px 0 24px; }
.page-title { margin: 8px 16px 8px; font-size: 28px; line-height: 36px; font-weight: 400; letter-spacing: 0; }
.page-sub { margin: 0 16px 24px; color: var(--on-surface-variant); font-size: 14px; line-height: 20px; letter-spacing: 0.25px; }

.group { margin: 0 16px 24px; }
.group-title { margin: 0 4px 8px; font-size: 14px; line-height: 20px; font-weight: 500; letter-spacing: 0.1px; color: var(--primary); }
.group-foot { margin: 6px 4px 0; font-size: 12px; line-height: 16px; letter-spacing: 0.4px; color: var(--on-surface-variant); }
.warn { color: var(--warn) !important; }
.error { color: var(--error) !important; }

.card { background: var(--surface-container); border-radius: 12px; overflow: hidden; }
.card.stack { display: grid; gap: 12px; padding: 16px; }

.row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 56px;
  padding: 8px 16px;
  color: var(--on-surface);
}
.row-label { flex: 1; min-width: 0; }
.row-value { color: var(--on-surface-variant); display: inline-flex; gap: 6px; align-items: center; font-size: 14px; }
.row-unit { color: var(--on-surface-variant); min-width: 1.5em; font-size: 14px; }

/* outlined text field (dense) */
.row-input, .row-select {
  height: 48px;
  border: 1px solid var(--outline);
  border-radius: 4px;
  background: transparent;
  color: var(--on-surface);
  font: inherit;
  letter-spacing: 0.5px;
  padding: 0 12px;
  outline: none;
  transition: border-color 0.15s;
}
.row-input { width: 112px; text-align: right; -moz-appearance: textfield; }
.row-input::-webkit-inner-spin-button, .row-input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.row-input:focus, .row-select:focus { border-color: var(--primary); box-shadow: inset 0 0 0 1px var(--primary); }
.row-select {
  -webkit-appearance: none;
  appearance: none;
  flex: 1;
  min-width: 0;
  padding-right: 40px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M7 10l5 5 5-5z' fill='%2344474f'/%3E%3C/svg%3E") no-repeat right 8px center / 24px;
}
@media (prefers-color-scheme: dark) {
  .row-select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M7 10l5 5 5-5z' fill='%23c4c6d0'/%3E%3C/svg%3E"); }
}
.row-select option, .row-select optgroup { background: var(--surface-high); color: var(--on-surface); }
.row-stack { flex: 1; min-width: 0; display: grid; gap: 4px; }
.row-detail { color: var(--on-surface-variant); font-size: 12px; line-height: 16px; letter-spacing: 0.4px; padding-left: 4px; }
.row-detail:empty { display: none; }
.row-link { color: var(--on-surface); text-decoration: none; }
.row-link:active { background: var(--state); }
.row-buttons { justify-content: flex-start; flex-wrap: wrap; gap: 8px; }
.row-buttons .btn-small { flex: 1; }

.slider { width: 100%; accent-color: var(--primary); height: 24px; }
.color-input {
  -webkit-appearance: none;
  appearance: none;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 12px;
  background: none;
  cursor: pointer;
}
.color-input::-webkit-color-swatch-wrapper { padding: 0; }
.color-input::-webkit-color-swatch { border: 1px solid var(--outline-variant); border-radius: 12px; }
.color-input::-moz-color-swatch { border: 1px solid var(--outline-variant); border-radius: 12px; }
.swatch { display: inline-block; width: 20px; height: 20px; border-radius: 50%; box-shadow: inset 0 0 0 1px var(--outline-variant); }

/* M3 segmented buttons */
.segmented {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  border: 1px solid var(--outline);
  border-radius: 20px;
  overflow: hidden;
}
.segmented button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 12px;
  border: 0;
  border-left: 1px solid var(--outline);
  background: transparent;
  color: var(--on-surface);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  line-height: 20px;
  letter-spacing: 0.1px;
  cursor: pointer;
  transition: background 0.2s var(--ease);
}
.segmented button:first-child { border-left: 0; }
.segmented button:active { background: var(--state); }
.segmented button[aria-checked="true"],
.segmented button[aria-selected="true"] { background: var(--secondary-container); color: var(--on-secondary-container); }
.segmented:not(.segmented-icons):not(.segmented-swatch) button[aria-checked="true"]::before,
.segmented:not(.segmented-icons):not(.segmented-swatch) button[aria-selected="true"]::before {
  content: "";
  width: 18px;
  height: 18px;
  flex: none;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M9 16.17 4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M9 16.17 4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z'/%3E%3C/svg%3E") center / contain no-repeat;
}
.segmented-icons { border-radius: 16px; }
.segmented-icons button { display: grid; justify-items: center; gap: 2px; padding: 8px 4px; font-size: 12px; }
.segmented-icons svg { width: 28px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.segmented-icons button[aria-checked="true"] svg { fill: color-mix(in srgb, currentColor 18%, transparent); }
.segmented-swatch .swatch { width: 18px; height: 18px; }

/* buttons */
.btn {
  -webkit-appearance: none;
  appearance: none;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 24px;
  border: 0;
  border-radius: 20px;
  background: transparent;
  color: var(--primary);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  line-height: 20px;
  letter-spacing: 0.1px;
  cursor: pointer;
  overflow: hidden;
  transition: box-shadow 0.2s var(--ease);
}
.btn::after { content: ""; position: absolute; inset: 0; background: currentColor; opacity: 0; transition: opacity 0.15s; }
.btn:active::after { opacity: 0.12; }
.btn:disabled { background: color-mix(in srgb, var(--on-surface) 12%, transparent); color: color-mix(in srgb, var(--on-surface) 38%, transparent); cursor: default; box-shadow: none; }
.btn-primary { background: var(--primary); color: var(--on-primary); }
.btn-primary:not(:disabled):hover { box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 1px 3px 1px rgba(0, 0, 0, 0.15); }
.btn-tonal { background: var(--secondary-container); color: var(--on-secondary-container); }
.btn-text { padding: 0 12px; }
.btn-small { min-height: 36px; padding: 0 12px; }
.btn-block { width: 100%; min-height: 48px; border-radius: 24px; }
.btn-danger { color: var(--error); }
.btn-record.is-recording { background: var(--error); color: #fff; animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.75; } }
.btn-icon {
  width: 40px;
  height: 40px;
  flex: none;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--on-surface-variant);
  cursor: pointer;
}
.btn-icon:active { background: var(--state); }
.btn-icon svg { width: 20px; height: 20px; stroke: currentColor; stroke-width: 2; stroke-linecap: round; fill: none; }
.button-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }

.toolbar {
  position: sticky;
  bottom: 0;
  z-index: 10;
  padding: 12px 16px calc(12px + var(--safe-b));
  background: var(--surface-container);
}
.toolbar .btn { max-width: 648px; margin: 0 auto; display: flex; }

/* previews */
.preview-card { display: grid; justify-items: center; gap: 8px; padding: 16px; }
.shape-preview { width: 100%; max-width: 320px; height: auto; max-height: 40vh; fill: var(--primary-container); stroke: var(--primary); stroke-width: 2; }
.preview-caption { color: var(--on-surface-variant); font-size: 14px; font-variant-numeric: tabular-nums; }
.rose-preview { padding: 12px; }
.rose-preview svg { display: block; width: 100%; height: auto; max-height: 64vh; }

/* orientation dial */
.dial-group { display: grid; justify-items: center; }
.dial { width: min(72vw, 280px); height: auto; overflow: visible; }
.dial-face { fill: var(--surface-container); stroke: var(--outline-variant); stroke-width: 1; }
.dial-ticks { fill: none; stroke: var(--outline-variant); stroke-width: 6; }
.dial-ticks.major { stroke: var(--outline); stroke-width: 12; }
.dial-n, .dial-l { font: 500 15px Roboto, system-ui, sans-serif; text-anchor: middle; }
.dial-n { fill: var(--error); font-size: 18px; }
.dial-l { fill: var(--on-surface-variant); }
.dial-table { transition: transform 0.3s var(--ease); }
.dial-table rect { fill: var(--primary-container); stroke: var(--primary); stroke-width: 2; }
.dial-arrow { fill: none; stroke: var(--primary); stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; }
.dial-readout { margin: 8px 0 0; font-size: 36px; line-height: 44px; font-variant-numeric: tabular-nums; }
.dial-readout small { font-size: 16px; font-weight: 500; color: var(--on-surface-variant); margin-left: 4px; }

.how-to { padding: 16px; }
.how-to-art { width: 100%; height: auto; font: 13px Roboto, system-ui, sans-serif; }
.how-table { fill: var(--surface-highest); stroke: var(--outline); stroke-width: 1.5; }
.how-phone { fill: var(--on-surface); }
.how-cam { fill: var(--surface); }
.how-arrow { fill: none; stroke: var(--primary); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.how-to-art text { fill: var(--primary); }
.how-steps { margin: 12px 0 0; padding-left: 22px; display: grid; gap: 8px; font-size: 14px; line-height: 20px; letter-spacing: 0.25px; }

/* camera colour picker */
.camera {
  position: relative;
  aspect-ratio: 4 / 3;
  border-radius: 16px;
  overflow: hidden;
  background: #000;
  touch-action: manipulation;
  cursor: crosshair;
}
.camera video, .camera img { width: 100%; height: 100%; object-fit: cover; display: block; }
.loupe {
  position: absolute;
  width: 48px;
  height: 48px;
  border: 3px solid #fff;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.35);
  pointer-events: none;
}
.camera-hint {
  position: absolute;
  left: 50%;
  bottom: 12px;
  transform: translateX(-50%);
  padding: 6px 16px;
  border-radius: 8px;
  background: #2f3036;
  color: #f0f0f7;
  font-size: 14px;
  letter-spacing: 0.25px;
  pointer-events: none;
}

.env-badge {
  position: fixed;
  top: calc(var(--safe-t) + 70px);
  right: 16px;
  z-index: 20;
  padding: 2px 8px;
  border-radius: 8px;
  background: var(--tertiary);
  color: #fff;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  pointer-events: none;
}

/* M3 search bar + list items */
.search-row { gap: 12px; padding-top: 8px; padding-bottom: 8px; }
.search-row::after {
  content: "";
  position: absolute;
  inset: 8px 12px;
  border-radius: 28px;
  background: var(--surface-highest);
  pointer-events: none;
  z-index: 0;
}
.search-icon { position: relative; z-index: 1; width: 22px; height: 22px; margin-left: 12px; fill: none; stroke: var(--on-surface-variant); stroke-width: 2; stroke-linecap: round; flex: none; }
.search-input {
  position: relative;
  z-index: 1;
  flex: 1;
  min-width: 0;
  height: 40px;
  border: 0;
  background: transparent;
  color: var(--on-surface);
  font: inherit;
  letter-spacing: 0.5px;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}
.search-input::placeholder { color: var(--on-surface-variant); }
.spinner {
  position: relative;
  z-index: 1;
  width: 20px;
  height: 20px;
  margin-right: 12px;
  border: 3px solid var(--secondary-container);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
  flex: none;
}
@keyframes spin { to { transform: rotate(360deg); } }
.row-result {
  width: 100%;
  border: 0;
  background: none;
  font: inherit;
  letter-spacing: inherit;
  text-align: left;
  color: var(--on-surface);
  cursor: pointer;
}
.row-result:active { background: var(--state); }
.row-add { color: var(--primary); font-size: 24px; line-height: 1; padding: 0 8px; }
.row-caption { min-height: 32px; padding-top: 8px; padding-bottom: 0; color: var(--primary); }
.row-caption small { font-size: 14px; font-weight: 500; letter-spacing: 0.1px; }
.muted { color: var(--on-surface-variant); }

/* cloth colour picker */
.cloth-picker { display: grid; grid-template-columns: repeat(auto-fit, minmax(58px, 1fr)); gap: 4px; padding: 16px 8px; }
.cloth-option {
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 4px 0;
  border: 0;
  background: none;
  color: var(--on-surface-variant);
  font: inherit;
  font-size: 12px;
  letter-spacing: 0.4px;
  cursor: pointer;
}
.cloth-swatch {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  box-shadow: inset 0 0 0 1px var(--outline-variant);
  outline: 3px solid transparent;
  outline-offset: 2px;
  transition: outline-color 0.15s, border-radius 0.2s var(--ease);
}
.cloth-option[aria-checked="true"] { color: var(--on-surface); font-weight: 500; }
.cloth-option[aria-checked="true"] .cloth-swatch { outline-color: var(--primary); border-radius: 50%; }

.shape-preview .table-top { fill: none; stroke-dasharray: 4 3; stroke-width: 1; opacity: 0.7; }
