:root {
  --bg: #f6f7fb;
  --card: #ffffff;
  --text: #18212f;
  --muted: #667085;
  --primary: #2563eb;
  --primary-2: #1d4ed8;
  --primary-soft: #eff6ff;
  --border: #e5e7eb;
  --danger: #dc2626;
  --danger-2: #b91c1c;
  --success-soft: #dcfce7;
  --success-text: #166534;
  --study-soft: #fee2e2;
  --study-text: #991b1b;
}
body.kspa-app {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
[hidden] {
  display: none !important;
}
.kspa-install-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  margin-bottom: 14px;
  border-radius: 18px;
  background: linear-gradient(180deg, #ffffff 0%, #eef6ff 100%);
  border: 1px solid #bfdbfe;
  box-shadow: 0 6px 20px rgba(15, 23, 42, 0.05);
}
.kspa-install-banner-text {
  display: grid;
  gap: 4px;
  font-size: 14px;
}
.kspa-install-banner-text span {
  color: var(--muted);
  line-height: 1.45;
}
.kspa-install-button {
  min-width: 128px;
  white-space: nowrap;
}
.kspa-install-modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(15, 23, 42, 0.45);
  z-index: 9999;
}
.kspa-install-modal-card {
  width: 100%;
  max-width: 420px;
  background: #fff;
  border-radius: 20px;
  padding: 20px;
  box-shadow: 0 20px 48px rgba(15, 23, 42, 0.22);
}
.kspa-shell { max-width: 560px; margin: 0 auto; padding: 16px; }
.kspa-pull-refresh {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  justify-content: center;
  padding: 4px 0 10px;
  pointer-events: none;
}
.kspa-pull-refresh span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  background: rgba(37, 99, 235, 0.95);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  box-shadow: 0 8px 22px rgba(37, 99, 235, 0.24);
}
.kspa-main { padding-bottom: 104px; }
.kspa-page { display: grid; gap: 16px; }
.kspa-device-detail-page,
.kspa-device-list-page { gap: 18px; }
.kspa-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.kspa-header-stacked { align-items: flex-start; }
.kspa-header h1, .kspa-card h2 { margin: 0; }
.kspa-overline {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 6px;
}
.kspa-inline-link {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
}
.kspa-inline-link:hover {
  text-decoration: underline;
}
.kspa-card, .kspa-button {
  border-radius: 20px;
}
.kspa-card {
  background: var(--card);
  border: 1px solid var(--border);
  padding: 18px;
  box-shadow: 0 6px 20px rgba(15, 23, 42, 0.05);
}
.kspa-card-list { display: grid; gap: 14px; }
.kspa-device-link {
  color: inherit;
  text-decoration: none;
  flex: 1;
}
.kspa-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 16px;
  border: 0;
  background: var(--primary);
  color: #fff;
  text-decoration: none;
  font-weight: 600;
  cursor: pointer;
}
.kspa-button:hover { background: var(--primary-2); }
.kspa-button-primary { background: var(--primary); }
.kspa-button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}
.kspa-download-card {
  background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
}
.kspa-empty-state-card {
  text-align: left;
}
.kspa-icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  min-width: 48px;
  height: 48px;
  border-radius: 999px;
  background: var(--primary);
  color: #fff;
  text-decoration: none;
  font-size: 22px;
  line-height: 1;
  box-shadow: 0 10px 22px rgba(37, 99, 235, 0.22);
}
.kspa-icon-button:hover {
  background: var(--primary-2);
}
.kspa-button-secondary { background: #111827; }
.kspa-button-danger { background: var(--danger); }
.kspa-button-danger:hover { background: var(--danger-2); }
.kspa-button-xl {
  width: 100%;
  min-height: 56px;
  font-size: 16px;
}
.kspa-device-main-action {
  flex: 1;
}
input, select {
  width: 100%;
  min-height: 44px;
  margin-top: 8px;
  margin-bottom: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0 12px;
  box-sizing: border-box;
}
.kspa-field-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 4px;
}
.kspa-form-stack {
  display: grid;
  gap: 8px;
}
.kspa-weekday-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
  margin-bottom: 6px;
}
.kspa-check-chip {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #f8fafc;
  cursor: pointer;
  font-weight: 700;
  transition: all 0.18s ease;
  user-select: none;
}
.kspa-check-chip:hover {
  border-color: #bfdbfe;
  background: #f0f7ff;
}
.kspa-check-chip input {
  position: absolute;
  inset: 0;
  opacity: 0;
  width: 100%;
  height: 100%;
  min-height: auto;
  margin: 0;
  cursor: pointer;
}
.kspa-check-chip span {
  position: relative;
  z-index: 1;
}
.kspa-check-chip:has(input:checked) {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.22);
}
.kspa-check-chip:has(input:focus-visible) {
  outline: 3px solid rgba(37, 99, 235, 0.2);
  outline-offset: 2px;
}
.kspa-inline-note {
  margin-top: 12px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
  word-break: break-word;
}
.kspa-pair-code-box {
  margin-top: 12px;
  padding: 14px 16px;
  border-radius: 14px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 4px;
  text-align: center;
  color: #1d4ed8;
}
.kspa-state-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 0 14px;
  border-radius: 999px;
  background: #f3f4f6;
  color: #111827;
  font-weight: 600;
  white-space: nowrap;
}
.kspa-state-pill.is-on {
  background: var(--study-soft);
  color: var(--study-text);
}
.kspa-state-pill.is-off {
  background: var(--success-soft);
  color: var(--success-text);
}
.kspa-status-dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  background: #eef2ff;
  color: #3730a3;
}
.kspa-status-dot.is-online {
  background: var(--success-soft);
  color: var(--success-text);
}
.kspa-status-dot.is-offline {
  background: #f3f4f6;
  color: #6b7280;
}
.kspa-section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.kspa-hero-card,
.kspa-device-list-card {
  background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
}
.kspa-hero-top,
.kspa-device-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}
.kspa-hero-title,
.kspa-device-card-title {
  margin: 0;
  font-size: 26px;
  line-height: 1.2;
}
.kspa-device-card-title {
  font-size: 22px;
}
.kspa-status-stack {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}
.kspa-hero-reason,
.kspa-device-card-reason {
  margin-top: 14px;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.5;
}
.kspa-hero-meta,
.kspa-device-card-meta {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}
.kspa-meta-item {
  padding: 14px 16px;
  border-radius: 16px;
  background: #f8fafc;
  border: 1px solid #edf2f7;
}
.kspa-meta-label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 6px;
}
.kspa-meta-value {
  display: block;
  font-size: 14px;
  line-height: 1.5;
  font-weight: 600;
}
.kspa-hero-action-row {
  margin-top: 18px;
}
.kspa-quick-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: stretch;
  gap: 14px;
}
.kspa-quick-grid-detail {
  grid-template-columns: 1fr;
}
.kspa-quick-card {
  color: inherit;
  text-decoration: none;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  min-height: 160px;
  height: 100%;
  box-sizing: border-box;
}
.kspa-device-card-actions {
  display: flex;
  gap: 12px;
  margin-top: 16px;
}
.kspa-device-list-card.is-busy {
  opacity: 0.78;
}
.kspa-report-card {
  display: grid;
  gap: 10px;
}
.kspa-report-list {
  display: grid;
  gap: 10px;
}
.kspa-report-item {
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fafafa;
}
.kspa-report-item-rich {
  background: linear-gradient(180deg, #ffffff 0%, #fafcff 100%);
}
.kspa-report-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.kspa-event-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  background: #eef2ff;
  color: #3730a3;
}
.kspa-event-badge.is-info {
  background: #eef2ff;
  color: #3730a3;
}
.kspa-event-badge.is-warning {
  background: #fff7ed;
  color: #c2410c;
}
.kspa-event-badge.is-important {
  background: #fef2f2;
  color: #b91c1c;
}
.kspa-event-badge.is-hidden-debug {
  background: #111827;
  color: #f9fafb;
}
.kspa-report-time {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 0;
}
.kspa-report-main {
  font-weight: 700;
  line-height: 1.45;
}
.kspa-report-summary {
  margin-top: 6px;
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
}
.kspa-report-reason {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}
.kspa-report-debug-meta {
  margin-top: 8px;
  font-size: 12px;
  line-height: 1.5;
  color: #475569;
}
.kspa-debug-hidden-card {
  border-style: dashed;
}
.kspa-report-item.is-debug-hidden {
  background: #f8fafc;
}
.kspa-report-type {
  color: var(--muted);
  font-size: 13px;
  margin-top: 4px;
}
.kspa-report-actions {
  margin-top: 12px;
}
.kspa-schedule-weekdays-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.kspa-schedule-weekdays-label {
  white-space: nowrap;
}
.kspa-schedule-weekdays-chips {
  display: inline-flex;
  gap: 6px;
  flex-wrap: wrap;
}
.kspa-schedule-weekday-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  padding: 4px 8px;
  border-radius: 999px;
  background: #eef2ff;
  color: #3730a3;
  font-size: 12px;
  font-weight: 600;
}
.kspa-feedback {
  margin-top: 0;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid transparent;
}
.kspa-feedback.is-success {
  background: var(--success-soft);
  border-color: #bbf7d0;
  color: var(--success-text);
}
.kspa-feedback.is-error {
  background: #fef2f2;
  border-color: #fecaca;
  color: var(--danger-2);
}
.kspa-debug-box {
  margin: 0;
  padding: 14px;
  border-radius: 14px;
  background: #0f172a;
  color: #e2e8f0;
  font-size: 12px;
  line-height: 1.5;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}
.kspa-tabbar {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: min(560px, 100%);
  box-sizing: border-box;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px));
  background: rgba(255,255,255,0.96);
  border-top: 1px solid var(--border);
  backdrop-filter: blur(14px);
  z-index: 50;
}
.kspa-tabbar-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 58px;
  color: var(--muted);
  text-decoration: none;
  font-size: 12px;
  font-weight: 700;
  border-radius: 16px;
}
.kspa-tabbar-item.is-active {
  color: var(--primary);
  background: var(--primary-soft);
}
.kspa-tabbar-icon {
  font-size: 20px;
  line-height: 1;
}
.kspa-tabbar-label {
  white-space: nowrap;
}
.kspa-billing-banner {
  margin-bottom: 16px;
  padding: 16px 18px;
  border-radius: 16px;
  border: 1px solid #bfdbfe;
  background: #eff6ff;
}
.kspa-billing-banner.is-warning {
  border-color: #fecaca;
  background: #fef2f2;
}
.kspa-plan-card {
  position: relative;
}
.kspa-plan-card.is-current {
  border-color: #93c5fd;
  box-shadow: 0 10px 28px rgba(37, 99, 235, 0.14);
  background: linear-gradient(180deg, #ffffff 0%, #eff6ff 100%);
}
.kspa-plan-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}
.kspa-plan-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  padding: 0 12px;
  border-radius: 999px;
  background: #dbeafe;
  color: #1d4ed8;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}
.kspa-price-highlight {
  margin-bottom: 10px;
  font-size: 24px;
  line-height: 1.2;
  font-weight: 800;
  color: #0f172a;
}
.kspa-plan-total-amount {
  margin-bottom: 12px;
  color: #b45309;
  font-size: 28px;
  line-height: 1.15;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.kspa-auth-page {
  gap: 18px;
}
.kspa-auth-card {
  padding: 0;
  overflow: hidden;
}
.kspa-auth-grid {
  display: grid;
  grid-template-columns: 1.4fr 0.9fr;
}
.kspa-auth-grid > * {
  padding: 22px;
}
.kspa-auth-aside {
  background: linear-gradient(180deg, #eff6ff 0%, #f8fbff 100%);
  border-left: 1px solid var(--border);
  display: grid;
  align-content: start;
  gap: 12px;
}
.kspa-check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: var(--muted);
}
.kspa-check-row input {
  width: 18px;
  min-height: 18px;
  height: 18px;
  margin: 0;
}
.kspa-feedback-error {
  margin-top: 0;
  margin-bottom: 12px;
  padding: 12px 14px;
  border-radius: 14px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: var(--danger-2);
}
.kspa-policy-section {
  gap: 12px;
}
.kspa-policy-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0;
  border: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
}
.kspa-policy-toggle-icon {
  font-size: 18px;
  color: var(--muted);
  flex: 0 0 auto;
}
.kspa-policy-lists-wrap {
  display: grid;
  gap: 10px;
}
.kspa-policy-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}
.kspa-manage-card {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
}
.kspa-manage-items {
  display: grid;
  gap: 8px;
}
.kspa-manage-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
}
.kspa-manage-item-main {
  min-width: 0;
  display: grid;
  gap: 3px;
}
.kspa-manage-item-title {
  font-weight: 700;
  font-size: 14px;
  line-height: 1.35;
  word-break: break-word;
}
.kspa-manage-item-meta {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}
.kspa-manage-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}
.kspa-manage-input {
  width: 100%;
  min-height: 40px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  box-sizing: border-box;
}
.kspa-manage-input:focus {
  outline: none;
  border-color: #93c5fd;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}
@media (max-width: 640px) {
  .kspa-shell { padding: 14px; }
  .kspa-card { padding: 16px; }
  .kspa-hero-top,
  .kspa-device-card-top,
  .kspa-section-heading,
  .kspa-header {
    flex-direction: column;
    align-items: flex-start;
  }
  .kspa-status-stack {
    align-items: flex-start;
  }
  .kspa-quick-grid,
  .kspa-quick-grid-single-mobile,
  .kspa-device-card-actions,
  .kspa-device-card-actions-3col,
  .kspa-auth-grid,
  .kspa-policy-grid {
    display: grid;
    grid-template-columns: 1fr;
  }
  .kspa-manage-item {
    flex-direction: column;
    align-items: stretch;
  }
  .kspa-manage-form {
    grid-template-columns: 1fr;
    align-items: stretch;
  }
  .kspa-weekday-grid {
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 4px;
  }
  .kspa-check-chip {
    min-width: 0;
    min-height: 36px;
    padding: 0 4px;
    border-radius: 10px;
  }
  .kspa-check-chip span {
    font-size: 11px;
    white-space: nowrap;
  }
  .kspa-schedule-weekdays-row {
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: center;
    gap: 6px;
  }
  .kspa-schedule-weekdays-label {
    font-size: 12px;
  }
  .kspa-schedule-weekdays-chips {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 4px;
    width: 100%;
  }
  .kspa-schedule-weekday-chip {
    min-width: 0;
    padding: 3px 0;
    font-size: 11px;
  }
}
