* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, system-ui, sans-serif;
  background: #f4f5f9;
  color: #1f2333;
  padding-bottom: 24px;
}

#status-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  padding: 6px 16px;
  color: #666;
}
#status-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #22c55e;
}
#status-dot.offline { background: #ef4444; }

.view { padding: 16px; max-width: 480px; margin: 0 auto; }
.hidden { display: none !important; }

h1 { font-size: 28px; margin-bottom: 0; }
.subtitle { color: #666; margin-top: 4px; }
.section-title { font-size: 15px; color: #555; margin: 28px 0 8px; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}
.topbar h2 { margin: 0; font-size: 20px; flex: 1; text-align: center; }

.btn-icon {
  border: none; background: white; border-radius: 10px;
  width: 40px; height: 40px; font-size: 18px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.table-wrap { overflow-x: auto; margin: 12px 0; }
.app-table {
  width: 100%; border-collapse: collapse; background: white;
  border-radius: 14px; overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.app-table th, .app-table td { padding: 12px 14px; text-align: left; font-size: 14px; }
.app-table thead th {
  background: #f0f1f7; font-weight: 600;
  color: #555; font-size: 12px; text-transform: uppercase; letter-spacing: 0.03em;
  white-space: nowrap;
}
.app-table thead th[data-sort] { cursor: pointer; user-select: none; }
.app-table thead th[data-sort]:hover { color: #4f46e5; }
.app-table thead th.sorted { color: #4f46e5; }
.app-table tbody tr { border-top: 1px solid #f0f0f0; }
.app-table tbody tr:hover { background: #fafafa; }
#decks-tbody tr { cursor: pointer; }
.app-table th:last-child, .app-table td:last-child { width: 36px; text-align: center; }
.sort-arrow { display: inline-block; font-size: 10px; margin-left: 4px; }
.app-table .del-btn { border: none; background: transparent; color: #ef4444; font-size: 16px; }

.heatmap-block {
  background: white; border-radius: 14px; padding: 14px 16px; margin-bottom: 10px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.heatmap-title { font-weight: 600; margin-bottom: 10px; font-size: 14px; }
.heatmap-body { display: flex; gap: 6px; }
.heatmap-daylabels {
  display: grid; grid-template-rows: repeat(7, 12px); gap: 3px;
  margin-top: 17px;
  font-size: 9px; color: #888; text-align: right; white-space: nowrap;
}
.heatmap-scroll { overflow-x: auto; }
.heatmap-months {
  display: grid; grid-auto-flow: column; grid-auto-columns: 12px; gap: 3px;
  font-size: 10px; color: #888; height: 14px; margin-bottom: 3px; white-space: nowrap;
}
.heatmap-grid {
  display: grid; grid-template-rows: repeat(7, 12px);
  grid-auto-flow: column; grid-auto-columns: 12px; gap: 3px; width: max-content;
}
.heatmap-cell { width: 12px; height: 12px; border-radius: 3px; }
.heatmap-cell.level-0 { background: #ffffff; border: 1px solid #e5e7eb; }
.heatmap-cell.level-1 { background: #86efac; }
.heatmap-cell.level-2 { background: #15803d; }
.heatmap-cell.future { background: transparent; }
.heatmap-legend {
  display: flex; gap: 14px; margin: 4px 0 20px; font-size: 12px; color: #666;
  align-items: center; flex-wrap: wrap;
}
.legend-item { display: flex; align-items: center; gap: 4px; }
.swatch { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.swatch.level-0 { background: #ffffff; border: 1px solid #e5e7eb; }
.swatch.level-1 { background: #86efac; }
.swatch.level-2 { background: #15803d; }

.card-list { display: flex; flex-direction: column; gap: 10px; margin: 16px 0; }

.card-item {
  background: white; border-radius: 14px; padding: 14px 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  display: flex; justify-content: space-between; align-items: center;
  cursor: pointer;
}
.card-item .meta { font-size: 12px; color: #888; }
.card-item .del-btn {
  border: none; background: transparent; color: #ef4444; font-size: 16px;
}

.btn-primary, .btn-secondary, .btn-danger, .btn-success {
  width: 100%; padding: 14px; border-radius: 12px; border: none;
  font-size: 16px; font-weight: 600; margin-top: 10px;
}
.btn-primary { background: #4f46e5; color: white; }
.btn-secondary { background: #e5e7ff; color: #4f46e5; }
.btn-danger { background: #fee2e2; color: #ef4444; }
.btn-success { background: #dcfce7; color: #16a34a; }
.btn-small { width: auto; padding: 10px 16px; margin-top: 0; }

.row-form { display: flex; gap: 8px; margin-bottom: 12px; }
.row-form input {
  flex: 1; padding: 12px; border-radius: 10px; border: 1px solid #ddd;
}

.flashcard {
  background: white; border-radius: 20px; height: 220px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1); margin-top: 20px;
  font-size: 26px; font-weight: 600; text-align: center; padding: 20px;
  cursor: pointer; user-select: none;
}
.hint { text-align: center; color: #999; font-size: 13px; margin-top: 10px; }
.flashcard-actions { display: flex; gap: 10px; margin-top: 20px; }

#modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.4);
  display: flex; align-items: center; justify-content: center; z-index: 10;
}
.modal {
  background: white; border-radius: 16px; padding: 20px; width: 85%; max-width: 340px;
}
.modal input {
  width: 100%; padding: 12px; border-radius: 10px; border: 1px solid #ddd; margin: 10px 0;
}
.modal-actions { display: flex; gap: 10px; }
.modal-actions button { flex: 1; }