/* BrushSchool Watercolor Lessons — senior-friendly, offline-first */

:root {
  --accent: #0369A1;
  --accent-hover: #0284C7;
  --accent-soft: #E0F2FE;
  --accent-ink: #0C4A6E;
  --bg: #F5F7FA;
  --surface: #FFFFFF;
  --surface-2: #EEF2F6;
  --text: #1C1917;
  --text-muted: #57534E;
  --border: #D6D3D1;
  --danger: #B91C1C;
  --danger-soft: #FEE2E2;
  --success: #166534;
  --success-soft: #DCFCE7;
  --warn: #92400E;
  --warn-soft: #FEF3C7;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 3px rgba(28, 25, 23, 0.08), 0 4px 16px rgba(28, 25, 23, 0.06);
  --shadow-lg: 0 8px 30px rgba(28, 25, 23, 0.12);
  --font: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  --space: 1rem;
  --touch: 48px;
  --max: 960px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 18px;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  line-height: 1.55;
  display: flex;
  flex-direction: column;
}

img {
  max-width: 100%;
}

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

button {
  cursor: pointer;
}

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: 0.75rem;
  top: -100px;
  z-index: 1000;
  background: var(--accent);
  color: #fff;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  text-decoration: none;
  font-weight: 600;
}

.skip-link:focus {
  top: 0.75rem;
}

/* Header */
.app-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow);
}

.header-inner {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0.85rem 1rem 0.65rem;
}

.brand {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.brand-mark {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: var(--accent-soft);
  font-size: 1.4rem;
  flex-shrink: 0;
}

.brand h1 {
  margin: 0;
  font-size: 1.35rem;
  color: var(--accent-ink);
  letter-spacing: -0.01em;
}

.tagline {
  margin: 0.15rem 0 0;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.main-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.nav-btn {
  min-height: var(--touch);
  min-width: var(--touch);
  padding: 0.55rem 0.9rem;
  border: 2px solid transparent;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text);
  font-weight: 600;
  font-size: 0.95rem;
}

.nav-btn:hover {
  border-color: var(--border);
}

.nav-btn.is-active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* Main */
.main {
  flex: 1;
  max-width: var(--max);
  width: 100%;
  margin: 0 auto;
  padding: 1.25rem 1rem 2.5rem;
}

.view {
  display: none;
}

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

.view[hidden] {
  display: none !important;
}

.view-header {
  margin-bottom: 1.15rem;
}

.view-header.row {
  margin-bottom: 0.75rem;
}

.view-header.row-between {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

.view-header h2 {
  margin: 0 0 0.35rem;
  font-size: 1.45rem;
  color: var(--accent-ink);
}

.view-lead {
  margin: 0;
  color: var(--text-muted);
  max-width: 42rem;
}

.section-title {
  margin: 1.25rem 0 0.65rem;
  font-size: 1.1rem;
  color: var(--accent-ink);
}

/* Toolbar & fields */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1rem;
  padding: 0.9rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin-bottom: 0.85rem;
}

.toolbar .field {
  margin-bottom: 0;
}

.field.grow {
  flex: 1 1 140px;
  min-width: 140px;
}

.field-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.field-row .field {
  flex: 1 1 140px;
}

label,
legend {
  font-weight: 600;
  color: var(--text);
  font-size: 0.95rem;
}

.req {
  font-weight: 500;
  color: var(--text-muted);
  font-size: 0.85rem;
}

input[type="text"],
input[type="search"],
input[type="number"],
input[type="date"],
input[type="time"],
select,
textarea {
  min-height: var(--touch);
  padding: 0.6rem 0.75rem;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  width: 100%;
}

textarea {
  min-height: 5.5rem;
  resize: vertical;
  line-height: 1.45;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  min-height: var(--touch);
  min-width: var(--touch);
  padding: 0.55rem 1.1rem;
  border: 2px solid transparent;
  border-radius: var(--radius-sm);
  font-weight: 600;
  text-align: center;
  background: var(--surface-2);
  color: var(--text);
  text-decoration: none;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn-secondary {
  background: var(--accent-soft);
  color: var(--accent-ink);
  border-color: #BAE6FD;
}

.btn-secondary:hover:not(:disabled) {
  border-color: var(--accent);
}

.btn-ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--surface-2);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}

.btn-danger:hover:not(:disabled) {
  background: #991B1B;
}

.btn-icon {
  width: var(--touch);
  height: var(--touch);
  padding: 0;
  font-size: 1.5rem;
  line-height: 1;
  background: transparent;
  border-color: transparent;
  color: var(--text-muted);
}

.btn-icon:hover {
  background: var(--surface-2);
  color: var(--text);
}

.btn-sm {
  min-height: 44px;
  padding: 0.4rem 0.75rem;
  font-size: 0.92rem;
}

.btn-block {
  width: 100%;
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin-top: 0.75rem;
}

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  box-shadow: var(--shadow);
}

.card-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.item-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  box-shadow: var(--shadow);
}

.item-card:hover {
  border-color: #BAE6FD;
}

.item-card-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
}

.item-card h3 {
  margin: 0;
  font-size: 1.1rem;
  color: var(--text);
}

.item-card p {
  margin: 0.35rem 0;
  color: var(--text-muted);
}

.item-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.75rem;
}

.meta {
  color: var(--text-muted);
  font-size: 0.92rem;
  margin: 0.35rem 0 0;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 1.75rem;
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: capitalize;
}

.badge-success {
  background: var(--success-soft);
  color: var(--success);
}

.badge-warn {
  background: var(--warn-soft);
  color: var(--warn);
}

.badge-muted {
  background: var(--surface-2);
  color: var(--text-muted);
}

.badge-sample {
  background: #F3E8FF;
  color: #6B21A8;
}

.chip {
  display: inline-flex;
  align-items: center;
  min-height: 2rem;
  padding: 0.25rem 0.7rem;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 0.88rem;
  font-weight: 600;
}

.chip-soft {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}

.lesson-meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.75rem;
}

/* Progress */
.progress-bar {
  height: 10px;
  background: var(--surface-2);
  border-radius: 999px;
  overflow: hidden;
  margin: 0.75rem 0 0.35rem;
}

.progress-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent-hover));
  border-radius: 999px;
  transition: width 0.25s ease;
}

.progress-label {
  font-weight: 700;
  color: var(--accent-ink);
  font-size: 0.95rem;
}

.course-hero-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.course-hero h2 {
  margin: 0 0 0.4rem;
  font-size: 1.35rem;
  color: var(--accent-ink);
}

/* Lesson */
.lesson-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  margin-top: 1rem;
}

@media (min-width: 800px) {
  .lesson-layout {
    grid-template-columns: 1.5fr 1fr;
    align-items: start;
  }
}

.steps-list {
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: step;
}

.step-item {
  counter-increment: step;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.85rem 0.9rem;
  margin-bottom: 0.65rem;
  background: var(--surface-2);
}

.step-item.is-done {
  background: var(--success-soft);
  border-color: #86EFAC;
}

.step-item-header {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
}

.step-check {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  margin-top: 0.1rem;
  accent-color: var(--accent);
}

.step-title {
  margin: 0;
  font-weight: 700;
  font-size: 1rem;
}

.step-title::before {
  content: counter(step) ". ";
  color: var(--accent);
}

.step-body {
  margin: 0.45rem 0 0 2.1rem;
  color: var(--text-muted);
}

.tips-list {
  margin: 0;
  padding-left: 1.2rem;
  color: var(--text-muted);
}

.tips-list li {
  margin-bottom: 0.45rem;
}

.side-actions {
  margin-top: 1rem;
}

/* Practice */
.practice-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

@media (min-width: 800px) {
  .practice-grid {
    grid-template-columns: 1fr 1fr;
    align-items: start;
  }
}

.video-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  background: #0F172A;
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-bottom: 0.75rem;
}

.video-frame video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: none;
  background: #000;
  transform: scaleX(-1);
}

.video-frame video.is-on {
  display: block;
}

.camera-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  text-align: center;
  color: #E2E8F0;
}

.camera-placeholder p {
  margin: 0;
  max-width: 22rem;
}

.camera-placeholder.is-hidden {
  display: none;
}

.check-fieldset {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.75rem 0.9rem 0.35rem;
  margin: 0 0 0.85rem;
}

.check-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.check-item {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  min-height: var(--touch);
  padding: 0.35rem 0;
}

.check-item input {
  width: 24px;
  height: 24px;
  margin-top: 0.15rem;
  flex-shrink: 0;
  accent-color: var(--accent);
}

.check-item label {
  font-weight: 500;
  cursor: pointer;
}

/* Stats / insights */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.15rem;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: var(--shadow);
  text-align: center;
}

.stat-card .stat-value {
  display: block;
  font-size: 1.85rem;
  font-weight: 800;
  color: var(--accent);
  line-height: 1.1;
}

.stat-card .stat-label {
  display: block;
  margin-top: 0.35rem;
  color: var(--text-muted);
  font-size: 0.92rem;
  font-weight: 600;
}

.insights-panels {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.85rem;
}

@media (min-width: 800px) {
  .insights-panels {
    grid-template-columns: 1fr 1fr;
  }

  .insights-panels .card:last-child {
    grid-column: 1 / -1;
  }
}

.insight-row {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.45rem 0;
  border-bottom: 1px solid var(--surface-2);
  color: var(--text-muted);
}

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

.insight-row strong {
  color: var(--text);
  font-weight: 700;
}

.empty-state {
  padding: 1.5rem 1rem;
  text-align: center;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

.settings-card {
  margin-bottom: 0.9rem;
}

.settings-card p {
  color: var(--text-muted);
  margin-top: 0;
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
}

.modal[hidden] {
  display: none !important;
}

@media (min-width: 640px) {
  .modal {
    align-items: center;
    padding: 1rem;
  }
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(28, 25, 23, 0.45);
}

.modal-panel {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 520px;
  max-height: 92vh;
  overflow: auto;
  background: var(--surface);
  border-radius: var(--radius) var(--radius) 0 0;
  box-shadow: var(--shadow-lg);
}

@media (min-width: 640px) {
  .modal-panel {
    border-radius: var(--radius);
  }
}

.modal-panel-sm {
  max-width: 420px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 2;
}

.modal-header h2 {
  margin: 0;
  font-size: 1.15rem;
  color: var(--accent-ink);
}

.modal-body {
  padding: 1rem 1.1rem 1.25rem;
}

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.55rem;
  margin-top: 0.5rem;
}

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 1.25rem;
  transform: translateX(-50%);
  z-index: 200;
  max-width: min(92vw, 420px);
  padding: 0.85rem 1.15rem;
  background: var(--accent-ink);
  color: #fff;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  font-weight: 600;
  text-align: center;
}

.toast[hidden] {
  display: none !important;
}

/* Footer */
.app-footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 1rem;
  text-align: center;
}

.app-footer p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.92rem;
}

/* Utility */
.stars {
  letter-spacing: 0.05em;
  color: var(--warn);
  font-weight: 700;
}

.list-plain {
  margin: 0;
  padding: 0;
  list-style: none;
}
