:root {
  --bg: #c6c9c9;
  --panel: #d9dbdb;
  --paper: #f3f4f2;
  --ink: #111;
  --muted: #62676f;
  --line: #111;
  --soft-line: rgba(0, 0, 0, .14);
  --blue: #0040ff;
  --red: #b42318;
  --green: #16803c;
  --shadow: 2px 2px 0 #111;
  --shadow-lg: 4px 4px 0 #111;
  --font: "JetBrains Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }
html, body, #app { min-height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.5 var(--font);
  letter-spacing: 0;
}
button, input, textarea, select { font: inherit; letter-spacing: 0; }
button {
  min-height: 34px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  box-shadow: 1px 1px 0 var(--line);
  cursor: pointer;
}
button:hover:not(:disabled) { transform: translate(-1px, -1px); box-shadow: var(--shadow); }
button:disabled { opacity: .45; cursor: not-allowed; }
.primary, button.primary {
  background: var(--ink);
  color: #fff;
}
input, textarea, select {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  background: #fff;
  padding: 8px 10px;
  color: var(--ink);
}
textarea { resize: vertical; }
label { display: grid; gap: 6px; }
label > span, .eyebrow {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}
h1, h2, h3, h4, p { margin: 0; }
h1 { font-size: 42px; line-height: 1.05; text-wrap: pretty; }
h2 { font-size: 24px; line-height: 1.2; }
h3 { font-size: 18px; line-height: 1.25; }
code {
  display: block;
  padding: 10px;
  border: 1px solid var(--line);
  background: #fff;
  overflow-wrap: anywhere;
}

.landing {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  background: var(--bg);
}
.landing-decor-left {
  position: absolute;
  left: -120px;
  top: -60px;
  width: 360px;
  height: 480px;
  background: var(--ink);
  transform: skew(-8deg);
  z-index: 0;
}
.landing-decor-right {
  position: absolute;
  right: -80px;
  bottom: -80px;
  width: 300px;
  height: 400px;
  background: var(--ink);
  transform: skew(12deg);
  opacity: .15;
  z-index: 0;
}
.landing-content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 32px;
  padding: 24px;
}
.landing-title {
  color: var(--ink);
  font-size: 38px;
  font-weight: 900;
  line-height: 1.05;
  text-align: center;
}
.landing-subtitle {
  max-width: 420px;
  color: var(--muted);
  text-align: center;
}
.card {
  background: var(--panel);
  box-shadow: var(--shadow);
}
.login-card {
  width: 360px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 32px;
  border: 0;
  background: var(--panel);
  box-shadow: var(--shadow);
}
.input-field {
  height: 40px;
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  box-shadow: 1px 1px 0 var(--line);
}
.input-field:focus {
  outline: none;
  box-shadow: 1px 1px 0 var(--line), 0 0 0 2px var(--blue);
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  font-weight: 800;
  box-shadow: 1px 1px 0 var(--line);
}
.btn-primary {
  background: var(--ink);
  color: #fff;
}
.login-btn {
  width: 100%;
  margin-top: 4px;
}
.landing-footer {
  position: absolute;
  bottom: 20px;
  z-index: 1;
  color: var(--muted);
  font-size: 12px;
}
.landing-footer a {
  color: inherit;
  text-decoration: none;
  font-weight: 900;
}
.landing-footer a:hover {
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.form-error, .banner {
  padding: 10px 12px;
  border: 1px solid var(--red);
  background: #fff5f2;
  color: var(--red);
  font-weight: 800;
}
.banner.success {
  border-color: var(--green);
  background: #f0fff5;
  color: var(--green);
}

.app-shell { min-height: 100vh; display: grid; grid-template-rows: 42px 1fr; }
.topbar {
  height: 42px;
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr) auto;
  align-items: center;
  background: var(--ink);
  color: #fff;
}
.brand {
  padding: 0 16px;
  font-weight: 900;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar nav { display: flex; height: 100%; }
.topbar nav button {
  min-height: 42px;
  padding: 0 16px;
  border: 0;
  border-left: 1px solid rgba(255,255,255,.16);
  background: transparent;
  color: rgba(255,255,255,.72);
  box-shadow: none;
}
.topbar nav button.active { color: #fff; background: rgba(255,255,255,.12); }
.userbox { display: flex; align-items: center; gap: 10px; padding: 0 12px; }
.userbox button {
  min-height: 26px;
  border-color: rgba(255,255,255,.7);
  background: transparent;
  color: #fff;
  box-shadow: none;
}

.workspace {
  padding: 18px;
  display: grid;
  gap: 16px;
  align-content: start;
}
.section-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 12px;
}
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.workbench-tabs, .filter-bar, .board-tools {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.workbench-tabs button.active, .board-tools button.active {
  background: var(--ink);
  color: #fff;
}
.filter-bar {
  padding: 10px;
  border: 2px solid var(--line);
  background: rgba(255,255,255,.45);
  box-shadow: var(--shadow);
}
.filter-bar input, .filter-bar select {
  width: auto;
  min-width: 170px;
  flex: 1;
}
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(120px, 1fr));
  gap: 10px;
}
.metric-card {
  border: 2px solid var(--line);
  background: var(--paper);
  box-shadow: var(--shadow);
  padding: 14px;
  display: grid;
  gap: 4px;
}
.metric-card b { font-size: 28px; }
.metric-card span { color: var(--muted); font-weight: 900; }
.dashboard-columns {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}
.list-line {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--soft-line);
}
.list-line span { color: var(--muted); font-size: 12px; text-align: right; }
.kanban-board {
  display: grid;
  grid-template-columns: repeat(4, minmax(240px, 1fr));
  gap: 12px;
  align-items: start;
  overflow-x: auto;
}
.kanban-column {
  min-height: 220px;
  display: grid;
  align-content: start;
  gap: 8px;
  padding: 10px;
  border: 2px solid var(--line);
  background: rgba(255,255,255,.52);
  box-shadow: var(--shadow);
}
.kanban-column h3 {
  display: flex;
  justify-content: space-between;
  font-size: 15px;
}
.kanban-column h3 em { color: var(--muted); font-style: normal; }
.file-list, .template-grid {
  display: grid;
  gap: 10px;
}
.template-grid {
  grid-template-columns: repeat(3, minmax(240px, 1fr));
}
.file-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  background: #fff;
}
.file-row span { color: var(--muted); font-size: 12px; }

.project-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 420px;
  gap: 16px;
  align-items: start;
}
.project-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(280px, 1fr));
  gap: 14px;
}
.project-card, .detail-panel, .calendar-panel, .day-panel, .notebooks, .notes, .editor, .user-card, .settings-card {
  border: 2px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
}
.project-card {
  display: grid;
  gap: 12px;
  padding: 14px;
}
.project-card.selected { outline: 3px solid var(--blue); outline-offset: -5px; }
.card-head, .detail-head, .panel-title {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
}
.card-head strong {
  min-width: 0;
  font-size: 16px;
  overflow-wrap: anywhere;
}
.card-head span, .user-card em, .user-card b {
  border: 1px solid var(--line);
  background: #fff;
  padding: 2px 6px;
  font-size: 11px;
  font-style: normal;
  font-weight: 800;
  white-space: nowrap;
}
.project-meta {
  display: grid;
  grid-template-columns: 86px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
}
.ring {
  --value: 0;
  width: 76px;
  aspect-ratio: 1;
  border: 2px solid var(--line);
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: radial-gradient(circle, var(--panel) 58%, transparent 59%), conic-gradient(var(--blue) calc(var(--value) * 1%), #b9bec6 0);
}
.ring b { font-size: 13px; }
dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; margin: 0; }
dt { color: var(--muted); font-weight: 800; }
dd { margin: 0; font-weight: 800; }
.member-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.member-chips span {
  max-width: 64px;
  min-height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 7px;
  border: 1px solid var(--line);
  background: #fff;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.task-preview {
  display: grid;
  gap: 5px;
  border-top: 1px solid var(--soft-line);
  padding-top: 10px;
  color: var(--muted);
  font-size: 12px;
}
.detail-panel {
  position: sticky;
  top: 60px;
  display: grid;
  gap: 14px;
  padding: 16px;
}
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.stats-grid div {
  border: 1px solid var(--line);
  background: #fff;
  padding: 10px;
  display: grid;
  gap: 2px;
}
.stats-grid b { font-size: 22px; }
.stats-grid span { color: var(--muted); font-size: 11px; font-weight: 800; }
.detail-list {
  padding: 10px;
  border: 1px solid var(--soft-line);
  background: rgba(255,255,255,.45);
}
.group-board {
  display: grid;
  gap: 10px;
  max-height: calc(100vh - 360px);
  overflow: auto;
}
.group-column {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.55);
  min-height: 96px;
}
.group-column.drag-over, .day.drag-over {
  outline: 3px solid var(--blue);
  outline-offset: -4px;
  background: #edf3ff;
}
.group-column h4 { font-size: 13px; }
.task-row {
  width: 100%;
  min-height: 54px;
  display: grid;
  gap: 3px;
  text-align: left;
  background: #fff;
  cursor: grab;
}
.task-row:active { cursor: grabbing; }
.task-row.is-dragging, .timeline.is-dragging, .day small.is-dragging { opacity: .42; }
.task-row.done { opacity: .6; }
.task-row span { font-weight: 900; }
.task-row em { color: var(--muted); font-size: 11px; font-style: normal; }
.task-row i {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  font-style: normal;
}
.status-pill, .priority-pill, .tag-pill {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  padding: 1px 6px;
  border: 1px solid var(--line);
  background: var(--paper);
  font-size: 11px;
}
.status-done { background: #e6f7ea; }
.status-doing { background: #e8efff; }
.status-delayed, .priority-4 { background: #fff0ec; color: var(--red); }
.priority-3 { background: #fff8da; }
.tag-pill { background: #f7f7f7; color: var(--muted); }
.task-row input[type="checkbox"] {
  width: 16px;
  min-height: 16px;
  vertical-align: middle;
}

.calendar-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 16px;
  align-items: start;
}
.calendar-panel, .day-panel { padding: 14px; }
.weekdays, .calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
}
.weekdays span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  text-align: center;
}
.calendar-grid { margin-top: 8px; }
.day {
  min-height: 96px;
  display: grid;
  align-content: start;
  gap: 4px;
  text-align: left;
  background: #fff;
  box-shadow: none;
}
.day.selected { outline: 2px solid var(--blue); }
.day.muted { opacity: .48; }
.day small {
  display: block;
  padding: 2px 4px;
  background: #dbe4ff;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  cursor: grab;
}
.day small.more {
  background: #fff;
  border: 1px dashed var(--soft-line);
  color: var(--muted);
  cursor: default;
}
.day-panel {
  display: grid;
  gap: 10px;
}
.timeline {
  display: grid;
  gap: 4px;
  padding: 10px;
  border: 1px solid var(--line);
  background: #fff;
  cursor: grab;
}
.timeline.done { opacity: .62; }
.timeline time { color: var(--blue); font-size: 12px; font-weight: 900; }
.timeline span { color: var(--muted); font-size: 12px; }

.docs-layout {
  min-height: calc(100vh - 92px);
  display: grid;
  grid-template-columns: 230px 300px minmax(0, 1fr);
  gap: 14px;
}
.notebooks, .notes, .editor {
  padding: 12px;
  display: grid;
  gap: 10px;
  align-content: start;
}
.notebooks button, .notes button {
  width: 100%;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  text-align: left;
  background: #fff;
  box-shadow: none;
}
.notebooks button.active, .notes button.active { outline: 2px solid var(--blue); }
.notes button {
  display: grid;
}
.notes input { margin-bottom: 4px; }
.notes button em {
  color: var(--muted);
  font-style: normal;
  font-size: 11px;
}
.editor-split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 12px;
}
.editor-split textarea {
  min-height: 520px;
  font-family: var(--font);
}
.markdown {
  min-height: 460px;
  padding: 16px;
  border: 1px solid var(--line);
  background: #fff;
  overflow-wrap: anywhere;
}
.markdown h1 { font-size: 26px; margin: 0 0 14px; }
.markdown h2 { font-size: 20px; margin: 18px 0 10px; }
.markdown h3 { margin: 16px 0 8px; }
.markdown p { margin: 8px 0; }
.markdown ul { margin: 8px 0; padding-left: 22px; }
.markdown blockquote {
  margin: 10px 0;
  padding: 8px 12px;
  border-left: 4px solid var(--line);
  background: #f6f6f6;
}
.markdown pre {
  padding: 12px;
  border: 1px solid var(--line);
  background: #111;
  color: #fff;
  overflow: auto;
}
.markdown .inline-code {
  display: inline;
  padding: 1px 4px;
  background: #eef0f2;
}
.markdown hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 16px 0;
}

.user-grid {
  display: grid;
  gap: 10px;
}
.user-card {
  min-height: 72px;
  padding: 12px;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto auto auto;
  align-items: center;
  gap: 12px;
}
.avatar {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  background: var(--ink);
  color: #fff;
  font-weight: 900;
}
.user-card div:nth-child(2) { display: grid; gap: 2px; }
.user-card span { color: var(--muted); font-size: 12px; }
.danger-text { color: var(--red); }

.settings-grid {
  display: grid;
  grid-template-columns: minmax(0, 520px) minmax(0, 1fr);
  gap: 16px;
}
.settings-card {
  padding: 16px;
  display: grid;
  gap: 14px;
  align-content: start;
}
.switch {
  display: flex;
  align-items: center;
  gap: 8px;
}
.switch input { width: 18px; min-height: 18px; }
.switch span {
  color: var(--ink);
  font-size: 13px;
  text-transform: none;
}

.modal-mask {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(17,17,17,.55);
}
.modal {
  width: min(760px, 100%);
  max-height: calc(100vh - 40px);
  overflow: auto;
  border: 2px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow-lg);
}
.modal-head {
  height: 44px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 12px;
  border-bottom: 1px solid var(--line);
  background: var(--ink);
  color: #fff;
}
.modal-head button {
  min-height: 28px;
  border-color: rgba(255,255,255,.7);
  background: transparent;
  color: #fff;
  box-shadow: none;
}
.modal-body {
  display: grid;
  gap: 14px;
  padding: 14px;
}
.modal-body.wide { width: min(980px, calc(100vw - 40px)); }
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
fieldset {
  margin: 0;
  padding: 10px;
  border: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
fieldset legend {
  padding: 0 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
}
.permission-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
fieldset label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
fieldset input { width: 16px; min-height: 16px; }
.inline-fields { display: flex; gap: 18px; flex-wrap: wrap; }

.empty {
  padding: 18px;
  border: 1px dashed var(--line);
  background: rgba(255,255,255,.45);
  color: var(--muted);
  font-weight: 800;
}
.muted { color: var(--muted); }

@media (max-width: 1180px) {
  .project-layout, .calendar-layout, .settings-grid { grid-template-columns: 1fr; }
  .detail-panel { position: static; }
  .docs-layout { grid-template-columns: 220px minmax(0, 1fr); }
  .editor { grid-column: 1 / -1; }
  .editor-split { grid-template-columns: 1fr; }
  .dashboard-grid { grid-template-columns: repeat(3, minmax(120px, 1fr)); }
  .dashboard-columns, .template-grid { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  body { font-size: 13px; }
  .topbar {
    height: auto;
    grid-template-columns: 1fr;
  }
  .topbar nav { overflow-x: auto; }
  .workspace { padding: 10px; }
  .login-panel, .project-list, .docs-layout, .form-grid, .user-card, .permission-grid { grid-template-columns: 1fr; }
  .login-panel > div:first-child { min-height: 220px; }
  h1 { font-size: 32px; }
  .calendar-panel { overflow-x: auto; }
  .weekdays, .calendar-grid { min-width: 680px; }
  .editor-split textarea { min-height: 340px; }
  .dashboard-grid, .file-row { grid-template-columns: 1fr; }
  .kanban-board { grid-template-columns: repeat(4, 260px); }
}
