/* Pages around the builder: sign in, the project dashboard, account settings.
   Loaded after style.css, which has the shared buttons, fields, menus and dialogs. */

body.page {
  display: flex;
  flex-direction: column;
  min-height: 100%;
  height: auto;
  overflow: auto;
}
.page main { flex: 1 0 auto; width: 100%; }
.page h1 { font-size: 20px; margin: 0; letter-spacing: -0.01em; }
.page h2 { font-size: 14px; margin: 0; }
.page a { color: var(--blue-d); }

.page-top { position: sticky; top: 0; z-index: 50; background: rgba(255, 255, 255, 0.92); backdrop-filter: blur(6px); }
.page-top .brand > span:last-child { display: inline; }
.page-nav { display: flex; gap: 2px; margin-left: 12px; }
.page-nav a { color: var(--muted); text-decoration: none; padding: 6px 10px; border-radius: 8px; }
.page-nav a:hover { color: var(--ink); background: var(--soft); }
.page-nav a[aria-current="page"] { color: var(--ink); font-weight: 600; }

/* always on screen: stuck to the bottom of the window while the page scrolls */
.page-foot { flex: none; margin-top: 40px; position: sticky; bottom: 0; z-index: 60; }
.page-foot .credit { display: block; width: 100%; }
.auth-page .page-foot { position: fixed; left: 0; right: 0; bottom: 0; margin: 0; } /* so the form sits in the exact middle */

.btn.wide { width: 100%; padding: 9px 12px; }
.btn.link { border-color: transparent; background: none; color: var(--blue-d); padding-left: 4px; padding-right: 4px; }
.btn.link:hover:not(:disabled) { background: none; text-decoration: underline; border-color: transparent; }
a.btn { display: inline-block; text-decoration: none; color: inherit; }
a.btn.primary { color: #fff; }

.spinner {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--line);
  border-top-color: var(--blue);
  animation: spin 0.7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- sign in / create account ---------- */

/* one screen, nothing to scroll: the form in the middle, the credit along the bottom */
html:has(body.auth-page), body.auth-page { height: 100%; overflow: hidden; }
body.auth-page { min-height: 0; }
.auth { display: grid; place-items: center; padding: 16px; min-height: 0; overflow: hidden; }
.auth-box { width: 100%; max-width: 360px; display: flex; flex-direction: column; align-items: center; gap: 18px; }
.auth-box .brand > span:last-child { display: inline; }
.auth-card {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 24px 24px 20px;
  background: #fff;
  box-shadow: 0 12px 36px rgba(30, 40, 60, 0.07);
}
.auth-card h2 { font-size: 18px; margin: 0 0 4px; }
.auth-card .sub { color: var(--muted); margin: 0 0 18px; font-size: 12px; }
.auth-card .field input { padding: 9px 11px; }
.pw { position: relative; display: flex; }
.pw input { padding-right: 62px !important; }
.pw-toggle {
  position: absolute;
  right: 5px;
  top: 50%;
  transform: translateY(-50%);
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 11.5px;
  padding: 4px 6px;
  border-radius: 6px;
  cursor: pointer;
}
.pw-toggle:hover { color: var(--ink); background: var(--soft); }
.field-hint { font-size: 11.5px; color: var(--muted); margin: -6px 0 12px; }
.field-row { display: flex; justify-content: space-between; align-items: baseline; }
.field-row a, .field-row button { font-size: 11.5px; }
.form-error {
  color: var(--red);
  background: #fff3f3;
  border: 1px solid #f3c4c6;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 12px;
  margin: 0 0 12px;
}
.form-error:empty { display: none; }
.form-ok { color: #2f8a3a; background: #effaf0; border: 1px solid #c6e9c9; border-radius: 8px; padding: 8px 10px; font-size: 12px; margin: 0 0 12px; }
.form-ok:empty { display: none; }
.auth-switch { text-align: center; margin: 16px 0 0; color: var(--muted); font-size: 12px; }
.auth-privacy { font-size: 11px; color: var(--muted); text-align: center; margin: 10px 0 0; }

/* ---------- dashboard ---------- */

.dash { max-width: 1240px; margin: 0 auto; padding: 30px 32px 0; }
.dash-hello { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 26px; }
.dash-hello p { margin: 6px 0 0; color: var(--muted); }
.dash-section { margin-bottom: 34px; }
.dash-section > header { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.dash-section > header h2 { display: flex; align-items: center; gap: 8px; margin-right: auto; }
.dash-section > header .robot-pick { width: 300px; max-width: 100%; }
.dash-count { font-weight: 500; color: var(--muted); font-size: 12px; }
.dash-search {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 10px 7px 30px;
  background: var(--soft) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%238b93a3' stroke-width='2.2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-4-4'/%3E%3C/svg%3E") 10px 50% no-repeat;
  width: 240px;
  font-size: 12px;
}
.dash-search:focus { outline: none; border-color: var(--blue); background-color: #fff; }
.dash-sort { border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; background: #fff; font-size: 12px; }

.banner {
  display: flex;
  align-items: center;
  gap: 14px;
  border: 1px solid #b9d3ff;
  background: #f3f8ff;
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 26px;
}
.banner .mini-deck { width: 74px; flex: none; }
.banner p { margin: 0; flex: 1; }
.banner .btn { flex: none; }

.templates { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }
.template {
  display: flex;
  flex-direction: column;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  padding: 10px;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.12s, box-shadow 0.12s, transform 0.12s;
}
.template:hover { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(76, 151, 255, 0.15); }
.template:active { transform: translateY(1px); }
.template-pic { height: 92px; border-radius: 8px; background: var(--soft); display: grid; place-items: center; overflow: hidden; }
.template-pic .mini-deck { width: 96px; }
.template.blank .template-pic { border: 1px dashed #cdd3de; background: #fff; font-size: 28px; color: var(--blue); }
.template b { font-size: 12.5px; }
.template span { font-size: 11px; color: var(--muted); line-height: 1.4; }
.template:disabled { opacity: 0.6; cursor: progress; }

.project-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 18px; }
.card {
  position: relative;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  transition: border-color 0.12s, box-shadow 0.12s;
}
.card:hover { border-color: #cfd8e6; box-shadow: 0 10px 28px rgba(30, 40, 60, 0.08); }
.card:focus-within { border-color: var(--blue); }
.card-pic {
  display: grid;
  grid-template-columns: 1fr 112px;
  gap: 14px;
  align-items: center;
  height: 150px;
  padding: 16px 18px;
  background: var(--soft);
  border-bottom: 1px solid var(--line);
  border-radius: 14px 14px 0 0;
  text-decoration: none;
  overflow: hidden;
}
.card-pic .mini-deck { width: 112px; }
.card-body { padding: 12px 14px 12px; display: flex; flex-direction: column; gap: 7px; flex: 1; }
.card-title-row { display: flex; align-items: flex-start; gap: 6px; }
.card-title {
  flex: 1;
  min-width: 0;
  font-weight: 700;
  font-size: 13.5px;
  color: var(--ink) !important;
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.card-title::after { content: ""; position: absolute; inset: 0; border-radius: 14px; } /* the whole card opens it */
.card-more {
  position: relative;
  z-index: 2;
  border: 0;
  background: none;
  border-radius: 6px;
  width: 26px;
  height: 22px;
  margin: -2px -4px 0 0;
  cursor: pointer;
  color: var(--muted);
  font-size: 15px;
  line-height: 1;
}
.card-more:hover, .card-more[aria-expanded="true"] { background: var(--soft); color: var(--ink); }
.card-desc {
  margin: 0;
  font-size: 11.5px;
  color: #6b7385;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 2.9em;
}
.card-desc.none { color: #b4bac6; }
.card-liquids { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 11px; color: #5b6275; min-height: 16px; }
.card-liquids span { display: inline-flex; align-items: center; gap: 5px; }
.card-liquids i { width: 9px; height: 9px; border-radius: 50%; background: var(--l); }
.card-stats { display: flex; flex-wrap: wrap; gap: 4px; }
.stat { font-size: 10.5px; border-radius: 999px; padding: 2px 8px; background: var(--soft); border: 1px solid var(--line); color: #5b6275; white-space: nowrap; }
.stat.error { background: #fff3f3; border-color: #f3c4c6; color: var(--red); }
.stat.warning { background: #fff8eb; border-color: #f6dca8; color: #b7791f; }
.stat.ok { background: #effaf0; border-color: #c6e9c9; color: #2f8a3a; }
.card-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 11px; color: var(--muted); border-top: 1px solid var(--line); padding-top: 8px; margin-top: auto; }
.card-foot span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card.busy { opacity: 0.55; pointer-events: none; }
.menu .danger-item { color: var(--red); }
.menu .danger-item:hover { background: #fff3f3 !important; }

.dash-empty {
  border: 1px dashed #cdd3de;
  border-radius: 14px;
  padding: 44px 20px;
  text-align: center;
  color: var(--muted);
}
.dash-empty b { display: block; color: var(--ink); font-size: 14px; margin-bottom: 6px; }
.dash-loading { display: flex; align-items: center; gap: 10px; color: var(--muted); padding: 30px 0; }

/* small pictures: the deck and the script */
.mini-deck {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 3px;
  padding: 4px;
  border: 1px solid #dfe3ea;
  border-radius: 7px;
  background: #fff;
}
.mini-slot {
  aspect-ratio: 1.45;
  border-radius: 3px;
  border: 1px solid #e3e7ee;
  background: #fff;
  display: grid;
  place-items: center;
  overflow: hidden;
}
.mini-slot.empty { border-style: dashed; border-color: #e6e9f0; background: #fbfcfd; }
.mini-slot.trash { background: #f6f7f9; }
.mini-slot .mini { width: 88%; max-height: 88%; }
.mini-slot .mini circle, .mini-slot .mini rect { stroke-width: 2; }
.mini-slot .trash-icon svg { width: 13px; height: 13px; }

.mini-script { display: flex; flex-direction: column; gap: 3px; min-width: 0; align-self: center; }
.mini-script i { display: block; height: 9px; border-radius: 3px; background: var(--c); box-shadow: inset 0 -1px rgba(0, 0, 0, 0.12); }
.mini-script i.hat { width: 58%; height: 12px; border-radius: 9px 9px 3px 3px; margin-bottom: 1px; }
.mini-script span { font-size: 10px; color: var(--muted); margin-top: 2px; }

/* ---------- account settings ---------- */

.acct { max-width: 760px; margin: 0 auto; padding: 30px 32px 0; }
.acct-back { display: inline-block; font-size: 12px; margin-bottom: 14px; text-decoration: none; }
.acct-back:hover { text-decoration: underline; }
.acct-head { display: flex; align-items: center; gap: 16px; margin-bottom: 26px; }
.acct-head p { margin: 4px 0 0; color: var(--muted); }
.panel { border: 1px solid var(--line); border-radius: 14px; padding: 18px 20px; margin-bottom: 18px; background: #fff; }
.panel h2 { margin-bottom: 4px; }
.panel > p { margin: 0 0 14px; color: var(--muted); font-size: 12px; }
.panel form { max-width: 380px; }
.robot-options { display: grid; gap: 8px; margin-bottom: 12px; }
.robot-option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
}
.robot-option:has(input:checked) { border-color: #b9d3ff; background: #eef5ff; }
.robot-option input { margin: 3px 0 0; accent-color: var(--blue); }
.robot-option > span { display: flex; flex-direction: column; gap: 2px; }
.panel .row { display: flex; gap: 10px; align-items: center; justify-content: space-between; padding: 10px 0; border-top: 1px solid var(--line); }
.panel .row:first-of-type { border-top: 0; }
.panel .row p { margin: 0; }
.panel .row .small { display: block; }
.panel.danger { border-color: #f3c4c6; }
.panel.danger h2 { color: var(--red); }
.btn.danger-solid { background: var(--red); border-color: #c93a3f; color: #fff; font-weight: 600; }
.btn.danger-solid:hover:not(:disabled) { background: #d73e43; border-color: #c93a3f; }
.readonly { padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--soft); color: #5b6275; }

/* ---------- not found ---------- */

.notfound { display: grid; place-items: center; text-align: center; padding: 80px 20px; }
.notfound > div { display: flex; flex-direction: column; align-items: center; }
.notfound .logo { width: 48px; height: 48px; margin-bottom: 28px; }
.notfound p { color: var(--muted); }

/* ---------- narrower windows ---------- */

@media (max-width: 960px) {
  .dash, .acct { padding: 24px 16px 0; }
  .dash-search { width: 100%; order: 5; }
}
