:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f7f7f8;
  color: #1f2328;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-width: 320px;
  min-height: 100%;
  background: #f7f7f8;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.app-shell {
  width: min(100%, 520px);
  min-height: 100svh;
  margin: 0 auto;
  padding: 16px 14px calc(24px + env(safe-area-inset-bottom));
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.app-header h1 {
  margin: 2px 0 0;
  font-size: 24px;
  line-height: 1.15;
  letter-spacing: 0;
}

.eyebrow {
  margin: 0;
  color: #6b7280;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.notice,
.warning-text,
.help-text,
.empty-text {
  margin: 10px 0;
  color: #64748b;
  font-size: 14px;
  line-height: 1.6;
}

.notice {
  padding: 10px 12px;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  background: #eff6ff;
  color: #1d4ed8;
}

.warning-text {
  color: #b45309;
}

.preview-section {
  overflow: hidden;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #ffffff;
}

.panel-canvas {
  display: block;
  width: 100%;
  height: auto;
  min-height: 220px;
  background: #f1f5f9;
}

.progress-summary {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-top: 1px solid #e5e7eb;
  color: #334155;
  font-size: 14px;
  font-weight: 700;
}

.screen-tabs {
  position: sticky;
  top: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin: 12px 0;
  padding: 6px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(12px);
}

.tab-button,
.ghost-button,
.primary-button,
.count-button {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  font-weight: 700;
}

.tab-button {
  background: transparent;
  color: #64748b;
}

.tab-button[aria-current="true"] {
  background: #2563eb;
  color: #ffffff;
}

.workspace {
  display: grid;
  gap: 14px;
}

.section-block,
.run-focus {
  padding: 14px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #ffffff;
}

.section-block h2,
.run-focus h2 {
  margin: 0 0 12px;
  font-size: 18px;
  line-height: 1.3;
  letter-spacing: 0;
}

.file-picker {
  display: grid;
  gap: 10px;
}

.file-picker span {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: #2563eb;
  color: #ffffff;
  font-weight: 800;
}

.file-picker input {
  width: 100%;
}

.form-grid,
.control-grid,
.range-grid {
  display: grid;
  gap: 12px;
}

.field,
.condition-row label {
  display: grid;
  gap: 7px;
  color: #475569;
  font-size: 13px;
  font-weight: 700;
}

.field input,
.field select,
.field textarea,
.condition-row input,
.stepper-row select {
  width: 100%;
  min-height: 44px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #ffffff;
  color: #111827;
  padding: 10px 12px;
}

.field textarea {
  resize: vertical;
  line-height: 1.5;
}

.range-field input {
  padding: 0;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  color: #334155;
  font-size: 14px;
  font-weight: 700;
}

.check-row input {
  width: 20px;
  height: 20px;
}

.conditions-list {
  display: grid;
  gap: 10px;
}

.condition-row {
  margin: 0;
  padding: 12px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #f8fafc;
}

.condition-row.is-done {
  border-color: #86efac;
  background: #f0fdf4;
}

.condition-row legend {
  padding: 0 6px;
  color: #334155;
  font-size: 13px;
  font-weight: 800;
}

.condition-numbers {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 10px;
}

.run-focus {
  text-align: center;
}

.run-focus h2 {
  overflow: hidden;
  margin-top: 4px;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.run-value {
  margin: 0 0 12px;
  color: #1f2937;
  font-size: 24px;
  font-weight: 800;
}

.mini-progress {
  overflow: hidden;
  height: 10px;
  border-radius: 999px;
  background: #e5e7eb;
}

.mini-progress span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: #16a34a;
}

.stepper-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.count-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.count-button {
  min-height: 58px;
  background: #e0e7ff;
  color: #1e3a8a;
  font-size: 18px;
}

.count-button.accent {
  background: #16a34a;
  color: #ffffff;
}

.count-button.subtle,
.ghost-button {
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: #334155;
}

.primary-button {
  background: #2563eb;
  color: #ffffff;
}

.share-actions {
  display: grid;
  gap: 10px;
}

.section-heading-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.section-heading-row h2,
.section-heading-row h3 {
  margin: 0;
  letter-spacing: 0;
}

.section-heading-row h3 {
  color: #334155;
  font-size: 15px;
  line-height: 1.3;
}

.shape-count {
  flex: 0 0 auto;
  color: #64748b;
  font-size: 13px;
  font-weight: 800;
}

.mask-add-row,
.mask-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.mask-list {
  margin-top: 10px;
}

.mask-chip {
  display: flex;
  min-height: 44px;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #ffffff;
  color: #334155;
  padding: 8px 10px;
  font-weight: 800;
}

.mask-chip[aria-pressed="true"] {
  border-color: #2563eb;
  background: #eff6ff;
  color: #1d4ed8;
}

.mask-chip-swatch {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  border: 1px solid rgba(15, 23, 42, 0.25);
  border-radius: 999px;
}

.mask-editor {
  display: grid;
  gap: 12px;
  margin-top: 12px;
  padding: 12px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #f8fafc;
}

.color-field input[type="color"] {
  min-height: 44px;
  padding: 4px;
}

.danger-button {
  color: #b91c1c;
}

@media (min-width: 460px) {
  .control-grid,
  .range-grid,
  .form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .share-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
