:root {
  --bg: #07060f;
  --bg-2: #100d1c;
  --card: rgba(28, 23, 48, 0.86);
  --card-solid: #171328;
  --line: rgba(255, 255, 255, 0.08);
  --text: #f6f3ff;
  --muted: #9d96b8;
  --accent: #c4b5fd;
  --accent-strong: #8b5cf6;
  --good: #34d399;
  --warn: #fbbf24;
  --danger: #fb7185;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
  --radius: 18px;
  --header-h: 64px;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(1200px 500px at 10% -10%, rgba(124, 58, 237, 0.28), transparent 55%),
    radial-gradient(900px 420px at 110% 0%, rgba(20, 184, 166, 0.16), transparent 50%),
    var(--bg);
  color: var(--text);
  font-family: Outfit, "PingFang SC", "Noto Sans SC", sans-serif;
}

body {
  padding:
    env(safe-area-inset-top)
    env(safe-area-inset-right)
    env(safe-area-inset-bottom)
    env(safe-area-inset-left);
}

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

button {
  cursor: pointer;
}

#app {
  max-width: 980px;
  margin: 0 auto;
  padding: 16px 16px 48px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  letter-spacing: 0.08em;
  font-size: 13px;
  color: var(--accent);
  text-transform: uppercase;
}

.logo-mark {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: linear-gradient(135deg, #8b5cf6, #22d3ee);
  display: grid;
  place-items: center;
  color: white;
  font-size: 11px;
  font-weight: 800;
}

h1 {
  margin: 0;
  font-size: 28px;
  letter-spacing: -0.04em;
}

.subtitle {
  color: var(--muted);
  font-size: 13px;
}

.top-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.icon-btn,
.btn {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  border-radius: 12px;
  padding: 10px 12px;
  color: var(--text);
}

.btn.primary {
  background: linear-gradient(135deg, #7c3aed, #6d28d9);
  border-color: transparent;
  font-weight: 600;
}

.btn.danger {
  background: rgba(251, 113, 133, 0.12);
  border-color: rgba(251, 113, 133, 0.3);
  color: #fecdd3;
}

.btn.ghost {
  background: transparent;
}

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

.tabs {
  display: flex;
  gap: 6px;
  padding: 4px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
  border-radius: 14px;
  margin-bottom: 14px;
}

.tabs button {
  flex: 1;
  border: 0;
  background: transparent;
  border-radius: 10px;
  padding: 10px 8px;
  color: var(--muted);
  font-weight: 600;
}

.tabs button.active {
  background: var(--card-solid);
  color: var(--text);
  box-shadow: var(--shadow);
}

.search {
  width: 100%;
  margin-bottom: 12px;
}

.search input,
.field input,
.field select,
.field textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: rgba(8, 6, 16, 0.7);
  border-radius: 14px;
  padding: 12px 14px;
  outline: none;
  font-size: 16px;
}

.search input:focus,
.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: rgba(167, 139, 250, 0.7);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.2);
}

.chip-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 10px;
  margin-bottom: 6px;
  scrollbar-width: none;
}

.chip-row::-webkit-scrollbar {
  display: none;
}

.chip {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 600;
}

.chip.active {
  color: white;
  border-color: transparent;
  background: var(--chip, var(--accent-strong));
}

.day-row .chip {
  min-width: 52px;
  text-align: center;
  padding: 10px 12px;
}

.day-row .chip small {
  display: block;
  font-size: 10px;
  font-weight: 500;
  opacity: 0.8;
}

.meta-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  margin: 4px 0 12px;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(52, 211, 153, 0.12);
  color: var(--good);
  font-size: 12px;
}

.list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
  position: relative;
  overflow: hidden;
}

.card::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--gym-color, var(--accent-strong));
}

.class-card {
  display: grid;
  grid-template-columns: 92px 1fr auto;
  gap: 10px;
  align-items: center;
}

.time {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 15px;
  line-height: 1.25;
}

.time span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.class-name {
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.02em;
}

.class-meta {
  color: var(--muted);
  font-size: 13px;
  margin-top: 3px;
}

.live {
  color: var(--good);
  font-weight: 700;
  font-size: 12px;
}

.soon {
  color: var(--warn);
  font-weight: 700;
  font-size: 12px;
}

.kind {
  justify-self: end;
  align-self: start;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 5px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--accent);
  white-space: nowrap;
}

.wa-link {
  display: inline-block;
  margin-top: 8px;
  color: var(--accent);
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
}

.empty {
  text-align: center;
  padding: 42px 16px;
  color: var(--muted);
}

.gym-week h2,
.section-title {
  margin: 18px 0 10px;
  font-size: 18px;
}

.gym-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 8px;
}

.day-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin: 14px 0 8px;
}

.manage-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.gym-manage {
  margin-bottom: 10px;
}

.gym-manage-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
}

.mini-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.mini-actions .btn,
.mini-actions .icon-btn {
  padding: 8px 10px;
  font-size: 13px;
}

.class-edit-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
  align-items: center;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: grid;
  place-items: end center;
  z-index: 20;
  padding: 12px;
}

.modal {
  width: min(560px, 100%);
  background: #141022;
  border: 1px solid var(--line);
  border-radius: 22px 22px 16px 16px;
  padding: 18px;
  max-height: min(88vh, 760px);
  overflow: auto;
  box-shadow: var(--shadow);
}

.modal h3 {
  margin: 0 0 12px;
}

.fields {
  display: grid;
  gap: 10px;
}

.field label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}

.two {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 14px;
}

.hint {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(18px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: #1e1933;
  border: 1px solid var(--line);
  color: var(--text);
  padding: 10px 14px;
  border-radius: 12px;
  z-index: 30;
  box-shadow: var(--shadow);
}

.hidden-file {
  display: none;
}

@media (min-width: 800px) {
  #app {
    padding-top: 28px;
  }

  .class-card {
    grid-template-columns: 110px 1fr auto;
  }

  .modal-backdrop {
    place-items: center;
  }

  .modal {
    border-radius: 22px;
  }
}

@media (max-width: 640px) {
  .class-card {
    grid-template-columns: 78px 1fr;
  }

  .kind {
    display: none;
  }

  h1 {
    font-size: 24px;
  }

  .gym-manage-head {
    flex-direction: column;
  }

  .mini-actions {
    width: 100%;
  }

  .mini-actions .btn {
    flex: 1;
    text-align: center;
  }
}
