:root {
  --green-900: #0e3d26;
  --green-700: #145c37;
  --green-600: #1e7145;
  --green-500: #278a56;
  --green-100: #e4f3ea;
  --amber-500: #f2a71b;
  --amber-600: #d8900e;
  --red-500: #d64545;
  --red-100: #fbe7e7;
  --ink-900: #16211b;
  --ink-700: #3c4a41;
  --ink-500: #6b7a70;
  --line: #dfe7e1;
  --paper: #ffffff;
  --bg: #f4f7f5;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 40, 30, 0.06), 0 4px 14px rgba(20, 40, 30, 0.06);
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink-900);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body {
  min-height: 100dvh;
  padding-bottom: env(safe-area-inset-bottom);
}

h1, h2, h3 { line-height: 1.25; margin: 0 0 4px; }
p { margin: 0 0 8px; }

button, input, select {
  font: inherit;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--green-600);
  color: #fff;
  padding: calc(env(safe-area-inset-top) + 12px) 16px 12px;
  box-shadow: var(--shadow);
}

.app-header__row {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 720px;
  margin: 0 auto;
}

.app-header__back {
  background: rgba(255,255,255,0.15);
  border: none;
  color: #fff;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  font-size: 18px;
  display: none;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.app-header__back.is-visible { display: flex; }

.app-header__titles { flex: 1; min-width: 0; }
.app-header__titles h1 {
  font-size: 17px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.app-header__titles small {
  display: block;
  font-size: 12px;
  opacity: 0.85;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.install-btn {
  background: var(--amber-500);
  color: var(--green-900);
  border: none;
  font-weight: 700;
  font-size: 12.5px;
  padding: 8px 10px;
  border-radius: 10px;
  display: none;
  flex-shrink: 0;
}
.install-btn.is-visible { display: inline-flex; align-items: center; gap: 4px; }

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

.view { display: none; }
.view.is-active { display: block; }

.card {
  background: var(--paper);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 14px;
  border: 1px solid var(--line);
}

.lede {
  color: var(--ink-500);
  font-size: 14px;
}

.privacy-note {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  background: var(--green-100);
  border: 1px solid #c7e4d4;
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 13px;
  color: var(--green-700);
  margin-bottom: 14px;
}
.privacy-note svg { flex-shrink: 0; margin-top: 1px; }

.ios-hint {
  background: #fff7e6;
  border: 1px solid #f2d99a;
  color: #7a5b0a;
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 13px;
  margin-bottom: 14px;
  display: none;
}
.ios-hint.is-visible { display: block; }

.btn {
  appearance: none;
  border: none;
  border-radius: 12px;
  padding: 13px 18px;
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  touch-action: manipulation;
}
.btn-primary { background: var(--green-600); color: #fff; }
.btn-primary:active { background: var(--green-700); }
.btn-secondary { background: var(--green-100); color: var(--green-700); }
.btn-amber { background: var(--amber-500); color: var(--green-900); }
.btn-ghost { background: transparent; color: var(--ink-500); }
.btn-danger { background: var(--red-100); color: var(--red-500); }
.btn-block { width: 100%; }
.btn[disabled] { opacity: 0.45; pointer-events: none; }

.btn-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.btn-row .btn { flex: 1; min-width: 140px; }

.field { margin-bottom: 16px; }
.field label {
  display: block;
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 6px;
}
.field .hint {
  font-size: 12.5px;
  color: var(--ink-500);
  margin-top: 5px;
}
.field input[type="text"] {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  font-size: 16px;
  background: var(--paper);
}
.field input[type="text"]:focus {
  outline: none;
  border-color: var(--green-500);
}

.file-drop {
  border: 2px dashed var(--line);
  border-radius: 12px;
  padding: 22px 14px;
  text-align: center;
  color: var(--ink-500);
  position: relative;
  background: #fbfdfc;
}
.file-drop.has-file { border-color: var(--green-500); background: var(--green-100); color: var(--green-700); }
.file-drop input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
}
.file-drop__icon { font-size: 26px; display: block; margin-bottom: 6px; }
.file-drop strong { color: var(--ink-900); }
.file-drop.has-file strong { color: var(--green-700); }

.empty-state {
  text-align: center;
  padding: 40px 16px;
  color: var(--ink-500);
}
.empty-state__icon { font-size: 40px; margin-bottom: 10px; }

.project-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 10px;
  cursor: pointer;
  box-shadow: var(--shadow);
}
.project-card__icon {
  width: 42px; height: 42px;
  border-radius: 10px;
  background: var(--green-100);
  color: var(--green-700);
  display: flex; align-items: center; justify-content: center;
  font-size: 19px;
  flex-shrink: 0;
}
.project-card__body { flex: 1; min-width: 0; }
.project-card__body h3 {
  font-size: 15.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.project-card__meta {
  font-size: 12.5px;
  color: var(--ink-500);
}
.project-card__chevron { color: var(--ink-500); flex-shrink: 0; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 700;
  padding: 4px 9px;
  border-radius: 999px;
  background: var(--green-100);
  color: var(--green-700);
}
.badge-amber { background: #fef2dc; color: var(--amber-600); }
.badge-red { background: var(--red-100); color: var(--red-500); }
.badge-muted { background: #eef1ef; color: var(--ink-500); }

.chip-list { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: block;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
  cursor: pointer;
  user-select: none;
}
.chip input { margin-right: 8px; }
.chip.is-checked { border-color: var(--green-500); background: var(--green-100); color: var(--green-700); font-weight: 700; }

.mode-options { display: flex; flex-direction: column; gap: 10px; }
.mode-option {
  display: block;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  cursor: pointer;
  user-select: none;
}
.mode-option input { margin-right: 8px; }
.mode-option strong { font-size: 14.5px; }
.mode-option .hint { margin-top: 4px; }
.mode-option.is-checked { border-color: var(--green-500); background: var(--green-100); }
.mode-option.is-checked strong { color: var(--green-700); }

.table-scroll {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  -webkit-overflow-scrolling: touch;
}
table { border-collapse: collapse; width: 100%; font-size: 13.5px; }
th, td {
  padding: 9px 11px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
thead th {
  background: #f1f5f2;
  position: sticky;
  top: 0;
  font-weight: 700;
  color: var(--ink-700);
}
tbody tr:last-child td { border-bottom: none; }

.cell-old { color: var(--red-500); text-decoration: line-through; }
.cell-new { color: var(--green-700); font-weight: 700; }
.cell-arrow { color: var(--ink-500); padding: 0 4px; }
.row-added td { background: #eefaf1; }
.row-removed td { background: var(--red-100); }

.summary-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}
.summary-tile {
  border-radius: 12px;
  padding: 12px;
  background: var(--paper);
  border: 1px solid var(--line);
  text-align: center;
}
.summary-tile strong { display: block; font-size: 22px; }
.summary-tile span { font-size: 12.5px; color: var(--ink-500); }
.summary-tile.added strong { color: var(--green-600); }
.summary-tile.removed strong { color: var(--red-500); }
.summary-tile.modified strong { color: var(--amber-600); }
.summary-tile.unchanged strong { color: var(--ink-500); }

.section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 700;
  margin: 18px 0 10px;
}

.warning-box {
  background: #fff7e6;
  border: 1px solid #f2d99a;
  color: #7a5b0a;
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 13.5px;
  margin-bottom: 14px;
}
.warning-box ul { margin: 6px 0 0; padding-left: 18px; }

.spinner {
  width: 18px; height: 18px;
  border: 2.5px solid rgba(255,255,255,0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.toast {
  position: fixed;
  left: 16px; right: 16px;
  bottom: calc(env(safe-area-inset-bottom) + 16px);
  background: var(--ink-900);
  color: #fff;
  padding: 13px 16px;
  border-radius: 12px;
  font-size: 14px;
  box-shadow: var(--shadow);
  z-index: 50;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  transform: translateY(8px);
  max-width: 500px;
  margin: 0 auto;
}
.toast.is-visible { opacity: 1; transform: translateY(0); }

.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(15, 25, 20, 0.45);
  display: none;
  align-items: flex-end;
  justify-content: center;
  z-index: 60;
  padding: 16px;
}
.modal-backdrop.is-visible { display: flex; }
.modal {
  background: var(--paper);
  border-radius: 16px;
  padding: 20px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow);
}
.modal h3 { font-size: 16px; margin-bottom: 8px; }
.modal p { font-size: 14px; color: var(--ink-700); margin-bottom: 16px; }

.app-footer {
  padding: 24px 16px calc(env(safe-area-inset-bottom) + 24px);
}
.app-footer__row {
  max-width: 720px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  text-align: center;
}
.app-footer__links {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  font-size: 13px;
}
.app-footer__links a {
  color: var(--ink-500);
  text-decoration: none;
}
.app-footer__links a:hover { color: var(--green-700); text-decoration: underline; }
.app-footer__links .kofi-link {
  color: var(--amber-600);
  font-weight: 700;
}
.lang-switch {
  display: inline-flex;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  padding: 3px;
  gap: 2px;
}
.lang-switch button {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--ink-500);
  font-size: 12px;
  font-weight: 700;
  padding: 5px 12px;
  border-radius: 999px;
  cursor: pointer;
}
.lang-switch button.is-active {
  background: var(--green-600);
  color: #fff;
}

@media (min-width: 560px) {
  .summary-grid { grid-template-columns: repeat(4, 1fr); }
}

/* Beyond phone widths, let the app actually use the screen instead of
   staying pinned to a phone-sized column. */
@media (min-width: 720px) {
  main, .app-header__row { max-width: 92vw; }
  #projectList { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; align-items: start; }
  #projectList .project-card { margin-bottom: 0; }
}

@media (min-width: 1000px) {
  main, .app-header__row { max-width: 1100px; }
  main { padding: 24px; }
}

@media (min-width: 1400px) {
  main, .app-header__row { max-width: 1320px; }
}
