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

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.5;
  color: #1a1a1a;
  background: #fafafa;
}

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.card {
  background: #fff;
  border: 1px solid #e2e2e2;
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 16px;
}

label {
  display: block;
  margin: 12px 0 4px;
  font-weight: 600;
}

/* 16px font keeps iOS Safari from zooming on focus */
input {
  width: 100%;
  padding: 10px 12px;
  font: inherit;
  font-size: 16px;
  border: 1px solid #bbb;
  border-radius: 6px;
}

select {
  width: 100%;
  padding: 10px 12px;
  font: inherit;
  font-size: 16px;
  border: 1px solid #bbb;
  border-radius: 6px;
  background: #fff;
}

/* Searchable repo list: scrolls inside its box so the page stays short */
.repo-list {
  max-height: 40vh;
  margin: 8px 0;
  padding: 0;
  overflow-y: auto;
  list-style: none;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 6px;
}

.repo-list li + li { border-top: 1px solid #eee; }

.repo-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  color: #1a1a1a;
  text-align: left;
  overflow-wrap: anywhere;
  background: transparent;
  border-radius: 0;
}

.repo-item[aria-pressed="true"] { background: #e7f1ff; font-weight: 600; }

.repo-empty { padding: 12px; color: #666; }

small { color: #666; }

h2 { margin: 0 0 8px; font-size: 1.15rem; }

.notice {
  padding: 8px 12px;
  background: #e7f1ff;
  border-radius: 6px;
}

button.full { width: 100%; margin-top: 12px; }

button {
  min-height: 44px; /* touch-friendly */
  padding: 10px 16px;
  font: inherit;
  color: #fff;
  background: #1f6feb;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
}

form button[type=submit] { width: 100%; margin-top: 16px; }
button:disabled { opacity: 0.6; cursor: default; }
button.secondary { color: #1a1a1a; background: #e8e8e8; }

.error {
  margin: 12px 0 0;
  padding: 8px 12px;
  color: #8a1f11;
  background: #fde8e6;
  border-radius: 6px;
}

.error p { margin: 0 0 8px; }

.muted { color: #666; }

a { color: #1f6feb; }

.nav { display: flex; align-items: center; gap: 12px; }

/* Links that look like the primary button */
a.button {
  display: block;
  min-height: 44px;
  padding: 10px 16px;
  color: #fff;
  background: #1f6feb;
  border-radius: 6px;
  text-align: center;
  text-decoration: none;
}

a.button.full { margin: 8px 0 16px; }

.post-list { margin: 0; padding: 0; list-style: none; }

.post-list li {
  background: #fff;
  border: 1px solid #e2e2e2;
  border-radius: 8px;
  margin-bottom: 8px;
}

/* Whole row is the tap target */
.post-list a {
  display: inline-block;
  min-height: 44px;
  padding: 10px 14px;
  overflow-wrap: anywhere;
  text-decoration: none;
}

.tag {
  margin-left: 4px;
  padding: 2px 8px;
  font-size: 0.8rem;
  color: #555;
  background: #eee;
  border-radius: 999px;
}

label.check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-height: 44px;
  margin: 8px 0;
  padding: 6px 0;
  font-weight: normal;
}

label.check input { width: 22px; height: 22px; margin-top: 1px; flex: none; }

code { padding: 1px 4px; background: #eee; border-radius: 4px; }

/* ----- editor ----- */

textarea {
  display: block;
  width: 100%;
  padding: 10px 12px;
  font: inherit;
  font-size: 16px;
  border: 1px solid #bbb;
  border-radius: 6px;
  resize: vertical;
}

textarea.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 16px; /* 16px stops iOS from zooming on focus */
  line-height: 1.45;
}

#body { min-height: 50vh; }

details { margin: 12px 0; }
summary { min-height: 44px; padding: 10px 0; cursor: pointer; }

.preview {
  min-height: 50vh;
  padding: 12px 16px;
  overflow-wrap: anywhere;
  background: #fff;
  border: 1px solid #e2e2e2;
  border-radius: 6px;
}

.preview img { max-width: 100%; height: auto; }
.preview pre { padding: 12px; overflow-x: auto; background: #f1f1f1; border-radius: 6px; }
.preview blockquote { margin: 0 0 1em; padding-left: 12px; color: #555; border-left: 3px solid #ccc; }

/* Toolbar stays reachable above the on-screen keyboard / at the bottom of long posts */
.toolbar {
  position: sticky;
  bottom: 0;
  display: flex;
  gap: 8px;
  margin: 12px -16px 0;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  background: #fafafa;
  border-top: 1px solid #e2e2e2;
}

.toolbar button { flex: 1; }

/* ----- small screens / notches ----- */

#app {
  padding-left: max(16px, env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right));
}

@media (max-width: 480px) {
  h1 { font-size: 1.4rem; }
  .topbar { flex-wrap: wrap; }
  .card { padding: 12px; }
}

@media (min-width: 720px) {
  .toolbar { margin-left: 0; margin-right: 0; padding-left: 0; padding-right: 0; }
}
