/* =========================
   GLOBAL
========================= */
* {
  box-sizing: border-box;
}

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

  overscroll-behavior: none;
  touch-action: manipulation;
}

.hidden {
  display: none;
}

/* =========================
   HEADER
========================= */
.app-header {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1rem;
  border-bottom: 1px solid #ddd;
  background: #faf9f6;
  text-align: center;
}

.app-header h1 {
  font-size: 1.35rem;
  font-weight: 600;
  margin: 0;
  letter-spacing: 0.2px;
}

.app-header > div {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  width: 100%;
}

/* Controls */
button,
select,
input[type="search"] {
  font-size: 0.9rem;
  padding: 0.55rem 0.75rem;
  border-radius: 12px;
  border: 1px solid #ddd;
  background: #f5f5f5;
}

button {
  cursor: pointer;
}

button:hover {
  background: #ededed;
}

#addCoinBtn {
  background: #222;
  color: #fff;
  border: none;
  font-weight: 600;
}

#addCoinBtn:hover {
  background: #000;
}

/* Search */
#searchInput {
  grid-column: 1 / -1;
  background: #fff;
}

#searchInput:focus {
  outline: none;
  border-color: #bbb;
}

/* Desktop header */
@media (min-width: 600px) {
  .app-header {
    flex-direction: row;
    align-items: center;
    text-align: left;
    justify-content: space-between;
  }

  .app-header > div {
    display: flex;
    width: auto;
  }

.app-subtitle {
  font-size: 0.8rem;
  color: #777;
  margin: 0.2rem 0 0;
}
}

/* =========================
   GALLERY
========================= */
.gallery {
  padding: 0.75rem;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.75rem;
}

.coin-tile {
  background: #faf9f6;
  border: 1px solid #ddd;
  padding: 0.4rem;
  border-radius: 6px;
  cursor: pointer;
}

.coin-tile img {
  width: 100%;
  display: block;
  border-radius: 4px;
  touch-action: pan-y;
}

/* =========================
   GALLERY LABELS
========================= */
.coin-label {
  margin-top: 0.4rem;
  text-align: center;
  font-size: 0.8rem;
  line-height: 1.2;
}

.coin-emperor {
  font-weight: 600;
}

.coin-reign {
  color: #666;
  font-size: 0.75rem;
}

/* =========================
   EMPTY STATE
========================= */
.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 3rem 1rem;
  color: #666;
  margin-top: 2rem;
}

.empty-state p {
  font-size: 0.95rem;
  margin-bottom: 0.75rem;
}

.empty-state button {
  border-radius: 999px;
  padding: 0.5rem 1rem;
}
.empty-title {
  font-size: 1rem;
  font-weight: 500;
}

.empty-sub {
  font-size: 0.85rem;
  color: #777;
}
/* =========================
   MODALS
========================= */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
  touch-action: none;
}

.modal.hidden {
  display: none !important;
}

.modal-content {
  background: #fff;
  width: 94%;
  max-width: 400px;
  max-height: 85vh;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 1rem;
  border-radius: 8px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* =========================
   FORM
========================= */
.form-group {
  margin-top: 1rem;
}

.form-group label {
  display: block;
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #555;
  margin-bottom: 0.3rem;
}

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 0.5rem;
  font-size: 0.9rem;
}

.image-preview {
  margin-top: 0.5rem;
  width: 100%;
  max-height: 200px;
  object-fit: contain;
  border: 1px solid #ddd;
  background: #faf9f6;
}

/* =========================
   DETAIL VIEW
========================= */
.coin-images {
  margin-bottom: 0.5rem;
}

.coin-image-block {
  margin-bottom: 1rem;
}

.coin-image-label {
  display: block;
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #666;
  margin-bottom: 0.25rem;
}

.coin-images img {
  width: 100%;
  border: 1px solid #ddd;
  background: #faf9f6;
  touch-action: pan-y;
}

.coin-meta {
  font-size: 0.9rem;
  line-height: 1.45;
}

.coin-meta p {
  margin: 0.5rem 0;
}

.coin-meta strong {
  font-weight: 600;
}

/* =========================
   ACTION BUTTONS
========================= */
.save-btn {
  margin-top: 1.2rem;
  width: 100%;
  padding: 0.7rem;
  font-size: 0.95rem;
}

.save-btn:disabled {
  opacity: 0.5;
}

.detail-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 1.2rem;
}

.detail-actions button {
  flex: 1;
  padding: 0.7rem;
  font-size: 0.9rem;
}

.danger {
  background: #b00020;
  color: #fff;
}

/* =========================
   SUPPORT SECTION
========================= */
.support-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 3rem 0 2rem;
}

.support-text {
  font-size: 0.8rem;
  color: #777;
  text-align: center;
  margin-bottom: 0.5rem;
}

.support-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.65rem 1.1rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 500;
  color: #444;
  text-decoration: none;
  background: #f1f1f1;
  border: 1px solid #ddd;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.support-btn:hover {
  background: #e8e8e8;
  border-color: #ccc;
}

.support-btn:active {
  background: #e0e0e0;
}
button,
.support-btn,
.coin-tile {
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

button:hover,
.support-btn:hover,
.coin-tile:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(0,0,0,0.08);
}

button:active,
.support-btn:active {
  transform: translateY(0);
  box-shadow: 0 2px 6px rgba(0,0,0,0.12);
}
/* =========================
   FIRST-RUN WELCOME
========================= */
.welcome-card {
  margin: 1rem;
  padding: 1rem;
  border-radius: 10px;
  background: #fff;
  border: 1px solid #ddd;
  box-shadow: 0 4px 10px rgba(0,0,0,0.04);
}

.welcome-card h2 {
  margin: 0 0 0.4rem 0;
  font-size: 1rem;
}

.welcome-card p {
  margin: 0 0 0.75rem 0;
  font-size: 0.85rem;
  color: #555;
  line-height: 1.4;
}

.welcome-card button {
  border-radius: 999px;
  padding: 0.45rem 0.9rem;
  font-size: 0.8rem;
  border: 1px solid #ddd;
  background: #f5f5f5;
}