/* MindSharp Daily — senior-friendly, offline-first, teal clarity aesthetic */

:root {
  --accent: #0F766E;
  --accent-hover: #0D5F59;
  --accent-soft: #CCFBF1;
  --accent-ink: #134E4A;
  --bg: #F0FDFA;
  --surface: #FFFFFF;
  --surface-2: #CCFBF1;
  --text: #134E4A;
  --text-muted: #4B5563;
  --border: #99F6E4;
  --danger: #B91C1C;
  --danger-soft: #FEE2E2;
  --success: #166534;
  --success-soft: #DCFCE7;
  --warn: #B45309;
  --warn-soft: #FEF3C7;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 3px rgba(15, 118, 110, 0.08), 0 4px 16px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 8px 30px rgba(15, 23, 42, 0.12);
  --font: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  --space: 1rem;
  --touch: 48px;
  --max: 920px;
}

*,
*::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;
}

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);
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 50;
}

.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: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 12px;
  background: var(--accent);
  color: #fff;
  font-size: 1.35rem;
  flex-shrink: 0;
}

.brand h1 {
  margin: 0;
  font-size: 1.35rem;
  line-height: 1.2;
  color: var(--accent-ink);
}

.tagline {
  margin: 0.2rem 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: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: var(--text-muted);
  font-weight: 600;
}

.nav-btn:hover {
  background: var(--accent-soft);
  color: var(--accent-ink);
}

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

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

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

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

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

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

.masthead {
  margin-bottom: 1.25rem;
  padding: 1.25rem 1.35rem;
  background: linear-gradient(135deg, #FFFFFF 0%, #CCFBF1 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.masthead-kicker {
  margin: 0 0 0.25rem;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent);
}

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

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

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

.stat-card .stat-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.2rem;
}

.stat-card .stat-value {
  display: block;
  font-size: 1.45rem;
  font-weight: 700;
  color: var(--accent-ink);
  line-height: 1.2;
}

/* Panels & cards */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.15rem 1.2rem;
  margin-bottom: 1.15rem;
  box-shadow: var(--shadow);
}

.panel-danger {
  border-color: #FECACA;
  background: #FFFBFB;
}

.panel-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
  margin-bottom: 0.65rem;
}

.panel-header h3 {
  margin: 0;
  font-size: 1.1rem;
  color: var(--accent-ink);
}

.panel-note {
  margin: 0 0 0.85rem;
  color: var(--text-muted);
}

.research-list {
  margin: 0 0 0.85rem;
  padding-left: 1.25rem;
  color: var(--text);
}

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

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

.card {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  padding: 0.9rem 1rem;
}

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

.card-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--accent-ink);
}

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

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

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 1.75rem;
  padding: 0.2rem 0.7rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 700;
  background: var(--accent-soft);
  color: var(--accent-ink);
  white-space: nowrap;
}

.status-pill.is-done {
  background: var(--success-soft);
  color: var(--success);
}

.status-pill.is-progress {
  background: var(--warn-soft);
  color: var(--warn);
}

.status-pill.is-idle {
  background: #E5E7EB;
  color: #374151;
}

.domain-badge {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: capitalize;
  background: var(--accent-soft);
  color: var(--accent-ink);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--touch);
  min-width: var(--touch);
  padding: 0.65rem 1.15rem;
  border-radius: var(--radius-sm);
  border: 2px solid transparent;
  font-weight: 700;
  text-align: center;
  transition: background 0.12s ease, border-color 0.12s ease;
}

.btn-sm {
  min-height: 44px;
  padding: 0.45rem 0.9rem;
  font-size: 0.95rem;
}

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

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

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

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

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

.btn-danger:hover {
  background: #991B1B;
}

.btn-icon {
  min-width: var(--touch);
  min-height: var(--touch);
  border: none;
  background: transparent;
  font-size: 1.6rem;
  line-height: 1;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
}

.btn-icon:hover {
  background: var(--accent-soft);
  color: var(--accent-ink);
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin-bottom: 0.75rem;
}

/* Forms */
.form-stack {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

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

.field label,
.days-fieldset legend {
  font-weight: 700;
  color: var(--accent-ink);
}

.field input,
.field select,
.field textarea {
  min-height: var(--touch);
  padding: 0.65rem 0.8rem;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  width: 100%;
}

.field textarea {
  min-height: 6rem;
  resize: vertical;
}

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

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

@media (max-width: 560px) {
  .field-row {
    grid-template-columns: 1fr;
  }
}

.check-label {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 44px;
  font-weight: 600;
}

.check-label input {
  width: 1.25rem;
  height: 1.25rem;
  accent-color: var(--accent);
}

.check-block {
  padding: 0.25rem 0;
}

.days-fieldset {
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.85rem 0.85rem;
  margin: 0;
}

.days-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.85rem;
}

/* Filters & tabs */
.filter-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
}

.filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.75rem;
}

.filter-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin-top: 0.85rem;
}

.result-summary {
  margin: 0 0 0.85rem;
  color: var(--text-muted);
  font-weight: 600;
}

.tab-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-bottom: 1rem;
}

.tab-btn {
  min-height: var(--touch);
  padding: 0.55rem 1.1rem;
  border-radius: 999px;
  border: 2px solid var(--border);
  background: var(--surface);
  font-weight: 700;
  color: var(--text-muted);
}

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

/* Empty / play */
.empty-state {
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 2rem 1.25rem;
  text-align: center;
}

.empty-title {
  margin: 0 0 0.5rem;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--accent-ink);
}

.play-board,
.play-results {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.2rem;
  box-shadow: var(--shadow);
  margin-bottom: 1rem;
}

.play-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid var(--border);
}

.play-type-badge {
  margin: 0 0 0.25rem;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--accent);
}

.play-meta h3 {
  margin: 0 0 0.25rem;
  font-size: 1.25rem;
}

.play-meta-line {
  margin: 0;
  color: var(--text-muted);
}

.play-surface {
  min-height: 8rem;
  margin-bottom: 1rem;
}

.play-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin-bottom: 0.75rem;
}

.feedback-panel {
  padding: 0.9rem 1rem;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  border: 1px solid var(--border);
  color: var(--accent-ink);
}

.feedback-panel.is-correct {
  background: var(--success-soft);
  border-color: #86EFAC;
  color: var(--success);
}

.feedback-panel.is-partial {
  background: var(--warn-soft);
  border-color: #FCD34D;
  color: #92400E;
}

.feedback-panel.is-wrong {
  background: var(--danger-soft);
  border-color: #FECACA;
  color: var(--danger);
}

.results-card {
  margin-bottom: 1rem;
}

.results-score {
  margin: 0.35rem 0 0.65rem;
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--accent);
}

/* Exercise UI */
.word-stage {
  text-align: center;
  padding: 1.25rem 0.5rem;
}

.word-stage-list {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.55rem;
  margin: 1rem 0;
  list-style: none;
  padding: 0;
}

.word-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0.5rem 1rem;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: 1.1rem;
}

.choice-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.55rem;
}

@media (min-width: 560px) {
  .choice-grid.two-col {
    grid-template-columns: 1fr 1fr;
  }
}

.choice-btn {
  min-height: var(--touch);
  text-align: left;
  padding: 0.85rem 1rem;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-weight: 600;
  color: var(--text);
}

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

.choice-btn.is-selected {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.choice-btn.is-correct {
  border-color: var(--success);
  background: var(--success-soft);
  color: var(--success);
}

.choice-btn.is-wrong {
  border-color: var(--danger);
  background: var(--danger-soft);
  color: var(--danger);
}

.choice-btn:disabled {
  cursor: default;
}

.check-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.45rem;
}

@media (min-width: 560px) {
  .check-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.check-option {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-height: var(--touch);
  padding: 0.55rem 0.85rem;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-weight: 600;
  cursor: pointer;
}

.check-option:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.check-option input {
  width: 1.3rem;
  height: 1.3rem;
  accent-color: var(--accent);
  flex-shrink: 0;
}

.instruction {
  margin: 0 0 0.85rem;
  color: var(--text);
  font-weight: 600;
}

.pattern-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  align-items: center;
  margin-bottom: 1rem;
}

.pattern-cell {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 3rem;
  min-height: 3rem;
  padding: 0.45rem 0.65rem;
  border-radius: 10px;
  background: var(--accent-soft);
  border: 2px solid var(--border);
  font-weight: 800;
  font-size: 1.15rem;
  color: var(--accent-ink);
}

.pattern-cell.is-blank {
  background: var(--surface);
  border-style: dashed;
  color: var(--text-muted);
}

.story-box {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1rem 1.1rem;
  margin-bottom: 1rem;
  line-height: 1.65;
}

/* Bars / snapshot */
.bar-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.bar-row {
  display: grid;
  grid-template-columns: 7rem 1fr 3.5rem;
  gap: 0.55rem;
  align-items: center;
}

.bar-label {
  font-weight: 700;
  text-transform: capitalize;
  color: var(--accent-ink);
}

.bar-track {
  height: 14px;
  background: #E5E7EB;
  border-radius: 999px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
  min-width: 0;
}

.bar-value {
  text-align: right;
  font-weight: 700;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.snapshot-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.75rem;
}

.snapshot-item {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.85rem;
}

.snapshot-item strong {
  display: block;
  font-size: 1.35rem;
  color: var(--accent);
  margin-bottom: 0.15rem;
}

.snapshot-item span {
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 600;
}

/* Modal */
.modal {
  border: none;
  border-radius: var(--radius);
  padding: 0;
  max-width: min(560px, calc(100vw - 1.5rem));
  width: 100%;
  box-shadow: var(--shadow-lg);
  color: var(--text);
  background: var(--surface);
}

.modal::backdrop {
  background: rgba(15, 23, 42, 0.45);
}

.modal-sm {
  max-width: min(420px, calc(100vw - 1.5rem));
}

.modal-inner {
  display: flex;
  flex-direction: column;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
}

.modal-header h2 {
  margin: 0;
  font-size: 1.15rem;
}

.modal-body {
  padding: 1rem;
}

.modal-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.55rem;
  padding: 0.85rem 1rem 1rem;
  border-top: 1px solid var(--border);
}

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

.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.95rem;
}

/* Sample tag */
.sample-tag {
  display: inline-block;
  margin-left: 0.35rem;
  padding: 0.1rem 0.45rem;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 700;
  background: var(--warn-soft);
  color: var(--warn);
  vertical-align: middle;
}
