@font-face {
  font-family: "JetBrainsMono Nerd Font Local";
  src: local("JetBrainsMono Nerd Font"), local("JetBrainsMono Nerd Font Mono"), local("JetBrains Mono Nerd Font");
  font-display: swap;
}

:root {
  --bg: #F2F0EF;
  --surface: #F8F7F6;
  --surface-strong: #FCFBFA;
  --text: #282624;
  --muted: #746F6B;
  --faint: #9F9995;
  --border: #D9D4D1;
  --border-strong: #C8C2BE;
  --danger: #9B453C;
  --shadow-soft: 0 10px 28px rgba(39, 35, 32, 0.06);
  --font: "JetBrainsMono Nerd Font Local", "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background: var(--bg);
  font-family: var(--font);
  font-size: 13px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select { font: inherit; }

button,
a { -webkit-tap-highlight-color: transparent; }

a { color: inherit; }

button:focus-visible,
input:focus-visible,
select:focus-visible,
a:focus-visible {
  outline: 2px solid #4B4744;
  outline-offset: 2px;
}

button:disabled { opacity: .55; cursor: wait; }

.wordmark {
  width: fit-content;
  color: var(--text);
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.06em;
  text-decoration: none;
}

.is-hidden { display: none !important; }
.is-loading { opacity: 0; pointer-events: none; }

/* auth */
.auth-page {
  display: grid;
  place-items: center;
  padding: 28px 16px;
}

.auth-shell {
  width: min(370px, 100%);
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

.auth-wordmark {
  align-self: center;
  margin-bottom: 18px;
  font-size: 21px;
}

.auth-card {
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: rgba(248, 247, 246, 0.72);
  box-shadow: var(--shadow-soft);
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px;
  margin-bottom: 19px;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: #EAE7E5;
}

.tab {
  height: 36px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.tab.is-active {
  color: var(--text);
  background: var(--surface-strong);
  box-shadow: 0 1px 3px rgba(40, 35, 33, 0.07);
}

.auth-form,
.settings-form { display: grid; gap: 14px; }

.field,
.auth-form label {
  display: grid;
  gap: 6px;
}

.field > span,
.auth-form label > span {
  color: var(--muted);
  font-size: 10px;
}

.field small,
.auth-form small {
  color: var(--faint);
  font-size: 9px;
}

input,
select {
  width: 100%;
  height: 42px;
  padding: 0 11px;
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  color: var(--text);
  background: rgba(255,255,255,.62);
}

input::placeholder { color: #AAA4A0; }

input:focus,
select:focus {
  outline: none;
  border-color: #77716D;
  background: #FFF;
  box-shadow: 0 0 0 3px rgba(75, 71, 68, .07);
}

.primary-button {
  width: 100%;
  height: 43px;
  margin-top: 2px;
  border: 1px solid #292725;
  border-radius: 7px;
  color: #F7F5F4;
  background: #292725;
  cursor: pointer;
}

.primary-button:hover { background: #161514; }

.tiny-note {
  align-self: center;
  margin-top: 16px;
  color: var(--faint);
  font-size: 9px;
}

.form-message {
  min-height: 17px;
  margin: 10px 0 0;
  color: #8C3F36;
  font-size: 10px;
}

.form-message.success { color: #557054; }

/* shared app chrome */
.app-shell {
  min-height: 100vh;
  transition: opacity 120ms ease;
}

.topbar,
.board-topbar {
  height: 62px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 clamp(18px, 4.2vw, 58px);
  border-bottom: 1px solid rgba(201, 195, 191, .72);
  background: rgba(242, 240, 239, .9);
}

.account-menu-wrap { position: relative; }

.account-trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 4px 0 4px 7px;
  border: 0;
  color: var(--text);
  background: transparent;
  cursor: pointer;
}

.account-name {
  max-width: 170px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 10px;
}

.account-arrow {
  color: var(--muted);
  font-size: 12px;
  transform: rotate(0deg);
  transition: transform 140ms ease;
}

.account-menu-wrap:hover .account-arrow,
.account-trigger[aria-expanded="true"] .account-arrow {
  transform: rotate(180deg);
}

.avatar,
.settings-avatar,
.member-avatar {
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  color: #4B4744;
  background: #E8E4E1;
  font-weight: 600;
}

.avatar {
  width: 29px;
  height: 29px;
  font-size: 8px;
}

.avatar img,
.settings-avatar img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.account-menu {
  position: absolute;
  z-index: 50;
  top: calc(100% - 1px);
  right: 0;
  width: 150px;
  padding: 5px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(252, 251, 250, .98);
  box-shadow: var(--shadow-soft);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-5px);
  transition: opacity 120ms ease, transform 120ms ease, visibility 120ms ease;
}

.account-menu-wrap:hover .account-menu,
.account-menu.is-open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.account-menu a,
.account-menu button {
  width: 100%;
  display: block;
  padding: 9px 10px;
  border: 0;
  border-radius: 5px;
  color: var(--muted);
  background: transparent;
  text-align: left;
  text-decoration: none;
  font-size: 10px;
  cursor: pointer;
}

.account-menu a:hover,
.account-menu button:hover {
  color: var(--text);
  background: #F0EDEB;
}

/* projects */
.projects-content {
  width: min(1050px, calc(100% - 38px));
  margin: 0 auto;
  padding: 64px 0 80px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}

.section-head h1,
.settings-content h1 {
  margin: 0;
  font-size: 28px;
  font-weight: 500;
  letter-spacing: -0.05em;
}

.small-button {
  min-height: 35px;
  padding: 0 12px;
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  color: var(--text);
  background: var(--surface-strong);
  cursor: pointer;
}

.small-button:hover { background: #FFF; }
.small-button.dark { border-color: #2A2826; color: #F7F5F4; background: #2A2826; }
.small-button.dark:hover { background: #161514; }
.small-button.danger { border-color: #CFA8A3; color: var(--danger); background: #FAF3F2; }
.small-button.danger:hover { background: #F7EAE8; }

.status-line {
  margin: 0 0 13px;
  color: var(--faint);
  font-size: 10px;
}

.project-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.project-card {
  min-height: 220px;
  overflow: visible;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  background: rgba(248, 247, 246, .66);
}

.new-project-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 20px;
  border-style: dashed;
  text-align: left;
  cursor: pointer;
}

.new-project-card:hover,
.project-card-real:hover {
  border-color: #BDB6B2;
  background: rgba(252,251,250,.8);
}

.new-project-plus {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--muted);
  font-size: 16px;
}

.new-project-copy { display: grid; gap: 3px; }
.new-project-copy strong { font-size: 11px; font-weight: 500; }
.new-project-copy small { color: var(--faint); font-size: 9px; }

.project-card-real { position: relative; cursor: pointer; overflow: visible; }

.project-preview {
  position: relative;
  height: 151px;
  overflow: hidden;
  border-radius: 10px 10px 0 0;
  border-bottom: 1px solid var(--border);
  background-color: #F5F3F2;
  background-image: radial-gradient(#D6D1CE 0.65px, transparent 0.65px);
  background-size: 13px 13px;
}

.preview-shape {
  position: absolute;
  width: 57px;
  height: 30px;
  border: 1px solid #C3BCB8;
  border-radius: 4px;
  background: #FBFAF9;
}

.shape-a { left: 20%; top: 46%; }
.shape-b { right: 19%; top: 30%; width: 68px; }
.preview-line { position: absolute; left: 40%; top: 48%; width: 27%; height: 1px; background: #BDB6B2; transform: rotate(-12deg); }

.project-card-meta {
  min-height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 14px;
}

.project-card-copy { min-width: 0; }
.project-card-copy h2 { margin: 0 0 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; font-weight: 500; }
.project-card-copy p { margin: 0; color: var(--faint); font-size: 9px; }

.card-menu-wrap { position: relative; }
.card-menu-button { width: 31px; height: 31px; border: 0; border-radius: 6px; color: var(--muted); background: transparent; cursor: pointer; letter-spacing: 1px; }
.card-menu-button:hover { color: var(--text); background: #EFECE9; }

.card-menu {
  position: absolute;
  z-index: 40;
  right: 0;
  top: 31px;
  width: 120px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface-strong);
  box-shadow: var(--shadow-soft);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-3px);
}

.card-menu.is-open { opacity: 1; visibility: visible; transform: translateY(0); }
.card-menu button { width: 100%; padding: 8px; border: 0; border-radius: 4px; color: var(--muted); background: transparent; text-align: left; font-size: 9px; cursor: pointer; }
.card-menu button:hover { color: var(--text); background: #F0EDEB; }
.card-menu .danger-text { color: var(--danger); }

/* dialogs */
dialog {
  color: var(--text);
  font-family: var(--font);
}

dialog::backdrop { background: rgba(40, 37, 34, .18); backdrop-filter: blur(2px); }

.dialog-card {
  width: min(430px, calc(100% - 28px));
  padding: 20px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: #F8F7F6;
  box-shadow: 0 22px 80px rgba(41, 37, 34, .14);
}

.dialog-head { display: flex; align-items: start; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.dialog-head h2 { margin: 0; font-size: 14px; font-weight: 500; letter-spacing: -0.03em; }
.dialog-kicker { margin: 0 0 3px; color: var(--faint); font-size: 9px; }
.icon-button { width: 28px; height: 28px; border: 0; border-radius: 5px; color: var(--muted); background: transparent; cursor: pointer; font-size: 17px; }
.icon-button:hover { color: var(--text); background: #EEEAE8; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 17px; }
.dialog-footnote { margin: 16px 0 0; color: var(--faint); font-size: 9px; }
.confirm-text { margin: 0 0 16px; color: var(--muted); font-size: 10px; }

.share-dialog { width: min(510px, calc(100% - 28px)); }
.member-list { display: grid; margin-bottom: 17px; }
.member-row { min-height: 44px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border-bottom: 1px solid #E1DDDA; }
.member-person { display: flex; align-items: center; gap: 9px; min-width: 0; font-size: 10px; }
.member-avatar { width: 27px; height: 27px; flex: 0 0 auto; font-size: 7px; }
.member-role-static { color: var(--faint); font-size: 9px; }
.member-controls { display: flex; align-items: center; gap: 5px; }
.member-controls select { width: 104px; height: 31px; padding: 0 7px; font-size: 9px; }
.member-remove { width: 28px; height: 28px; border: 0; border-radius: 5px; color: var(--faint); background: transparent; cursor: pointer; }
.member-remove:hover { color: var(--danger); background: #F3E9E7; }
.share-add-form { display: grid; grid-template-columns: minmax(0, 1fr) 112px auto; align-items: end; gap: 8px; }
.share-add-button { height: 42px; }

/* board */
.board-page { overflow: hidden; }
.board-app { height: 100vh; display: flex; flex-direction: column; transition: opacity 120ms ease; }
.board-topbar { flex: 0 0 58px; padding: 0 17px; }
.board-left { display: flex; align-items: center; gap: 11px; min-width: 0; }
.back-link { width: 31px; height: 31px; display: grid; place-items: center; border-radius: 6px; color: var(--muted); text-decoration: none; }
.back-link:hover { color: var(--text); background: #EAE7E5; }
.board-name { max-width: min(60vw, 520px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; font-weight: 500; }
.board-surface { position: relative; flex: 1; background-color: #F4F2F1; background-image: radial-gradient(#D2CDCA 0.65px, transparent 0.65px); background-size: 15px 15px; }
.board-placeholder { position: absolute; inset: 0; display: grid; place-content: center; gap: 4px; color: var(--muted); text-align: center; pointer-events: none; }
.board-placeholder span { font-size: 11px; }
.board-placeholder small { color: var(--faint); font-size: 8px; }

/* settings */
.settings-content { width: min(720px, calc(100% - 38px)); margin: 0 auto; padding: 54px 0 80px; }
.settings-back { display: inline-block; margin-bottom: 18px; color: var(--muted); font-size: 10px; text-decoration: none; }
.settings-back:hover { color: var(--text); }
.settings-content h1 { margin-bottom: 26px; }
.settings-section { padding: 21px 0; border-top: 1px solid var(--border); }
.profile-settings-row { display: flex; align-items: center; gap: 13px; margin-bottom: 23px; }
.settings-avatar { width: 48px; height: 48px; font-size: 11px; }
.profile-settings-row strong { display: block; margin-bottom: 3px; font-size: 11px; font-weight: 500; }
.profile-settings-row p,
.danger-section p { margin: 0; color: var(--faint); font-size: 9px; }
.settings-action-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.settings-action-row .form-message { flex: 1; margin: 0; }
.danger-section { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.danger-section h2 { margin: 0 0 4px; font-size: 11px; font-weight: 500; color: var(--danger); }

.session-error { min-height: 100vh; display: grid; place-content: center; gap: 8px; text-align: center; color: var(--muted); }
.session-error p { margin: 0; }
.session-error a { font-size: 10px; }

@media (max-width: 760px) {
  .project-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .projects-content { padding-top: 42px; }
}

@media (max-width: 540px) {
  .account-name { max-width: 110px; }
  .topbar { padding: 0 15px; }
  .projects-content, .settings-content { width: calc(100% - 26px); }
  .section-head h1, .settings-content h1 { font-size: 24px; }
  .project-grid { grid-template-columns: 1fr; }
  .project-card { min-height: 205px; }
  .share-add-form { grid-template-columns: 1fr 105px; }
  .share-add-button { grid-column: 1 / -1; width: 100%; }
  .danger-section { align-items: flex-start; flex-direction: column; }
}

@media (hover: none) {
  .account-menu-wrap:hover .account-menu { opacity: 0; visibility: hidden; transform: translateY(-5px); }
  .account-menu.is-open { opacity: 1 !important; visibility: visible !important; transform: translateY(0) !important; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; scroll-behavior: auto !important; }
}
