:root {
  --bg: #16171c;
  --panel: #1e1f26;
  --panel-2: #26272f;
  --tile: #202128;
  --border: #33343d;
  --text: #e7e7ea;
  --text-dim: #8a8b96;
  --accent: #c6ff4d;      /* lime — add / positive action */
  --heat-cold: #4d7bff;   /* rarely used */
  --heat-hot: #ff5f7e;    /* frequently used */
  --danger: #ff5f7e;
  --radius: 10px;
  --font-display: 'Space Grotesk', sans-serif;
  --font-body: 'Inter', sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  min-height: 100vh;
}

.app {
  max-width: 1100px;
  margin: 0 auto;
  padding: 28px 24px 60px;
}

/* ---------- topbar ---------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-mark {
  color: var(--accent);
  font-size: 20px;
  transform: rotate(0deg);
}

.brand h1 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 20px;
  letter-spacing: -0.02em;
  margin: 0;
}

.add-form {
  flex: 1 1 320px;
  display: flex;
  gap: 8px;
}

.add-form input {
  flex: 1;
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 14px;
  font-family: var(--font-body);
  outline: none;
  transition: border-color .15s ease;
}

.add-form input:focus {
  border-color: var(--accent);
}

.add-form button {
  background: var(--accent);
  color: #12140a;
  border: none;
  padding: 10px 18px;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  font-family: var(--font-body);
  transition: transform .1s ease, filter .15s ease;
}

.add-form button:hover { filter: brightness(1.08); }
.add-form button:active { transform: scale(0.97); }

.controls {
  display: flex;
  gap: 8px;
}

.ghost-btn, .icon-btn {
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 13px;
  cursor: pointer;
  font-family: var(--font-body);
  white-space: nowrap;
  transition: color .15s ease, border-color .15s ease;
}

.ghost-btn:hover, .icon-btn:hover {
  color: var(--text);
  border-color: #4a4b56;
}

/* ---------- statusbar ---------- */

.statusbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  font-size: 12px;
  color: var(--text-dim);
}

.limit-meter {
  flex: 1;
  height: 4px;
  background: var(--panel-2);
  border-radius: 2px;
  overflow: hidden;
}

.limit-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--heat-cold), var(--heat-hot));
  transition: width .25s ease;
}

/* ---------- grid ---------- */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}

.tile {
  position: relative;
  aspect-ratio: 1 / 1;
  background: var(--tile);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  border: 1px solid var(--border);
  transition: transform .12s ease, border-color .12s ease;
}

.tile:hover {
  transform: translateY(-2px);
  border-color: #52535e;
}

.tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.tile-badge {
  position: absolute;
  bottom: 6px;
  left: 6px;
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(10, 10, 12, 0.72);
  backdrop-filter: blur(2px);
  padding: 3px 7px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  font-family: var(--font-display);
}

.heat-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.tile-delete {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(10, 10, 12, 0.72);
  color: var(--text-dim);
  border: none;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition: opacity .12s ease, color .12s ease, background .12s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tile:hover .tile-delete { opacity: 1; }
.tile-delete:hover { color: var(--danger); background: rgba(10,10,12,0.9); }

.tile-broken {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-dim);
  font-size: 11px;
  text-align: center;
  padding: 10px;
}

/* ---------- empty state ---------- */

.empty-state {
  display: none;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 90px 20px;
  color: var(--text-dim);
}

.empty-state.visible { display: flex; }

.empty-glyph {
  font-size: 34px;
  color: var(--accent);
  margin-bottom: 14px;
}

.empty-state p { margin: 4px 0; font-size: 14px; }
.empty-sub { font-size: 12.5px; line-height: 1.6; }

/* ---------- overlay / panel ---------- */

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(8, 8, 10, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
}

.overlay.hidden { display: none; }

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 22px;
  width: 340px;
  max-width: 90vw;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.panel-head h2 {
  font-family: var(--font-display);
  font-size: 16px;
  margin: 0;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
  font-size: 13px;
}

.field input {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 14px;
  outline: none;
}

.field input:focus { border-color: var(--accent); }

.hint { color: var(--text-dim); font-size: 11px; }

.panel-actions {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.secondary-btn {
  flex: 1;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px;
  border-radius: 8px;
  font-size: 12.5px;
  cursor: pointer;
}

.secondary-btn:hover { border-color: #52535e; }

.danger-btn {
  flex: 1;
  background: transparent;
  border: 1px solid rgba(255, 95, 126, 0.4);
  color: var(--danger);
  padding: 9px;
  border-radius: 8px;
  font-size: 12.5px;
  cursor: pointer;
}

.danger-btn:hover { background: rgba(255, 95, 126, 0.08); }

.footnote {
  font-size: 11px;
  color: var(--text-dim);
  line-height: 1.5;
  margin: 10px 0 0;
}

/* ---------- toast ---------- */

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 18px;
  border-radius: 30px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
  z-index: 30;
}

.toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (max-width: 560px) {
  .topbar { flex-direction: column; align-items: stretch; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
}
