/* Publist — Google Sheets-inspired skin */

:root {
  --bg: #ffffff;
  --chrome: #f8f9fa;
  --fg: #202124;
  --muted: #5f6368;
  --grid-line: #e2e3e3;
  --gutter-line: #c7cbd1;
  --blue: #1a73e8;
  --blue-soft: #e8f0fe;
  --green: #188038;
  --green-hover: #146c2e;
  --red: #d93025;
  --avail: #34a853;
  --hover: #f6f8fc;
  --chip-line: #dadce0;
  --menu-bg: #ffffff;
  --sel: rgba(26, 115, 232, 0.16);
  --tab-active-bg: #e6f4ea;
  --shadow: 0 2px 6px rgba(60, 64, 67, 0.15), 0 8px 24px rgba(60, 64, 67, 0.15);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #202124;
    --chrome: #2d2e31;
    --fg: #e8eaed;
    --muted: #9aa0a6;
    --grid-line: #3c4043;
    --gutter-line: #5f6368;
    --blue: #8ab4f8;
    --blue-soft: rgba(138, 180, 248, 0.16);
    --green: #81c995;
    --green-hover: #a8dab5;
    --red: #f28b82;
    --hover: #28292c;
    --chip-line: #5f6368;
    --menu-bg: #2d2e31;
    --sel: rgba(138, 180, 248, 0.22);
    --tab-active-bg: rgba(129, 201, 149, 0.18);
    --shadow: 0 2px 6px rgba(0, 0, 0, 0.5), 0 8px 24px rgba(0, 0, 0, 0.5);
  }
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }
body {
  font-family: Roboto, Arial, Helvetica, sans-serif;
  background: var(--bg);
  color: var(--fg);
  font-size: 13px;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}

/* Demo banner — unmissable on purpose */
.demo-banner {
  background: #feefc3;
  color: #202124;
  text-align: center;
  padding: 7px 16px;
  font-size: 13px;
  border-bottom: 1px solid #f2e0a4;
}
.demo-banner code { font-family: ui-monospace, "SF Mono", Menlo, monospace; }

/* ---------------------------------------------------------- document header */

.sheets-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px 4px;
  background: var(--bg);
}
.doc-icon { width: 26px; height: 34px; flex: none; }
.doc-meta { flex: 1; min-width: 0; }
.doc-title-row { display: flex; align-items: center; gap: 8px; }
.doc-title {
  font-family: "Google Sans", Roboto, Arial, sans-serif;
  font-size: 18px;
  font-weight: 400;
  letter-spacing: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Menu bar — pull left by the summary's padding so "File" aligns under "Publist" */
.menubar { display: flex; gap: 2px; margin-top: 2px; margin-left: -8px; }
.menu { position: relative; }
.menu summary {
  list-style: none;
  cursor: pointer;
  padding: 2px 8px;
  border-radius: 4px;
  color: var(--fg);
  user-select: none;
}
.menu summary::-webkit-details-marker { display: none; }
.menu summary:hover, .menu[open] summary { background: var(--hover); }
.menu-list {
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 30;
  min-width: 240px;
  background: var(--menu-bg);
  border-radius: 6px;
  box-shadow: var(--shadow);
  padding: 6px 0;
}
.menu-list button, .menu-list a {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  font: inherit;
  color: var(--fg);
  text-decoration: none;
  padding: 7px 16px;
  cursor: pointer;
  white-space: nowrap;
}
.menu-list button:hover, .menu-list a:hover { background: var(--hover); }
.menu-hint { color: var(--muted); }
.menu-info { padding: 7px 16px; color: var(--muted); font-size: 12px; white-space: nowrap; }

.header-actions { display: flex; align-items: center; gap: 12px; }

/* ---- account avatar + menu (top-right) ---- */
.account { position: relative; }
.account summary { list-style: none; cursor: pointer; }
.account summary::-webkit-details-marker { display: none; }
.account summary::marker { content: ""; }

.avatar-btn { display: inline-flex; position: relative; border-radius: 50%; }
.avatar-btn:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--avatar-bg, var(--blue));
  color: #fff;
  font-weight: 600;
  font-size: 14px;
  line-height: 1;
  user-select: none;
  transition: box-shadow 0.15s;
}
.avatar-btn:hover .avatar { box-shadow: 0 0 0 4px var(--hover); }
.avatar.lg { width: 44px; height: 44px; font-size: 17px; }

/* signed-out: solid grey account circle with a white silhouette (Google-style) */
.account:not(.signed-in) .avatar { background: var(--muted); color: var(--bg); }
.avatar-person { width: 24px; height: 24px; fill: currentColor; }
.avatar-initials { display: none; }
.account.signed-in .avatar-person { display: none; }
.account.signed-in .avatar-initials { display: inline; }

/* status light on the avatar: available = online (green), else offline (grey) */
.avatar-status {
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  border: 2px solid var(--bg);
  background: var(--muted);
}
.avatar-status.on { background: var(--avail); }
.avatar-status.off { background: var(--muted); }

.account-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 10px);
  min-width: 268px;
  background: var(--menu-bg);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 8px;
  z-index: 40;
}
.account-head { display: flex; gap: 12px; align-items: center; padding: 8px 10px 12px; }
.account-id { min-width: 0; }
.account-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.account-email { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.account-body { border-top: 1px solid var(--grid-line); padding-top: 6px; margin-top: 2px; }
/* show the right section for the current auth state */
.account:not(.signed-in) .account-head,
.account:not(.signed-in) .account-body { display: none; }
.account.signed-in .account-guest { display: none; }

.account-item, .status-switch {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border: none;
  border-radius: 8px;
  background: none;
  font: inherit;
  color: var(--fg);
  cursor: pointer;
  text-align: left;
}
.account-item:hover, .status-switch:hover { background: var(--hover); }
.status-switch .status-text { flex: 1; }
.status-switch[hidden] { display: none; }

/* iOS-style toggle on the right of the availability row */
.switch { position: relative; width: 38px; height: 22px; flex: none; }
.switch input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; margin: 0; cursor: pointer; }
.switch-track {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: var(--chip-line);
  transition: background 0.15s;
}
.switch-track::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
  transition: transform 0.15s;
}
.switch input:checked + .switch-track { background: var(--avail); }
.switch input:checked + .switch-track::after { transform: translateX(16px); }

.guest-note { color: var(--muted); font-size: 12px; padding: 6px 10px 10px; }
.btn.block { width: 100%; justify-content: center; }

/* Buttons */
.btn {
  appearance: none;
  border: none;
  font: inherit;
  font-weight: 500;
  padding: 8px 18px;
  border-radius: 980px;
  cursor: pointer;
}
.btn.ghost { background: none; color: var(--blue); }
.btn.ghost:hover { background: var(--blue-soft); }
.btn.primary { background: var(--blue); color: #fff; }
@media (prefers-color-scheme: dark) {
  .btn.primary { color: #202124; }
}
.btn.text { background: none; color: var(--blue); }
.btn.text:hover { background: var(--blue-soft); }
.btn.danger { background: none; color: var(--red); }
.btn.danger:hover { background: rgba(217, 48, 37, 0.08); }

/* --------------------------------------------------------------- formula bar */

.formula-bar {
  display: flex;
  align-items: center;
  border-top: 1px solid var(--grid-line);
  border-bottom: 1px solid var(--grid-line);
  background: var(--bg);
  height: 32px;
  flex: none;
}
.name-box {
  width: 110px;
  flex: none;
  text-align: center;
  font-size: 12px;
  color: var(--fg);
  border-right: 1px solid var(--grid-line);
  align-self: stretch;
  display: flex;
  align-items: center;
  justify-content: center;
  font-variant-numeric: tabular-nums;
}
.fx {
  font-style: italic;
  font-family: Georgia, serif;
  color: var(--muted);
  padding: 0 12px;
  border-right: 1px solid var(--grid-line);
  align-self: stretch;
  display: flex;
  align-items: center;
}
#search {
  flex: 1;
  border: none;
  outline: none;
  background: none;
  font: inherit;
  color: var(--fg);
  padding: 0 12px;
  min-width: 120px;
}
.search-clear {
  appearance: none;
  border: none;
  background: none;
  font-size: 18px;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
  padding: 0 10px;
  flex: none;
}
.search-clear:hover { color: var(--fg); }
.toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
  padding: 0 14px;
  border-left: 1px solid var(--grid-line);
  align-self: stretch;
}
.toggle input { accent-color: var(--green); }

/* -------------------------------------------------------------------- grid */

.grid-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.table-wrap { flex: 1; overflow: auto; background: var(--bg); }

table { border-collapse: separate; border-spacing: 0; table-layout: fixed; }

th, td {
  border-right: 1px solid var(--grid-line);
  border-bottom: 1px solid var(--grid-line);
  padding: 5px 8px;
  text-align: left;
  vertical-align: top;
  font-weight: 400;
  overflow: hidden;       /* fixed layout: content clips at the column edge */
  text-overflow: ellipsis;
}

/* row-number / column-letter gutters */
.gutter, td.gutter {
  background: var(--chrome);
  color: var(--muted);
  text-align: center;
  font-size: 11px;
  width: 44px;
  min-width: 44px;
  border-right: 1px solid var(--gutter-line);
  position: sticky;
  left: 0;
  z-index: 2;
  vertical-align: middle;
  user-select: none;
}

.col-letters th {
  position: sticky;
  top: 0;
  z-index: 3;
  background: var(--chrome);
  color: var(--muted);
  font-size: 11px;
  text-align: center;
  padding: 3px 8px;
  border-bottom: 1px solid var(--gutter-line);
  overflow: visible;
}
.col-letters .corner { z-index: 4; }

/* drag handle to resize a column, like the divider in Sheets */
.col-resizer {
  position: absolute;
  top: 0;
  right: -3px;
  width: 7px;
  height: 100%;
  cursor: col-resize;
  z-index: 6;
  touch-action: none;
}
.col-resizer:hover { background: var(--blue); opacity: 0.4; }

/* "frozen row 1" — the field names */
.field-row th {
  position: sticky;
  top: 22px;
  z-index: 3;
  background: var(--bg);
  font-weight: 700;
  border-bottom: 2px solid var(--gutter-line);
  white-space: nowrap;
}
.field-row .gutter { z-index: 4; background: var(--chrome); }

tbody tr:hover td:not(.gutter) { background: var(--hover); }
tr.own-row td:not(.gutter) { background: var(--blue-soft); }
tr.own-row td.gutter { color: var(--blue); font-weight: 700; }

/* row selected via the gutter number (Sheets-style) — whole row highlights */
tr.row-selected td { background: var(--sel) !important; }
tr.row-selected td.gutter { background: var(--blue) !important; color: var(--bg); font-weight: 700; }
.gutter { cursor: pointer; }

td { position: relative; }
td.selected {
  outline: 2px solid var(--blue);
  outline-offset: -2px;
}
td.selected::after {
  content: "";
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 6px;
  height: 6px;
  background: var(--blue);
  border: 1px solid var(--bg);
}

.person-name { font-weight: 500; white-space: nowrap; }
.person-bio { color: var(--muted); font-size: 12px; max-width: 30ch; margin-top: 1px; }
.dot {
  display: inline-block;
  width: 7px; height: 7px;
  border-radius: 50%;
  margin-right: 6px;
  background: var(--muted);
  opacity: 0.35;
}
.dot.on { background: var(--avail); opacity: 1; }

td.headline { max-width: 32ch; }

/* Category — a Sheets dropdown-chip */
.cat-pill {
  display: inline-block;
  border-radius: 980px;
  padding: 2px 10px;
  font-size: 12px;
  white-space: nowrap;
  color: #202124;
  background: #e2e3e3;
}
.cat-video-editing { background: #d4edbc; }
.cat-clipping      { background: #ffe5a0; }
.cat-design        { background: #e6cff2; }
.cat-motion        { background: #bfe1f6; }
.cat-writing       { background: #fefcbf; }
.cat-social-media  { background: #f6cfe6; }
.cat-creator       { background: #ffcfc9; }
.cat-marketing     { background: #ffd8b5; }
.cat-development   { background: #c6dbe1; }
.cat-ai            { background: #d9e2fd; }
.cat-photo-video   { background: #c9e7d8; }
.cat-audio         { background: #e8d9c0; }
.cat-voiceover     { background: #f3d1e0; }
.cat-other         { background: #e2e3e3; }

.skills-cell { max-width: 26ch; }
.skill-chip {
  appearance: none;
  display: inline-block;
  background: var(--bg);
  border: 1px solid var(--chip-line);
  color: var(--muted);
  font: inherit;
  border-radius: 980px;
  padding: 1px 9px;
  font-size: 12px;
  margin: 0 3px 3px 0;
  cursor: pointer;
}
.skill-chip:hover { border-color: var(--blue); color: var(--blue); }

td.location { color: var(--muted); white-space: nowrap; }

td.contact { min-width: 16ch; }
.contact-btn {
  appearance: none;
  border: none;
  background: none;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 12px;
  color: var(--fg);
  cursor: copy;
  padding: 0;
  text-align: left;
  overflow-wrap: anywhere;
}
.contact-btn:hover { color: var(--blue); }

/* signed-out: blurred, unreadable, click to sign in */
.contact-locked {
  appearance: none;
  border: none;
  background: none;
  padding: 0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.contact-lock { font-size: 11px; opacity: 0.55; }
.contact-blurred {
  filter: blur(4px);
  user-select: none;
  pointer-events: none;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 12px;
  color: var(--fg);
}
.contact-locked:hover .contact-lock { opacity: 1; color: var(--blue); }

td.link-cell a { color: var(--blue); white-space: nowrap; }
td.link-cell a:hover { text-decoration: underline; }
td.link-cell a { text-decoration: none; }

td.updated {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.empty-state { padding: 48px 20px; text-align: center; color: var(--muted); }

/* --------------------------------------------------------- sheet-tabs footer */

.sheet-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--chrome);
  border-top: 1px solid var(--grid-line);
  padding: 12px 18px;
  flex: none;
  overflow-x: auto;
}
/* category tab-search — an "all sheets" style filter for the tab bar */
.tab-search {
  display: flex;
  align-items: center;
  gap: 5px;
  flex: none;
  padding: 3px 10px;
  border-radius: 980px;
  background: var(--bg);
  border: 1px solid var(--grid-line);
}
.tab-search-icon { font-size: 11px; opacity: 0.6; }
.tab-search input {
  border: none;
  background: none;
  outline: none;
  font: inherit;
  font-size: 12px;
  color: var(--fg);
  width: 118px;
}

.tabs { display: flex; gap: 4px; flex: none; align-items: center; }
.tab {
  appearance: none;
  border: none;
  background: none;
  font: inherit;
  font-size: 13px;
  color: var(--muted);
  padding: 7px 16px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  line-height: 1;
}
.tab:hover { background: var(--hover); color: var(--fg); }
.tab.active { background: var(--tab-active-bg); color: var(--green); font-weight: 600; }
.tab-count {
  margin-left: 7px;
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  opacity: 0.8;
}
.tab.active .tab-count { color: var(--green); }
.tab-empty { font-size: 12px; color: var(--muted); padding: 7px 8px; }

.status {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}
.status b { color: var(--fg); font-weight: 700; }
.status-sep { opacity: 0.5; }

/* ------------------------------------------------------------------- dialog */

dialog {
  border: none;
  border-radius: 8px;
  background: var(--menu-bg);
  color: var(--fg);
  box-shadow: var(--shadow);
  padding: 24px;
  width: min(560px, calc(100vw - 32px));
  /* restore centering: the global `* { margin: 0 }` reset kills the UA's margin:auto */
  position: fixed;
  inset: 0;
  margin: auto;
  max-height: calc(100vh - 32px);
  overflow: auto;
  font-family: Roboto, Arial, sans-serif;
  font-size: 13px;
}
dialog::backdrop { background: rgba(32, 33, 36, 0.5); }
#recordForm h2 {
  font-family: "Google Sans", Roboto, Arial, sans-serif;
  font-size: 20px;
  font-weight: 400;
}
.form-note { color: var(--muted); font-size: 12px; margin: 6px 0 14px; }
#recordForm label { display: block; margin-bottom: 12px; font-weight: 500; }
#recordForm .hint { color: var(--muted); font-weight: 400; }
#recordForm input:not([type="checkbox"]), #recordForm select, #recordForm textarea {
  display: block;
  width: 100%;
  margin-top: 4px;
  font: inherit;
  padding: 8px 12px;
  border-radius: 4px;
  border: 1px solid var(--chip-line);
  background: var(--bg);
  color: var(--fg);
  outline: none;
}
#recordForm input:focus, #recordForm select:focus, #recordForm textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 1px var(--blue);
}
/* skills combobox */
.skills-label { margin-bottom: 4px; }
.skills-field { position: relative; margin-bottom: 12px; }
.skills-box {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  border: 1px solid var(--chip-line);
  border-radius: 4px;
  background: var(--bg);
  cursor: text;
}
.skills-box:focus-within { border-color: var(--blue); box-shadow: 0 0 0 1px var(--blue); }
#recordForm #skillEntry {
  display: inline;
  width: auto;
  flex: 1;
  min-width: 90px;
  margin: 0;
  padding: 2px 0;
  border: none;
  border-radius: 0;
  background: none;
}
#recordForm #skillEntry:focus { border: none; box-shadow: none; }
.skill-token {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--chip);
  border-radius: 6px;
  padding: 2px 4px 2px 9px;
  font-size: 13px;
}
.skill-token-x {
  appearance: none;
  border: none;
  background: none;
  color: var(--muted);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
}
.skill-token-x:hover { color: var(--red); }
.skill-suggest {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  z-index: 5;
  background: var(--menu-bg);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 4px;
  max-height: 240px;
  overflow: auto;
}
.skill-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  padding: 7px 10px;
  border: none;
  border-radius: 6px;
  background: none;
  font: inherit;
  color: var(--fg);
  cursor: pointer;
  text-align: left;
}
.skill-option:hover, .skill-option.active { background: var(--hover); }
.skill-option-count { color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.skill-option.create .skill-option-name { color: var(--blue); }
.skill-option.create .skill-option-count { color: var(--blue); }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: end; }
.checkbox-label { display: flex !important; align-items: center; gap: 8px; padding-bottom: 10px; }
.checkbox-label input { accent-color: var(--avail); }
.req { color: var(--red); font-weight: 700; }
.form-reassure { color: var(--muted); font-size: 12px; margin-top: 12px; }
.form-sep { border: none; border-top: 1px solid var(--grid-line); margin: 16px 0; }
.form-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-weight: 500;
  font-size: 13px;
  padding: 2px 0;
}
.form-error { color: var(--red); font-size: 13px; min-height: 18px; margin: 4px 0; }
.form-actions { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
.spacer { flex: 1; }

@media (max-width: 720px) {
  .header-actions .ghost { display: none; }
  .form-row { grid-template-columns: 1fr; }
  .name-box { display: none; }
}
