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

html,
body {
  margin: 0;
  padding: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Text",
    sans-serif;
  background: #020617;
  color: #e5e7eb;
}

body {
  min-height: 100vh;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.9rem 1.1rem;
  background: rgba(15, 23, 42, 0.9);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(148, 163, 184, 0.2);
}

.app-header-main h1 {
  margin: 0;
  font-size: 1.1rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.subtitle {
  margin: 0.1rem 0 0;
  font-size: 0.75rem;
  color: #9ca3af;
}

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

.nav-link {
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  text-decoration: none;
  font-size: 0.75rem;
  color: #e5e7eb;
  border: 1px solid transparent;
}

.nav-link:hover {
  background: rgba(148, 163, 184, 0.2);
}

.nav-link-active {
  background: #22c55e1a;
  border-color: #22c55e;
}

.app-main {
  max-width: 720px;
  margin: 0 auto;
  padding: 1.2rem 1rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.card {
  background: radial-gradient(circle at top left, #0f172a, #020617);
  border-radius: 1rem;
  border: 1px solid rgba(148, 163, 184, 0.2);
  box-shadow: 0 18px 45px rgba(15, 23, 42, 0.9);
}

.card-header {
  padding: 0.9rem 1rem 0.6rem;
  border-bottom: 1px solid rgba(15, 23, 42, 0.9);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.card-header h2 {
  margin: 0;
  font-size: 0.95rem;
}

.card-body {
  padding: 0.7rem 1rem 1rem;
}

.today-date {
  font-size: 0.8rem;
  color: #9ca3af;
}

.today-score {
  margin-top: 0.6rem;
  font-size: 0.9rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.today-score span:last-child {
  font-weight: 600;
  color: #22c55e;
}

.hint-text {
  margin: 0.6rem 0 0;
  font-size: 0.78rem;
  color: #9ca3af;
}

/* Buttons & inputs */
.btn {
  border: 1px solid rgba(148, 163, 184, 0.5);
  background: rgba(15, 23, 42, 0.9);
  color: #e5e7eb;
  padding: 0.4rem 0.8rem;
  border-radius: 999px;
  font-size: 0.78rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
}

.btn-sm {
  padding: 0.3rem 0.6rem;
  font-size: 0.72rem;
}

.btn-primary {
  border-color: #22c55e;
  background: #22c55e1a;
  color: #bbf7d0;
}

.btn-danger {
  border-color: #f97316;
  background: #f973161a;
  color: #fed7aa;
}

.btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.btn:hover:not(:disabled) {
  filter: brightness(1.05);
}

.input {
  width: 100%;
  border-radius: 0.65rem;
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: rgba(15, 23, 42, 0.85);
  color: #e5e7eb;
  padding: 0.38rem 0.6rem;
  font-size: 0.8rem;
}

.input:focus {
  outline: 2px solid #22c55e;
  outline-offset: 1px;
}

.field-label {
  display: block;
  font-size: 0.78rem;
  color: #9ca3af;
  margin-bottom: 0.2rem;
}

/* Task list (today) */
.task-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.35rem 0;
}

.task-checkbox {
  width: 1.1rem;
  height: 1.1rem;
  border-radius: 0.3rem;
  border: 1px solid rgba(148, 163, 184, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  background: rgba(15, 23, 42, 0.9);
}

.task-checkbox.checked {
  border-color: #22c55e;
  background: radial-gradient(circle at 30% 20%, #4ade80, #22c55e);
  box-shadow: 0 0 0 1px rgba(34, 197, 94, 0.7);
}

.task-name {
  flex: 1;
  font-size: 0.88rem;
}

.task-name.inactive {
  opacity: 0.5;
  text-decoration: line-through;
}

/* Task editor */
.task-editor-row {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 0.4rem;
  align-items: center;
  padding: 0.25rem 0;
}

.task-editor-name {
  width: 100%;
}

.task-editor-toggle {
  transform: scale(1.1);
}

.task-editor-actions {
  display: flex;
  gap: 0.25rem;
}

.task-drag-handle {
  font-size: 0.9rem;
  cursor: grab;
  user-select: none;
  opacity: 0.6;
}

/* Sync key */
.sync-key-row {
  margin-top: 0.6rem;
}

.sync-key-display {
  display: flex;
  gap: 0.4rem;
  align-items: center;
}

.sync-key-display .input {
  flex: 1;
}

.status-banner {
  margin-top: 0.6rem;
  font-size: 0.78rem;
  color: #bbf7d0;
  min-height: 1.1rem;
}

.status-banner.error {
  color: #fed7aa;
}

/* Heatmap */
.heatmap-container {
  overflow-x: auto;
  padding-bottom: 0.25rem;
}

.heatmap-svg {
  display: block;
  max-width: 100%;
}

.heatmap-day {
  cursor: pointer;
  transition: opacity 0.1s ease-out, transform 0.05s ease-out;
}

.heatmap-day:hover {
  opacity: 0.8;
  transform: translateY(-0.5px);
}

.heatmap-legend {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.75rem;
  color: #9ca3af;
  margin-top: 0.6rem;
}

.heatmap-legend-swatch {
  width: 0.85rem;
  height: 0.85rem;
  border-radius: 0.15rem;
}

.day-detail-heading {
  font-size: 0.9rem;
  margin: 0 0 0.2rem;
}

.day-detail-sub {
  margin: 0;
  font-size: 0.8rem;
  color: #9ca3af;
}

.day-detail-list {
  margin: 0.5rem 0 0;
  padding-left: 1rem;
  font-size: 0.8rem;
}

/* Segmented control */
.segmented-control {
  display: inline-flex;
  padding: 0.15rem;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(148, 163, 184, 0.4);
}

.segmented-option {
  border: none;
  background: transparent;
  color: #9ca3af;
  padding: 0.28rem 0.7rem;
  border-radius: 999px;
  font-size: 0.75rem;
  cursor: pointer;
}

.segmented-option-active {
  background: #22c55e1a;
  color: #bbf7d0;
}

/* Responsive */
@media (min-width: 768px) {
  .card-header h2 {
    font-size: 1rem;
  }
}

