/* ── Reset ────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── Base ─────────────────────────────────────────────────────────────────── */
body {
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: #222;
  background: #f5f5f5;
  min-height: 100vh;
}

/* ── Layout ───────────────────────────────────────────────────────────────── */
header {
  background: #1a1a2e;
  color: #fff;
  padding: 0.75rem 2rem;
  display: flex;
  align-items: center;
  gap: 2rem;
}

header h1 {
  font-size: 1.3rem;
  white-space: nowrap;
}

nav { display: flex; gap: 0.25rem; flex-wrap: wrap; }
nav a {
  color: #aac4ff;
  text-decoration: none;
  padding: 0.4rem 0.75rem;
  border-radius: 4px;
  transition: background 0.15s;
  font-size: 0.9rem;
}
nav a:hover    { background: rgba(255,255,255,0.1); color: #fff; }
nav a.active   { background: rgba(255,255,255,0.2); color: #fff; font-weight: 600; }

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem 2rem;
}

.page-title {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 1.25rem;
  color: #111;
}

/* ── Cards ────────────────────────────────────────────────────────────────── */
.card {
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.25rem;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
}

.card h2 { font-size: 1.05rem; margin-bottom: 0.9rem; color: #333; }

/* ── Forms ────────────────────────────────────────────────────────────────── */
.form-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: flex-end;
  margin-bottom: 0.75rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}
.form-group label { font-size: 0.82rem; color: #555; font-weight: 500; }

input[type=text], input[type=number], input[type=search],
select, textarea {
  padding: 0.45rem 0.7rem;
  border: 1px solid #ccc;
  border-radius: 5px;
  font-size: 0.9rem;
  font-family: inherit;
  background: #fff;
  outline: none;
  transition: border-color 0.15s;
}
input:focus, select:focus, textarea:focus { border-color: #4a7fff; }

textarea { resize: vertical; min-height: 60px; }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
button, .btn {
  padding: 0.45rem 1.1rem;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  font-size: 0.9rem;
  font-family: inherit;
  font-weight: 500;
  transition: filter 0.15s, opacity 0.15s;
}
button:disabled { opacity: 0.55; cursor: not-allowed; }
button:not(:disabled):hover { filter: brightness(0.93); }

.btn-primary { background: #3a6fff; color: #fff; }
.btn-danger  { background: #e53935; color: #fff; }
.btn-secondary { background: #e0e0e0; color: #333; }

.btn-small {
  padding: 0.25rem 0.55rem;
  font-size: 0.8rem;
  border-radius: 4px;
  background: #e0e0e0;
  color: #333;
  border: none;
  cursor: pointer;
}
.btn-small.btn-danger { background: #ffebee; color: #c62828; }
.btn-small.btn-danger:hover { background: #e53935; color: #fff; }

/* ── Tables ───────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}
th {
  background: #f0f0f0;
  text-align: left;
  padding: 0.5rem 0.75rem;
  font-weight: 600;
  color: #444;
  border-bottom: 2px solid #ddd;
}
td {
  padding: 0.45rem 0.75rem;
  border-bottom: 1px solid #eee;
  vertical-align: middle;
}
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: #f5f9ff; }

.empty { color: #999; text-align: center; padding: 1.5rem; }
.mono  { font-family: monospace; font-size: 0.82rem; color: #555; }

.actions { display: flex; gap: 0.4rem; align-items: center; }
.col-select { font-size: 0.8rem; max-width: 160px; }

/* ── Status messages ──────────────────────────────────────────────────────── */
.status {
  margin-top: 0.75rem;
  padding: 0.55rem 0.9rem;
  border-radius: 5px;
  font-size: 0.9rem;
}
.status.success { background: #e8f5e9; color: #2e7d32; border: 1px solid #a5d6a7; }
.status.error   { background: #ffebee; color: #c62828; border: 1px solid #ef9a9a; }

/* ── Generate page ────────────────────────────────────────────────────────── */
.generate-grid {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 1.5rem;
  align-items: start;
}
@media (max-width: 720px) {
  .generate-grid { grid-template-columns: 1fr; }
}

#preview-canvas { border: 1px solid #ccc; border-radius: 4px; display: block; }

.clues-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-top: 0.75rem;
}
@media (max-width: 600px) {
  .clues-layout { grid-template-columns: 1fr; }
}
.clues-list { padding-left: 1.2rem; font-size: 0.85rem; }
.clues-list li { margin-bottom: 0.25rem; }

/* ── Pagination ───────────────────────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 1rem;
  font-size: 0.88rem;
  color: #555;
}

/* ── Detail section ───────────────────────────────────────────────────────── */
.detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}
.detail-header h3 { font-size: 1rem; }
