/* CC GUILD Microtask — palette lifted from the logo (indigo + gold) */
:root {
  --ink: #211a3d;
  --ink-2: #3a3163;
  --muted: #6f6890;
  --line: #e3e0ee;
  --bg: #f6f5fa;
  --surface: #ffffff;
  --brand: #2e2456;
  --brand-soft: #efecfa;
  --gold: #ffd24a;
  --gold-deep: #e0ac00;
  --ok: #1f9d6b;
  --danger: #c0392f;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(33, 26, 61, 0.06), 0 8px 24px rgba(33, 26, 61, 0.07);
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); }

.wrap {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 20px 80px;
}

/* ---------------------------------------------------------------- app bar */
.appbar {
  background: var(--brand);
  color: #fff;
  border-bottom: 3px solid var(--gold);
}
.appbar-inner {
  max-width: 900px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  text-decoration: none;
}
.brand img {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: block;
}
.brand-name {
  font-weight: 700;
  letter-spacing: 0.02em;
  font-size: 15px;
  line-height: 1.1;
}
.brand-sub {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--gold);
}
.appbar .spacer { flex: 1; }
.appbar-link {
  color: rgba(255, 255, 255, 0.82);
  text-decoration: none;
  font-size: 13px;
}
.appbar-link:hover { color: #fff; }

/* --------------------------------------------------------------- controls */
.btn {
  font: inherit;
  font-size: 14px;
  font-weight: 550;
  padding: 8px 14px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s, border-color 0.12s, transform 0.06s;
}
.btn:hover { background: #faf9fd; border-color: #cfcae0; }
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}
.btn-primary:hover { background: #3a2e6b; border-color: #3a2e6b; }
.btn-gold {
  background: var(--gold);
  border-color: var(--gold-deep);
  color: #3a2a00;
}
.btn-gold:hover { background: #ffdc70; border-color: var(--gold-deep); }
.btn-danger { color: var(--danger); border-color: #f0d3d0; background: #fff; }
.btn-danger:hover { background: #fdf2f1; border-color: #e0a9a3; }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

input[type='text'],
input[type='password'] {
  font: inherit;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
  color: var(--ink);
  width: 100%;
}
input:focus-visible,
.btn:focus-visible,
.tab:focus-visible {
  outline: 2px solid var(--gold-deep);
  outline-offset: 1px;
}

/* ---------------------------------------------------------------- shells */
.page-head {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 26px 0 16px;
}
.page-head h1 {
  margin: 0;
  font-size: 26px;
  letter-spacing: -0.01em;
}
.page-head .sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.back {
  display: inline-block;
  margin-top: 18px;
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
}
.back:hover { color: var(--brand); }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* --------------------------------------------------------- project cards */
.new-project {
  display: flex;
  gap: 8px;
  padding: 14px;
  margin-bottom: 18px;
}
.project-list { display: grid; gap: 10px; }
.project-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  text-decoration: none;
  color: inherit;
}
.project-row:hover { border-color: #cfcae0; }
.project-row .name { font-weight: 600; font-size: 16px; }
.project-row .meta { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.project-row .grow { flex: 1; min-width: 0; }
.tab-chips { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 7px; }
.chip {
  font-size: 11.5px;
  padding: 1px 8px;
  border-radius: 20px;
  background: var(--brand-soft);
  color: var(--ink-2);
}
.empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--muted);
}

/* -------------------------------------------------------------- progress */
.progress {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 12.5px;
  color: var(--muted);
  white-space: nowrap;
}
.bar {
  width: 92px;
  height: 7px;
  border-radius: 4px;
  background: var(--line);
  overflow: hidden;
}
.bar > i {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--gold), var(--gold-deep));
  transition: width 0.25s ease;
}
.bar.done > i { background: linear-gradient(90deg, #43c58c, var(--ok)); }

/* ------------------------------------------------------------- tab strip */
.project-title-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 24px 0 12px;
}
.project-title {
  font-size: 25px;
  font-weight: 700;
  letter-spacing: -0.01em;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 2px 6px;
  margin: 0 0 0 -6px;
  min-width: 40px;
}
.project-title:hover { border-color: var(--line); background: var(--surface); }
.project-title:focus { outline: none; border-color: var(--gold-deep); background: #fff; }

.tabbar {
  display: flex;
  align-items: center;
  gap: 4px;
  overflow-x: auto;
  overflow-y: hidden; /* overflow-x alone makes overflow-y compute to auto */
  scrollbar-width: thin;
  border-bottom: 1px solid var(--line);
  padding-bottom: 0;
  margin-bottom: 0;
}
.tabbar::-webkit-scrollbar { height: 5px; }
.tabbar::-webkit-scrollbar-thumb { background: var(--line); border-radius: 3px; }

.tab {
  font: inherit;
  font-size: 14px;
  font-weight: 550;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-bottom: 2.5px solid transparent;
  padding: 9px 12px;
  margin-bottom: -1px;
  border-radius: 8px 8px 0 0;
  cursor: pointer;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 7px;
}
.tab:hover { color: var(--ink); background: rgba(46, 36, 86, 0.045); }
.tab.active {
  color: var(--ink);
  border-bottom-color: var(--gold-deep);
  background: rgba(255, 210, 74, 0.13);
}
.tab .count {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  background: var(--brand-soft);
  border-radius: 20px;
  padding: 0 6px;
}
.tab.active .count { background: rgba(224, 172, 0, 0.22); color: #6b5200; }
.tab .caret { opacity: 0.45; font-size: 10px; }
.tab.active .caret { opacity: 0.8; }
.tab-add {
  font-size: 17px;
  line-height: 1;
  padding: 7px 12px;
  color: var(--muted);
  background: transparent;
  border: 0;
  cursor: pointer;
  border-radius: 8px;
}
.tab-add:hover { background: rgba(46, 36, 86, 0.06); color: var(--ink); }

/* ------------------------------------------------------------ menu popup */
.menu {
  position: fixed; /* placed from viewport coordinates in popupMenu() */
  z-index: 40;
  min-width: 150px;
  padding: 5px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(33, 26, 61, 0.16);
}
.menu button {
  display: block;
  width: 100%;
  text-align: left;
  font: inherit;
  font-size: 13.5px;
  padding: 7px 10px;
  border: 0;
  border-radius: 7px;
  background: none;
  color: var(--ink);
  cursor: pointer;
}
.menu button:hover:not(:disabled) { background: var(--brand-soft); }
.menu button:disabled { color: #b6b1c8; cursor: default; }
.menu button.danger { color: var(--danger); }
.menu button.danger:hover { background: #fdf2f1; }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 4px 2px; }

/* -------------------------------------------------------------- editor */
.editor-shell {
  background: var(--surface);
  border: 1px solid var(--line);
  border-top: 0;
  border-radius: 0 0 var(--radius) var(--radius);
  box-shadow: var(--shadow);
}
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  padding: 7px 10px;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  background: var(--surface);
  border-radius: 0;
  z-index: 5;
}
.toolbar button {
  font: inherit;
  font-size: 13px;
  min-width: 30px;
  height: 30px;
  padding: 0 8px;
  border: 0;
  border-radius: 7px;
  background: none;
  color: var(--ink-2);
  cursor: pointer;
}
.toolbar button:hover { background: var(--brand-soft); }
.toolbar button.on { background: var(--brand); color: #fff; }
.toolbar .sep { width: 1px; background: var(--line); margin: 4px 5px; }
.toolbar .grow { flex: 1; }
.save-state {
  font-size: 12px;
  color: var(--muted);
  align-self: center;
  padding-right: 4px;
}
.save-state.saving { color: var(--gold-deep); }
.save-state.error { color: var(--danger); }

.doc { padding: 10px 26px 60px; }
.ProseMirror { outline: none; min-height: 320px; }
.ProseMirror > * + * { margin-top: 0.7em; }
.ProseMirror h1 { font-size: 1.5em; margin: 1.1em 0 0.3em; letter-spacing: -0.01em; }
.ProseMirror h2 { font-size: 1.25em; margin: 1em 0 0.25em; }
.ProseMirror h3 { font-size: 1.08em; margin: 1em 0 0.2em; }
.ProseMirror p { margin: 0.55em 0; }
.ProseMirror ul, .ProseMirror ol { padding-left: 1.4em; }
.ProseMirror blockquote {
  border-left: 3px solid var(--gold);
  margin-left: 0;
  padding-left: 14px;
  color: var(--ink-2);
}
.ProseMirror code {
  background: var(--brand-soft);
  padding: 1px 5px;
  border-radius: 5px;
  font-size: 0.9em;
}
.ProseMirror pre {
  background: var(--ink);
  color: #f3f1fb;
  padding: 12px 14px;
  border-radius: 10px;
  overflow-x: auto;
}
.ProseMirror pre code { background: none; color: inherit; padding: 0; }
.ProseMirror hr { border: 0; border-top: 1px solid var(--line); margin: 1.4em 0; }
.ProseMirror a { color: var(--brand); text-decoration: underline; text-underline-offset: 2px; }
.ProseMirror p.is-editor-empty:first-child::before {
  content: attr(data-placeholder);
  float: left;
  height: 0;
  color: #a9a3c0;
  pointer-events: none;
}

/* checklists */
ul[data-type='taskList'] {
  list-style: none;
  padding: 0;
  margin: 0.4em 0;
}
ul[data-type='taskList'] li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 3px 0;
}
ul[data-type='taskList'] li > label {
  flex: 0 0 auto;
  margin-top: 0.18em;
  user-select: none;
}
ul[data-type='taskList'] li > div { flex: 1 1 auto; min-width: 0; }
ul[data-type='taskList'] li > div > p { margin: 0; }
ul[data-type='taskList'] input[type='checkbox'] {
  width: 17px;
  height: 17px;
  accent-color: var(--brand);
  cursor: pointer;
}
ul[data-type='taskList'] li[data-checked='true'] > div {
  color: var(--muted);
  text-decoration: line-through;
  text-decoration-color: rgba(111, 104, 144, 0.5);
}

/* --------------------------------------------------------------- dialogs */
dialog {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0;
  box-shadow: 0 24px 60px rgba(33, 26, 61, 0.24);
  color: var(--ink);
  max-width: min(460px, calc(100vw - 32px));
  width: 100%;
}
dialog::backdrop { background: rgba(33, 26, 61, 0.42); }
dialog h2 { margin: 0 0 4px; font-size: 17px; }
dialog .body { padding: 20px; }
dialog .hint { color: var(--muted); font-size: 13px; margin: 0 0 14px; }
dialog .actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}
.link-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 0;
  border-top: 1px solid var(--line);
}
.link-row input {
  font-size: 12.5px;
  padding: 6px 9px;
  color: var(--ink-2);
}

/* ---------------------------------------------------------- client view */
.client-head { padding: 26px 0 4px; }
.client-head h1 { margin: 0; font-size: 26px; letter-spacing: -0.01em; }
.client-head .sub { color: var(--muted); font-size: 13px; margin-top: 6px; }
.tab-progress {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 26px 0;
  font-size: 13px;
  color: var(--muted);
}
.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%) translateY(12px);
  background: var(--ink);
  color: #fff;
  font-size: 13.5px;
  padding: 9px 16px;
  border-radius: 999px;
  box-shadow: 0 10px 30px rgba(33, 26, 61, 0.3);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s, transform 0.18s;
  z-index: 90;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { background: var(--danger); }

/* --------------------------------------------------------------- login */
.login-wrap {
  max-width: 340px;
  margin: 14vh auto;
  text-align: center;
  padding: 0 20px;
}
.login-wrap img { width: 74px; height: 74px; border-radius: 16px; }
.login-wrap h1 { font-size: 19px; margin: 16px 0 20px; }
.login-wrap form { display: grid; gap: 10px; }
.login-error { color: var(--danger); font-size: 13px; min-height: 18px; }

@media (max-width: 640px) {
  .wrap { padding: 0 14px 60px; }
  .doc { padding-left: 16px; padding-right: 16px; }
  .tab-progress { padding-left: 16px; }
  .page-head { flex-wrap: wrap; }
  .project-row { flex-wrap: wrap; }
}

.brand-text { display: grid; }
.tabbar .tab .count { transition: none; }

/* ------------------------------------------------------- share link manager */
dialog.wide { max-width: min(560px, calc(100vw - 32px)); }
.share-new {
  display: flex;
  gap: 8px;
  margin: 0 0 6px;
}
.share-new input { flex: 1; min-width: 0; }
.select {
  font: inherit;
  font-size: 14px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
}
.link-row {
  display: grid;
  gap: 6px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}
.link-head {
  display: flex;
  align-items: center;
  gap: 8px;
}
.link-name { font-weight: 600; font-size: 14px; }
.link-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}
.link-actions input { flex: 1; min-width: 0; font-size: 12.5px; padding: 6px 9px; color: var(--ink-2); }
.empty-links { padding-top: 12px; border-top: 1px solid var(--line); margin-bottom: 0; }

.access-badge {
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.02em;
  padding: 2px 8px;
  border-radius: 20px;
  white-space: nowrap;
}
.access-badge.read { background: var(--brand-soft); color: var(--ink-2); }
.access-badge.write { background: rgba(255, 210, 74, 0.32); color: #6b5200; }
.viewer-name { font-size: 12.5px; color: var(--muted); }
.client-head .progress { display: inline-flex; }
.client-head #overall { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* a read-only share link cannot tick anything */
.toolbar:empty { display: none; }
.is-readonly .ProseMirror { caret-color: transparent; }
.is-readonly ul[data-type='taskList'] input[type='checkbox'] {
  pointer-events: none;
  opacity: 0.7;
  cursor: default;
}
.appbar-link.error { color: #ffd7d2; }
