/* ============================================================
   Training Tracker — dark glass skin (matches the Hub starfield)
   ============================================================ */

:root {
  --bg: #080c14;
  --surface: rgba(255, 255, 255, 0.03);
  --surface-2: rgba(255, 255, 255, 0.05);
  --surface-solid: #10141f;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text: #e0e0e0;
  --text-muted: #9ca3af;

  --brand-1: #6366f1;
  --brand-2: #8b5cf6;
  --brand-grad: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);

  --success: #10b981;
  --warning: #f59e0b;
  --danger: #f43f5e;
  --neutral: #64748b;

  --radius: 20px;
  --radius-sm: 12px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

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

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

body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background-color: var(--bg);
  background-image: radial-gradient(900px 500px at 50% -10%, rgba(99, 102, 241, 0.13), transparent 60%),
    radial-gradient(700px 420px at 100% 0%, rgba(139, 92, 246, 0.09), transparent 55%);
  background-repeat: no-repeat;
  line-height: 1.55;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--brand-1);
  text-decoration: none;
}

:focus-visible {
  outline: 2px solid var(--brand-1);
  outline-offset: 2px;
}

.container {
  max-width: 720px;
  margin: 0 auto;
  padding: 1rem 1rem 4rem;
}

/* ---------- Buttons ---------- */
button,
.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 0.62rem 1.1rem;
  font-family: inherit;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  background: var(--brand-grad);
  color: #fff;
  transition: transform 0.15s ease, filter 0.15s ease, box-shadow 0.15s ease;
}

button:hover,
.button-link:hover {
  transform: translateY(-1px);
  filter: brightness(1.08);
  color: #fff;
}

button.secondary {
  background: transparent;
  color: var(--text-muted);
  border-color: var(--border-strong);
}

button.secondary:hover {
  color: var(--text);
  border-color: var(--brand-1);
}

/* ---------- Forms ---------- */
label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.9rem;
}

input,
select,
textarea {
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  font-family: inherit;
  font-size: 1rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--brand-1);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
  outline: none;
}

input[type="date"],
input[type="time"] {
  -webkit-appearance: none;
  appearance: none;
  color-scheme: dark;
}

select {
  -webkit-appearance: none;
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-muted) 50%),
    linear-gradient(135deg, var(--text-muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 55%, calc(100% - 13px) 55%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 2rem;
}

details summary {
  cursor: pointer;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 600;
}

/* ---------- App shell ---------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.6rem 1rem;
  background: rgba(8, 12, 20, 0.82);
  backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid var(--border);
}

.app-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 800;
  color: var(--text);
  font-size: 1rem;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: var(--brand-grad);
  color: #fff;
  font-size: 1rem;
}

.app-nav {
  display: flex;
  gap: 0.2rem;
}

.nav-link {
  padding: 0.42rem 0.7rem;
  border-radius: 999px;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.9rem;
  transition: color 0.15s ease, background 0.15s ease;
}

.nav-link:hover {
  color: var(--text);
  background: var(--surface-2);
}

.nav-link.active {
  color: #fff;
  background: var(--brand-grad);
}

/* ---------- Page head ---------- */
.page-head {
  margin: 1.25rem 0 1rem;
}

.page-title {
  font-size: 1.4rem;
  margin: 0 0 0.25rem;
  letter-spacing: -0.01em;
}

.big-date {
  font-size: 1.7rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.period {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.25rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* ---------- Auth (login) ---------- */
.auth-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1.5rem;
}

.auth-card {
  width: 100%;
  max-width: 400px;
  padding: 2rem 1.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-align: center;
}

.auth-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 60px;
  height: 60px;
  border-radius: 18px;
  background: var(--brand-grad);
  color: #fff;
  font-size: 1.8rem;
  box-shadow: 0 0 40px rgba(99, 102, 241, 0.35);
}

.auth-title {
  margin: 1rem 0 0.2rem;
  font-size: 1.5rem;
  font-weight: 800;
}

.auth-sub {
  color: var(--text-muted);
  margin: 0 0 1.5rem;
}

.auth-card form {
  text-align: left;
}

/* ---------- Cards / surfaces ---------- */
.day-card,
.calendar,
.chart-block,
.settings-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.day-card {
  padding: 1.1rem;
  animation: fade-up 0.22s ease;
}

.day-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  margin-bottom: 0.9rem;
}

.day-meta {
  display: flex;
  flex-direction: column;
}

.day-date {
  font-weight: 700;
  font-size: 1.05rem;
}

.day-week {
  color: var(--text-muted);
  font-size: 0.82rem;
}

.day-type {
  font-weight: 700;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.28rem 0.7rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
}

.status-unrecorded { background: rgba(100, 116, 139, 0.2); color: #94a3b8; }
.status-exercised  { background: rgba(16, 185, 129, 0.18); color: #34d399; }
.status-missed     { background: rgba(244, 63, 94, 0.16); color: #fb7185; }

.notice {
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.28);
  color: #fbbf24;
  padding: 0.6rem 0.8rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  margin-bottom: 0.9rem;
}

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

/* progress */
.progress {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  margin-bottom: 0.9rem;
}

.progress-track {
  flex: 1;
  height: 10px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}

.progress-fill {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--brand-grad);
  transition: width 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}

.progress-text {
  font-weight: 800;
  font-size: 0.88rem;
  min-width: 3rem;
  text-align: right;
}

/* exercise list */
.exercise-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.exercise {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.8rem 0;
  border-bottom: 1px solid var(--border);
}

.exercise:last-child {
  border-bottom: none;
}

.ex-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border-radius: 12px;
  font-size: 1.25rem;
  background: var(--surface-2);
}

.exercise.done .ex-icon {
  filter: saturate(0.2);
  opacity: 0.5;
}

.ex-body {
  flex: 1;
  min-width: 0;
}

.ex-name {
  font-weight: 700;
  font-size: 1rem;
}

.exercise.done .ex-name {
  color: var(--text-muted);
  text-decoration: line-through;
}

.ex-plan {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-top: 0.1rem;
}

.ex-plan span {
  margin-right: 0.55rem;
}

.ex-coach {
  font-size: 0.82rem;
  color: #a5b4fc;
  margin-top: 0.15rem;
}

/* checkbox */
.checkbox {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 2px solid var(--border-strong);
  background: transparent;
  color: #fff;
  font-size: 1.15rem;
  line-height: 1;
  padding: 0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: none;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}

.checkbox:hover {
  border-color: var(--brand-1);
  transform: scale(1.05);
  box-shadow: none;
}

.checkbox.checked {
  background: var(--success);
  border-color: var(--success);
}

/* details form */
.detail {
  margin-top: 0.45rem;
}

.detail-form {
  margin-top: 0.5rem;
  padding: 0.7rem;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.5rem;
  margin-bottom: 0.6rem;
}

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

.skip-row {
  margin-top: 0.85rem;
}

.skip-form {
  margin-top: 0.5rem;
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.skip-form select {
  flex: 1;
  min-width: 8rem;
}

/* ---------- Calendar ---------- */
.calendar {
  padding: 1rem;
  margin-bottom: 1.25rem;
}

.cal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.cal-head h2 {
  margin: 0;
  font-size: 1.1rem;
}

.cal-nav {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  color: var(--text-muted);
  font-size: 1.3rem;
  transition: background 0.15s ease;
}

.cal-nav:hover {
  background: var(--surface-2);
  color: var(--text);
}

.cal-weekdays,
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0.3rem;
}

.cal-weekdays span {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.3rem 0;
}

.cal-cell {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  aspect-ratio: 1 / 1;
  border: 1px solid transparent;
  border-radius: 10px;
  color: var(--text);
  font-size: 0.85rem;
  transition: background 0.12s ease;
}

.cal-cell.cell-status-exercised {
  background: rgba(16, 185, 129, 0.16);
}

.cal-cell.cell-status-missed {
  background: rgba(244, 63, 94, 0.14);
}

.cal-cell:hover {
  background: var(--surface-2);
}

.cal-cell.dim {
  opacity: 0.32;
}

.cal-cell.today {
  border-color: var(--brand-1);
}

.cal-cell.selected {
  background: var(--brand-grad) !important;
  color: #fff;
  font-weight: 700;
}

.cal-cell.cell-status-exercised .cal-status {
  color: #34d399;
  font-weight: 700;
}

.cal-cell.cell-status-missed .cal-status {
  color: #fb7185;
  font-weight: 700;
}

.cal-cell.cell-status-unrecorded .cal-status {
  color: #64748b;
}

.cal-cell.selected .cal-status {
  color: #fff;
}

.cal-status {
  font-size: 0.68rem;
  line-height: 1;
  margin-top: 0.15rem;
}

.cal-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.9rem;
  justify-content: center;
  margin-top: 0.85rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}

.cal-legend span {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.cal-legend .lg {
  width: 12px;
  height: 12px;
  border-radius: 4px;
  display: inline-block;
}

.lg-exercised { background: rgba(16, 185, 129, 0.6); }
.lg-missed { background: rgba(244, 63, 94, 0.55); }
.lg-unrecorded { background: rgba(100, 116, 139, 0.35); }
.lg-today { background: transparent; border: 2px solid var(--brand-1); }

/* ---------- Stats ---------- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.stat-icon {
  font-size: 1.2rem;
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.stat-label {
  color: var(--text-muted);
  font-size: 0.8rem;
}

.chart-block {
  padding: 1rem;
  margin-bottom: 1rem;
}

.chart-block h3 {
  margin: 0 0 0.75rem;
  font-size: 1rem;
}

.chart-block canvas {
  max-height: 240px;
}

/* ---------- Settings ---------- */
.settings-block {
  padding: 1.1rem;
  margin-bottom: 1rem;
}

.settings-block h2 {
  margin: 0 0 0.9rem;
  font-size: 1.05rem;
}

.btn-row {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* ---------- Record UI ---------- */
.record-title {
  font-size: 0.95rem;
  font-weight: 700;
  margin: 0.25rem 0 0.4rem;
}

.muted {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.missed-note,
.rest-hint {
  background: rgba(244, 63, 94, 0.08);
  border: 1px solid rgba(244, 63, 94, 0.25);
  color: #fda4af;
  padding: 0.55rem 0.8rem;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  margin-bottom: 0.75rem;
}

.rest-hint {
  background: rgba(99, 102, 241, 0.08);
  border-color: rgba(99, 102, 241, 0.25);
  color: #a5b4fc;
}

.tag-suggest {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 0.08rem 0.45rem;
  border-radius: 999px;
  background: rgba(99, 102, 241, 0.16);
  color: #a5b4fc;
  margin-right: 0.5rem;
}

.empty-mini {
  color: var(--text-muted);
  font-size: 0.88rem;
  padding: 0.4rem 0;
  margin: 0;
}

/* add own activity */
.add-form {
  display: flex;
  gap: 0.5rem;
  margin: 0.6rem 0 0.25rem;
}

.add-form input {
  flex: 1;
  margin-top: 0;
}

.add-btn {
  white-space: nowrap;
  margin-top: 0;
}

.del-form {
  margin: 0.15rem 0 0 0.2rem;
}

.del-btn {
  width: 30px;
  height: 30px;
  padding: 0;
  border-radius: 8px;
  font-size: 0.9rem;
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--text-muted);
  box-shadow: none;
}

.del-btn:hover {
  color: #fb7185;
  border-color: #fb7185;
}

.missed-block {
  margin-top: 0.9rem;
  padding-top: 0.75rem;
  border-top: 1px dashed var(--border-strong);
}

.missed-form {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.4rem;
}

.missed-form input {
  flex: 1;
  min-width: 12rem;
  margin-top: 0;
}

/* ---------- Utilities ---------- */
.empty {
  text-align: center;
  color: var(--text-muted);
  padding: 2rem 0;
}

.form-error {
  color: #fb7185;
  font-size: 0.9rem;
  font-weight: 600;
  margin: 0.5rem 0;
}

.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--success);
  color: #fff;
  padding: 0.6rem 1rem;
  border-radius: 999px;
  font-weight: 600;
  z-index: 30;
}

@keyframes fade-up {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }
}
