/* ===== ธีมพื้นฐานระบบ Flip-Book ===== */
:root {
  --bg: #0f1220;
  --bg-soft: #171a2b;
  --card: #1e2138;
  --line: #2a2f4a;
  --text: #eef1ff;
  --muted: #9aa3c7;
  --brand: #6c8cff;
  --brand-2: #b06cff;
  --danger: #ff5d6c;
  --ok: #3ddc97;
  --radius: 14px;
  --shadow: 0 10px 40px rgba(0,0,0,.35);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Sarabun", "Segoe UI", system-ui, -apple-system, sans-serif;
  background: radial-gradient(1200px 600px at 20% -10%, #232743 0, transparent 60%), var(--bg);
  background-color: var(--bg);
  color: var(--text);
  min-height: 100vh;
}
a { color: var(--brand); text-decoration: none; }
.container { max-width: 1180px; margin: 0 auto; padding: 24px; }

/* Topbar */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 24px; border-bottom: 1px solid var(--line);
  background: rgba(20,22,40,.6); backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 12px; font-weight: 800; font-size: 20px; }
.brand .logo {
  width: 34px; height: 34px; border-radius: 9px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  display: grid; place-items: center; font-size: 18px;
}

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
  border: 1px solid var(--line); background: var(--card); color: var(--text);
  padding: 10px 16px; border-radius: 10px; font-size: 14px; font-weight: 600;
  transition: .15s; font-family: inherit;
}
.btn:hover { border-color: var(--brand); transform: translateY(-1px); }
.btn-primary { background: linear-gradient(135deg, var(--brand), var(--brand-2)); border: none; color: #fff; }
.btn-danger { border-color: var(--danger); color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-ghost { background: transparent; }
.btn-sm { padding: 6px 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* Grid of books */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 22px; }
.book-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; transition: .18s; box-shadow: var(--shadow);
}
.book-card:hover { transform: translateY(-4px); border-color: var(--brand); }
.book-cover {
  aspect-ratio: 3/4; display: grid; place-items: center; position: relative;
  color: #fff; text-align: center; padding: 20px;
}
.book-cover h3 { margin: 0; font-size: 18px; text-shadow: 0 2px 8px rgba(0,0,0,.4); }
.book-cover .spine { position: absolute; left: 0; top: 0; bottom: 0; width: 10px; background: rgba(0,0,0,.25); }
.book-body { padding: 14px 16px; }
.book-body .title { font-weight: 700; margin: 0 0 4px; }
.book-body .meta { color: var(--muted); font-size: 12.5px; display: flex; gap: 12px; }

.empty {
  text-align: center; color: var(--muted); padding: 80px 20px;
  border: 1px dashed var(--line); border-radius: var(--radius);
}

/* Forms / inputs */
label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 6px; }
input[type=text], input[type=password], input[type=file], textarea, select {
  width: 100%; padding: 11px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--bg-soft); color: var(--text);
  font-family: inherit; font-size: 14px;
}
input[type=color] { width: 52px; height: 40px; padding: 2px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg-soft); }
textarea { resize: vertical; min-height: 70px; }
.row { display: flex; gap: 14px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 160px; }
.switch { display: inline-flex; align-items: center; gap: 8px; color: var(--text); }

/* Toast */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--card); border: 1px solid var(--line); padding: 12px 18px;
  border-radius: 10px; box-shadow: var(--shadow); z-index: 100; opacity: 0;
  transition: .25s; pointer-events: none;
}
.toast.show { opacity: 1; bottom: 34px; }
.toast.ok { border-color: var(--ok); }
.toast.err { border-color: var(--danger); }

/* Modal */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.6); backdrop-filter: blur(4px);
  display: none; place-items: center; z-index: 50; padding: 20px;
}
.modal-backdrop.show { display: grid; }
.modal {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  width: min(560px, 100%); padding: 24px; box-shadow: var(--shadow);
  max-height: 90vh; overflow: auto;
}
.modal h2 { margin-top: 0; }
