/* FamilyDash admin — vanilla CSS, no framework, no build step.
   Palette echoes the app's Moon Garden theme. */

:root {
  --deep:    #0d1a15;
  --mid:     #14261f;
  --raised:  #1b3229;
  --line:    #2c4a3d;
  --ink:     #eef3ef;
  --sage:    #9db8a8;
  --moon:    #f2ecd9;
  --gold:    #e6c06a;
  --rose:    #e08f8f;
  --leaf:    #7fb894;
  --radius:  12px;
}

* { box-sizing: border-box; }

/* Must outrank the layout rules below. The UA's `[hidden] { display: none }`
   loses to any class selector that sets display — `.signin { display: grid }`
   kept the sign-in panel on screen and pushed the whole admin UI below the
   fold, which looked exactly like a failed sign-in. */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--deep);
  color: var(--ink);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

h1 { margin: 0 0 4px; font-size: 24px; font-weight: 600; }
.muted { color: var(--sage); font-size: 13px; }
.spacer { flex: 1; }

/* --- sign in ---------------------------------------------------------- */
.signin {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.signin .card {
  width: min(360px, 100%);
  background: var(--mid);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px;
  display: flex;
  flex-direction: column;
}
.signin label { margin-top: 14px; font-size: 13px; color: var(--sage); }
.signin #signin-button { margin-top: 20px; }

.google {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 20px;
  padding: 11px 16px;
  background: #fff;
  border-color: #dadce0;
  color: #1f1f1f;
  font-weight: 600;
}
.google:hover { background: #f4f4f4; }

/* "or" rule: a line either side of the label. */
.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 22px 0 2px;
  color: var(--sage);
  font-size: 12px;
}
.divider::before, .divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

/* --- chrome ----------------------------------------------------------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  background: var(--mid);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 600; }
.household {
  padding: 2px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 13px;
  color: var(--sage);
}

.tabs {
  display: flex;
  gap: 4px;
  padding: 12px 20px 0;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
}
.tab {
  background: none;
  border: 1px solid transparent;
  border-bottom: none;
  color: var(--sage);
  padding: 9px 18px;
  border-radius: var(--radius) var(--radius) 0 0;
  cursor: pointer;
  font: inherit;
  white-space: nowrap;
}
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] {
  background: var(--raised);
  border-color: var(--line);
  color: var(--ink);
  margin-bottom: -1px;
}

.content { padding: 24px 20px 64px; max-width: 1100px; margin: 0 auto; }

/* --- forms ------------------------------------------------------------ */
.row-form {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
  background: var(--mid);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 20px;
}
.row-form.stacked { align-items: flex-start; }
.row-form label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 12px;
  color: var(--sage);
}
.row-form label.wide { flex: 1 1 100%; }

input, select, textarea {
  background: var(--deep);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  padding: 8px 10px;
  font: inherit;
  min-width: 0;
}
textarea { resize: vertical; width: 100%; }
input[type="color"] { padding: 2px; width: 52px; height: 38px; cursor: pointer; }
input[type="number"] { width: 92px; }
input:focus, select:focus, textarea:focus, button:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 1px;
}

button {
  border-radius: 8px;
  padding: 9px 16px;
  font: inherit;
  cursor: pointer;
  border: 1px solid var(--line);
}
button:disabled { opacity: .55; cursor: default; }
.primary { background: var(--gold); border-color: var(--gold); color: #23201a; font-weight: 600; }
.ghost { background: transparent; color: var(--sage); }
.ghost:hover:not(:disabled) { color: var(--ink); }
.danger { background: transparent; border-color: transparent; color: var(--rose); padding: 5px 9px; }
.link { background: none; border: none; color: var(--sage); padding: 5px 9px; text-decoration: underline; }
.link:hover { color: var(--ink); }

/* --- tables ----------------------------------------------------------- */
table {
  width: 100%;
  border-collapse: collapse;
  background: var(--mid);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
th, td {
  text-align: left;
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--sage); font-weight: 600; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--raised); }
td.actions, th.actions { text-align: right; white-space: nowrap; width: 1%; }
td.empty { color: var(--sage); text-align: center; padding: 28px; }
.swatch { width: 18px; height: 18px; border-radius: 50%; display: inline-block; border: 1px solid var(--line); }
.pill {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  border: 1px solid var(--line);
  font-size: 12px;
  color: var(--sage);
}
.pill.on { color: var(--leaf); border-color: var(--leaf); }
.clip { max-width: 46ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }

/* --- messages --------------------------------------------------------- */
.error { color: var(--rose); font-size: 13px; margin: 8px 0 0; }
.banner {
  margin: 0;
  padding: 11px 20px;
  background: #3a1f1f;
  border-bottom: 1px solid var(--rose);
}

@media (max-width: 620px) {
  .row-form label { flex: 1 1 100%; }
  .clip { max-width: 22ch; }
  .topbar .muted { display: none; }
}

/* --- API tokens -------------------------------------------------------- */
.lede {
  margin: 0 0 18px;
  color: var(--sage);
  font-size: 13px;
  max-width: 70ch;
}
.speclink { color: var(--gold); white-space: nowrap; }

/* The one moment the plaintext token exists in the UI. */
.reveal {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 18px;
  padding: 14px 16px;
  border: 1px solid var(--gold);
  border-radius: var(--radius);
  background: rgba(230, 192, 106, .08);
}
.reveal code {
  flex: 1 1 320px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  word-break: break-all;
  color: var(--ink);
}
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; color: var(--sage); }
.pill.off { color: var(--rose); border-color: var(--rose); }

/* --- dashboard layout editor ------------------------------------------ */
.layout-wrap { display: flex; gap: 24px; align-items: flex-start; flex-wrap: wrap; }

.layout-grid {
  --cell: 44px;
  position: relative;
  width: calc(var(--cell) * 12);
  height: calc(var(--cell) * 9);
  background-color: var(--mid);
  background-image:
    linear-gradient(to right, var(--line) 1px, transparent 1px),
    linear-gradient(to bottom, var(--line) 1px, transparent 1px);
  background-size: var(--cell) var(--cell);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  user-select: none;
  touch-action: none;   /* pointer events own the gestures */
  flex: none;
}

.layout-tile {
  position: absolute;
  box-sizing: border-box;
  border: 1px solid var(--gold);
  border-radius: 6px;
  background: rgba(230, 192, 106, .14);
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  padding: 6px 8px;
  cursor: grab;
  overflow: hidden;
}
.layout-tile.dragging { cursor: grabbing; background: rgba(230, 192, 106, .26); }
.layout-tile .size { display: block; font-weight: 400; font-size: 11px; color: var(--sage); }
.layout-tile .remove {
  position: absolute; top: 2px; right: 4px;
  background: none; border: none; color: var(--sage); font-size: 14px; line-height: 1; padding: 2px 4px; cursor: pointer;
}
.layout-tile .remove:hover { color: var(--rose); }
.layout-tile .share {
  position: absolute; top: 2px; right: 22px;
  background: none; border: none; color: var(--sage); font-size: 14px; line-height: 1; padding: 2px 4px; cursor: pointer;
}
.layout-tile .share:hover { color: var(--gold); }
.layout-tile.shared { border-style: dashed; }
.layout-tile.selected { box-shadow: 0 0 0 2px var(--gold) inset; }
.layout-tile .label { display: block; padding-right: 30px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.layout-area { margin-bottom: 18px; }
.layout-area .chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.layout-area .chip {
  display: inline-flex; align-items: center; gap: 4px;
  border: 1px solid var(--gold); border-radius: 999px; padding: 3px 6px 3px 10px;
  font-size: 12px; font-weight: 600; background: rgba(230, 192, 106, .14);
}
.layout-area .chip button { background: none; border: none; color: var(--sage); font-size: 14px; line-height: 1; padding: 0 2px; cursor: pointer; }
.layout-area .chip button:hover { color: var(--rose); }
.layout-area .muted { margin: 0 0 8px; font-size: 12px; }

/* --- verse images ------------------------------------------------------ */
.thumb { width: 64px; height: 48px; object-fit: cover; border-radius: 6px; display: block; background: var(--mid); cursor: zoom-in; }

/* --- image drop zone ------------------------------------------------------ */
.field-label { display: block; font-size: 13px; color: var(--sage); margin-bottom: 6px; }
.dropzone {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 14px 16px; min-height: 64px;
  border: 1.5px dashed var(--line); border-radius: 8px; background: var(--mid);
  color: var(--ink); font-size: 14px; cursor: pointer; outline: none;
}
.dropzone:focus, .dropzone.over { border-color: var(--gold); background: rgba(230, 192, 106, .08); }
.dropzone .drop-text strong { color: var(--ink); }
.dropzone .link { padding: 0; font: inherit; color: var(--gold); background: none; border: none; cursor: pointer; text-decoration: underline; }
.drop-preview { width: 96px; height: 72px; object-fit: cover; border-radius: 6px; }

/* --- legal pages ---------------------------------------------------------- */
.legal { max-width: 760px; margin: 0 auto; padding: 48px 24px 80px; }
.legal h1 { font-size: 28px; margin: 0 0 4px; }
.legal h2 { font-size: 17px; margin: 32px 0 8px; color: var(--gold); }
.legal p, .legal li { line-height: 1.65; color: var(--ink); }
.legal ul { padding-left: 20px; }
.legal li { margin-bottom: 6px; }
.legal .updated { color: var(--sage); font-size: 13px; margin: 0 0 28px; }
.legal a { color: var(--gold); }
.legal .home { display: inline-block; margin-top: 40px; color: var(--sage); font-size: 14px; }

/* --- lightbox ------------------------------------------------------------ */
.lightbox {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  background: rgba(4, 12, 10, .88);
  cursor: zoom-out;
}
.lightbox img { max-width: 92vw; max-height: 92vh; border-radius: 10px; box-shadow: 0 20px 60px rgba(0, 0, 0, .6); }
.lightbox-close {
  position: absolute; top: 16px; right: 20px;
  background: none; border: none; color: var(--ink); font-size: 32px; line-height: 1; cursor: pointer;
}
.needs { color: var(--rose); font-size: 12px; font-weight: 600; }
.layout-tile .handle {
  position: absolute; right: 0; bottom: 0; width: 16px; height: 16px;
  cursor: nwse-resize;
  background: linear-gradient(135deg, transparent 50%, var(--gold) 50%);
  border-bottom-right-radius: 5px;
}

.layout-side { min-width: 220px; flex: 1 1 220px; }
.layout-side h3 { margin: 0 0 8px; font-size: 13px; color: var(--sage); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.layout-palette { display: flex; flex-wrap: wrap; gap: 8px; min-height: 38px; margin-bottom: 18px; }
.layout-palette .empty { color: var(--sage); font-size: 13px; }
.layout-actions { display: flex; gap: 10px; flex-wrap: wrap; }
