* { box-sizing: border-box; }

body {
  font-family: system-ui, -apple-system, sans-serif;
  margin: 0;
  color: #222;
  background: #fafafa;
}

footer {
  max-width: 1200px;
  margin: 1rem auto;
  padding: 0 1rem 2rem;
  text-align: right;
}

.legal-page {
  display: block;
  max-width: 48rem;
  margin: 2rem auto;
  padding: 1.5rem;
}

.legal-page h2 { margin-top: 2rem; }
.legal-page .effective-date { color: #666; }

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid #e0e0e0;
  background: #fff;
}

header h1 { margin: 0; font-size: 1.25rem; }

main {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 1.5rem;
  padding: 1.5rem;
}

section h2 { margin-top: 0; font-size: 1rem; text-transform: uppercase; letter-spacing: 0.05em; color: #555; }

#kittens-list {
  list-style: none;
  padding: 0;
  margin: 0 0 0.75rem 0;
}

#kittens-list li {
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  padding: 0.6rem 0.8rem;
  margin-bottom: 0.5rem;
}

#kittens-list .meta { font-size: 0.85rem; color: #666; }

#kittens-list .kitten-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

button {
  font: inherit;
  padding: 0.4rem 0.75rem;
  border: 1px solid #d0d0d0;
  background: #fff;
  border-radius: 5px;
  cursor: pointer;
  color: #222;
  line-height: 1.2;
  transition: background-color 0.12s, border-color 0.12s, color 0.12s;
}

button:hover { background: #f4f4f4; border-color: #b8b8b8; }
button:active { background: #ebebeb; }
button:focus-visible { outline: 2px solid #4f8df9; outline-offset: 1px; }

button.primary {
  background: #2e6cdf;
  border-color: #2e6cdf;
  color: #fff;
}
button.primary:hover { background: #2858bd; border-color: #2858bd; }
button.primary:active { background: #234fa6; border-color: #234fa6; }

.chart-controls {
  margin-bottom: 0.75rem;
}

.chart-controls fieldset {
  border: 1px solid #e0e0e0;
  border-radius: 4px;
  padding: 0.4rem 0.8rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.8rem;
}

.chart-controls legend { padding: 0 0.3rem; color: #666; font-size: 0.85rem; }
.chart-controls label { font-size: 0.9rem; }

.chart-wrap {
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  padding: 1rem;
  height: 70vh;
  min-height: 400px;
}

dialog {
  border: 1px solid #c0c0c0;
  border-radius: 8px;
  padding: 1.25rem;
  width: min(420px, calc(100vw - 2rem));
}

dialog form { display: flex; flex-direction: column; gap: 0.6rem; }
dialog label { display: flex; flex-direction: column; gap: 0.2rem; font-size: 0.9rem; }
dialog label.checkbox-row { flex-direction: row; align-items: center; gap: 0.4rem; }
dialog label.checkbox-row input { width: auto; }
dialog input, dialog select {
  font: inherit;
  font-size: max(16px, 1rem);
  padding: 0.35rem 0.5rem;
  border: 1px solid #c0c0c0;
  border-radius: 4px;
}
dialog menu { padding: 0; margin: 0.5rem 0 0; display: flex; gap: 0.5rem; justify-content: flex-end; }

.recent-points {
  margin: 0.5rem 0 0;
  padding: 0;
  list-style: none;
  font-size: 0.8rem;
  color: #444;
  border-top: 1px dashed #e0e0e0;
  padding-top: 0.4rem;
}

.recent-points li {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.6rem;
  padding: 0.15rem 0;
  font-variant-numeric: tabular-nums;
}

.recent-points .date { color: #777; }
.recent-points .notes { color: #999; font-style: italic; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent-points .weight { font-weight: 600; }

.recent-points li.add-weight {
  display: block;
  text-align: center;
  padding: 0.4rem 0.5rem;
  margin-bottom: 0.3rem;
  background: #eaf1fc;
  color: #2e6cdf;
  font-weight: 600;
  font-size: 0.82rem;
  border-radius: 4px;
  cursor: pointer;
  user-select: none;
}

.recent-points li.add-weight:hover { background: #d8e6fa; }
.recent-points li.add-weight:active { background: #c8dafc; }
.recent-points li.add-weight:focus-visible {
  outline: 2px solid #2e6cdf;
  outline-offset: 1px;
}

.kitten-actions {
  display: flex;
  gap: 0.3rem;
  align-items: center;
}

.icon-btn {
  padding: 0.35rem;
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-color: transparent;
  color: #666;
}

.icon-btn:hover {
  background: #ececec;
  border-color: #d0d0d0;
  color: #222;
}

.icon-btn svg { display: block; }

.summary {
  margin-top: 0.4rem;
  font-size: 0.85rem;
  color: #333;
  font-variant-numeric: tabular-nums;
}

#kittens-list li.archived {
  opacity: 0.55;
  background: #f4f4f4;
}

#archived-controls {
  margin-top: 0.5rem;
}

.archived-toggle {
  font-size: 0.85rem;
  color: #666;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  cursor: pointer;
}

.datapoints-table tr.clickable { cursor: pointer; }
.datapoints-table tr.clickable:hover { background: #f5f9ff; }

.kittens-section-actions {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

#import-dialog { width: min(480px, 90vw); }
#import-dialog textarea {
  width: 100%;
  font: inherit;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.85rem;
  padding: 0.4rem 0.5rem;
  border: 1px solid #c0c0c0;
  border-radius: 4px;
  resize: vertical;
}

.import-preview {
  background: #f6f8fc;
  border: 1px solid #dde3ec;
  border-radius: 4px;
  padding: 0.6rem 0.8rem;
  font-size: 0.88rem;
  line-height: 1.5;
  max-height: 200px;
  overflow-y: auto;
}

.import-warn { color: #b56b00; display: block; }

.import-error {
  background: #fbeaea;
  border: 1px solid #d6a0a0;
  color: #b03030;
  border-radius: 4px;
  padding: 0.5rem 0.7rem;
  font-size: 0.88rem;
}

dialog menu .danger {
  margin-right: auto;
  border-color: #d36a6a;
  color: #b03030;
}
dialog menu .danger:hover { background: #fbeaea; }

.tabs {
  display: flex;
  gap: 0.25rem;
  border-bottom: 1px solid #d0d0d0;
  margin-bottom: 1rem;
}

.tab {
  background: transparent;
  border: 1px solid transparent;
  border-bottom: none;
  border-radius: 6px 6px 0 0;
  padding: 0.45rem 0.9rem;
  font-size: 0.95rem;
  color: #555;
  cursor: pointer;
  margin-bottom: -1px;
}

.tab:hover { background: #f0f0f0; }

.tab[aria-selected="true"] {
  background: #fff;
  border-color: #d0d0d0;
  color: #222;
  font-weight: 600;
}

.table-wrap {
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  padding: 0.5rem 1rem;
  overflow-x: auto;
}

.datapoints-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.datapoints-table th,
.datapoints-table td {
  text-align: left;
  padding: 0.4rem 0.6rem;
  border-bottom: 1px solid #efefef;
}

.datapoints-table th {
  font-weight: 600;
  color: #555;
  background: #fafafa;
  position: sticky;
  top: 0;
}

.datapoints-table td.num,
.datapoints-table th.num { text-align: right; font-variant-numeric: tabular-nums; }

#datapoints-empty { padding: 0.5rem; }

.kitten-data-block { margin-bottom: 1.5rem; }
.kitten-data-block h3 {
  margin: 0 0 0.5rem 0;
  font-size: 1rem;
  font-weight: 600;
}

#error {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  background: #c0392b;
  color: white;
  padding: 0.6rem 0.9rem;
  border-radius: 4px;
  max-width: min(360px, calc(100vw - 2rem));
}

@media (max-width: 720px) {
  main {
    grid-template-columns: 1fr;
    padding: 1rem;
    gap: 1rem;
  }
  header {
    padding: 0.75rem 1rem;
    flex-wrap: wrap;
    gap: 0.5rem;
  }
  #auth {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
  }
  .chart-wrap {
    height: 60vh;
    min-height: 320px;
    padding: 0.5rem;
  }
  .tab {
    padding: 0.6rem 1rem;
    font-size: 1rem;
  }
  .table-wrap { padding: 0.4rem 0.5rem; }
  .datapoints-table { font-size: 0.85rem; }
  .icon-btn {
    width: 36px;
    height: 36px;
  }
}

@media (max-width: 480px) {
  header h1 { font-size: 1.1rem; }
  .chart-wrap {
    height: 55vh;
    min-height: 280px;
  }
  dialog { padding: 1rem; }
  dialog menu { flex-wrap: wrap; }
}

@media (max-height: 480px) and (orientation: landscape) {
  .chart-wrap {
    height: 80vh;
    min-height: 240px;
  }
}
