:root {
  color-scheme: light;
  --bg: #f6f8fc;
  --surface: #ffffff;
  --surface-raised: #eef3ff;
  --segment: #edf1f8;
  --selected: #314da3;
  --text: #121826;
  --muted: #667085;
  --rule: #d8e0f0;
  --accent: #314da3;
  --accent-strong: #243b86;
  --accent-soft: #e7edff;
  --warning: #b45309;
  --success: #16835f;
  --shadow: 0 18px 46px rgba(49, 77, 163, 0.12);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Segoe UI", sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

button {
  color: inherit;
}

.phone-app {
  width: min(100%, 980px);
  min-height: 100vh;
  margin: 0 auto;
  background: var(--bg);
}

.brand-strip {
  padding: 22px clamp(18px, 5vw, 46px) 6px;
}

.brand-strip img {
  display: block;
  width: min(100%, 520px);
  height: auto;
}

.screen {
  display: none;
  min-height: 100vh;
  padding: max(20px, env(safe-area-inset-top)) 0 max(26px, env(safe-area-inset-bottom));
}

.screen.is-active {
  display: block;
}

.app-header,
.detail-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: minmax(112px, 1fr) auto minmax(56px, 1fr);
  align-items: center;
  gap: 12px;
  min-height: 72px;
  padding: 16px clamp(18px, 5vw, 46px) 12px;
  background: rgba(246, 248, 252, 0.92);
  backdrop-filter: blur(18px);
}

.detail-header {
  grid-template-columns: minmax(118px, 1fr) minmax(0, auto) minmax(46px, 1fr);
  border-bottom: 1px solid var(--rule);
}

h1,
h2,
p {
  margin: 0;
}

h1,
.detail-header h2 {
  min-width: 0;
  color: var(--text);
  font-size: clamp(1.42rem, 4.3vw, 2rem);
  font-weight: 750;
  line-height: 1.12;
  text-align: center;
}

.detail-header h2 {
  max-width: min(58vw, 520px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.header-spacer {
  min-width: 44px;
}

.circle-button {
  justify-self: end;
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: #ffffff;
  font-size: 1.55rem;
  font-weight: 900;
  cursor: pointer;
}

.score-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(150px, 320px);
  align-items: center;
  gap: 20px;
  padding: 18px clamp(18px, 5vw, 46px) 12px;
}

.total-check {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  color: var(--text);
  font-size: clamp(1.8rem, 6vw, 2.8rem);
  line-height: 1;
}

.total-check strong {
  font-weight: 500;
}

.clear-button {
  min-height: 62px;
  border: 0;
  border-radius: 12px;
  background: var(--accent);
  color: white;
  font-size: clamp(1.65rem, 5vw, 2.55rem);
  font-weight: 800;
  cursor: pointer;
}

.completion-text {
  padding: 0 clamp(18px, 5vw, 46px) 12px;
  color: var(--muted);
  font-size: 1rem;
}

.item-list {
  padding: 0 clamp(18px, 5vw, 46px);
}

.scale-item {
  padding: 18px 0 22px;
  border-top: 1px solid var(--rule);
}

.scale-item:first-child {
  border-top: 0;
}

.item-top {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 44px;
  gap: 12px;
  align-items: start;
}

.item-title {
  min-width: 0;
  color: var(--text);
  font-size: clamp(1.45rem, 5vw, 2.35rem);
  font-weight: 650;
  line-height: 1.13;
}

.item-status {
  margin-top: 6px;
  color: var(--accent);
  font-size: clamp(1.15rem, 4vw, 1.55rem);
  line-height: 1.15;
}

.info-button {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 2px solid var(--accent);
  border-radius: 999px;
  background: transparent;
  color: var(--accent);
  font-size: 1.35rem;
  font-weight: 900;
  cursor: pointer;
}

.segmented {
  display: inline-grid;
  grid-auto-columns: minmax(74px, 1fr);
  grid-auto-flow: column;
  max-width: 100%;
  margin-top: 14px;
  overflow: hidden;
  border: 1px solid var(--rule);
  border-radius: 12px;
  background: var(--segment);
}

.segmented button {
  min-width: 0;
  min-height: 62px;
  padding: 0 18px;
  border: 0;
  border-left: 1px solid var(--rule);
  background: transparent;
  color: var(--text);
  font-size: clamp(1.35rem, 4vw, 1.85rem);
  cursor: pointer;
}

.segmented button:first-child {
  border-left: 0;
}

.segmented button.is-selected {
  background: var(--selected);
  color: #ffffff;
  font-weight: 800;
}

.time-panel,
.result-card,
.install-panel {
  margin: 22px clamp(18px, 5vw, 46px) 40px;
  padding: 16px;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.time-panel h2,
.result-card h2,
.install-panel h2 {
  margin-top: 2px;
  font-size: clamp(1.1rem, 4vw, 1.45rem);
  text-align: left;
}

.time-panel label {
  display: block;
  margin: 14px 0 6px;
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 750;
}

.time-panel input,
.time-panel textarea,
#resultText {
  width: 100%;
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcff;
  color: var(--text);
}

.time-panel textarea,
#resultText {
  resize: vertical;
}

.time-panel input:focus,
.time-panel textarea:focus,
#resultText:focus {
  border-color: var(--accent);
  outline: 3px solid var(--accent-soft);
}

.result-card.is-hidden {
  display: none;
}

.result-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.section-label {
  color: var(--accent);
  font-size: 0.74rem;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

#resultText {
  font: 600 1rem/1.45 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.copy-button,
.secondary-button {
  min-height: 44px;
  padding: 0 18px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  font-weight: 850;
  cursor: pointer;
}

.secondary-button {
  border: 1px solid var(--accent);
  background: #ffffff;
  color: var(--accent);
}

.copy-button.did-copy {
  background: var(--success);
}

.copy-feedback,
.install-hint {
  min-height: 20px;
  margin-top: 8px;
  color: var(--success);
  font-size: 0.9rem;
  font-weight: 700;
}

.install-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
}

.install-panel p:not(.section-label):not(.install-hint) {
  margin-top: 6px;
  color: var(--muted);
  line-height: 1.45;
}

.install-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.back-button {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--accent);
  font-size: clamp(1rem, 4vw, 1.3rem);
  font-weight: 700;
  cursor: pointer;
}

.back-button span:first-child {
  font-size: 2.2rem;
  line-height: 0.75;
}

.detail-content {
  padding: 26px 0 128px;
}

.section-kicker {
  padding: 0 clamp(18px, 5vw, 46px) 10px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 760;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.instruction-panel,
.definition-list {
  padding: 18px clamp(18px, 5vw, 46px);
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  background: var(--surface);
  color: var(--text);
  font-size: clamp(1.12rem, 4.2vw, 1.45rem);
  line-height: 1.48;
}

.instruction-panel p + p {
  margin-top: 12px;
}

.definition-list {
  padding-top: 0;
  padding-bottom: 0;
}

.definition-row {
  padding: 16px 0;
  border-top: 1px solid var(--rule);
}

.definition-row:first-child {
  border-top: 0;
}

.score-dock {
  position: fixed;
  right: max(0px, calc((100vw - 980px) / 2));
  bottom: 0;
  left: max(0px, calc((100vw - 980px) / 2));
  z-index: 12;
  padding: 10px clamp(18px, 5vw, 46px) max(14px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--rule);
  background: rgba(246, 248, 252, 0.95);
  backdrop-filter: blur(18px);
}

.score-dock p {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.95rem;
}

.detail-options {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.detail-options button {
  flex: 1 0 84px;
  min-height: 52px;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-size: 1.35rem;
  font-weight: 800;
  cursor: pointer;
}

.detail-options button.is-selected {
  border-color: var(--accent);
  background: var(--accent);
  color: #ffffff;
}

.guidelines-dialog {
  width: min(92vw, 720px);
  border: 0;
  border-radius: 12px;
  padding: 24px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}

.guidelines-dialog::backdrop {
  background: rgba(18, 24, 38, 0.34);
}

.guidelines-dialog h2 {
  margin-bottom: 16px;
  text-align: center;
}

.guidelines-dialog ul {
  margin: 0;
  padding-left: 22px;
  font-size: clamp(1rem, 4vw, 1.2rem);
  line-height: 1.45;
}

.dialog-action {
  width: 100%;
  min-height: 48px;
  margin-top: 20px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #ffffff;
  font-weight: 850;
  cursor: pointer;
}

@media (max-width: 640px) {
  .score-row,
  .install-panel {
    grid-template-columns: 1fr;
  }

  .clear-button {
    width: 100%;
  }

  .segmented {
    width: 100%;
    grid-auto-columns: minmax(0, 1fr);
  }

  .segmented button {
    padding: 0 8px;
  }

  .install-actions {
    justify-content: stretch;
  }

  .install-actions button {
    flex: 1;
  }
}
