:root {
  --bg: #f3f3f0;
  --bg-panel: #fbfbf9;
  --bg-sunken: #eaeae6;
  --bg-elev: #ffffff;
  --border: #d9d9d3;
  --border-strong: #b4b4ac;
  --text: #1b1b19;
  --text-dim: #5f5f59;
  --text-faint: #6e6e68;
  --accent: #35618a;
  --accent-soft: #dbe4ee;
  --accent-text: #ffffff;
  --good: #497853;
  --warn: #8a6a20;
  --bad: #a03d38;
  --radius: 3px;
  --radius-sm: 2px;
  --header-h: 46px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}
[data-theme="dark"] {
  --bg: #141416;
  --bg-panel: #1b1b1e;
  --bg-sunken: #0f0f11;
  --bg-elev: #232327;
  --border: #2d2d31;
  --border-strong: #45454b;
  --text: #e6e6e1;
  --text-dim: #a1a19a;
  --text-faint: #84847f;
  --accent: #82a9cc;
  --accent-soft: #22303c;
  --accent-text: #141416;
  --good: #86b092;
  --warn: #c3a759;
  --bad: #cc7d76;
}

* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  height: 100%;
}
body {
  font-family: var(--font);
  font-size: 13.5px;
  line-height: 1.4;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
button,
input,
select,
textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}
::-webkit-scrollbar {
  width: 9px;
  height: 9px;
}
::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border: 2px solid transparent;
  background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-faint);
  background-clip: content-box;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
}
.toolbar {
  height: var(--header-h);
  flex: 0 0 auto;
  display: flex;
  align-items: stretch;
  gap: 2px;
  padding: 0 12px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  z-index: 20;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
}
.toolbar::-webkit-scrollbar {
  height: 0;
}
.toolbar > * {
  flex: 0 0 auto;
}
.brand {
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.2px;
  display: flex;
  align-items: center;
  padding-right: 14px;
  margin-right: 6px;
  border-right: 1px solid var(--border);
  color: var(--text);
  white-space: nowrap;
}
.toolbar .spacer {
  flex: 1;
}
.tabs {
  display: flex;
  align-items: stretch;
  gap: 0;
}
.tab {
  border: none;
  border-bottom: 2px solid transparent;
  background: transparent;
  padding: 0 11px;
  cursor: pointer;
  font-weight: 500;
  font-size: 13px;
  color: var(--text-dim);
  white-space: nowrap;
}
.tab:hover {
  color: var(--text);
}
.tab.active {
  color: var(--text);
  border-bottom-color: var(--accent);
}

.btn {
  border: 1px solid var(--border);
  background: var(--bg-panel);
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 500;
  font-size: 12.5px;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}
.btn:hover {
  border-color: var(--border-strong);
  background: var(--bg-sunken);
}
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}
.btn.primary:hover {
  background: color-mix(in srgb, var(--accent) 88%, var(--text));
  border-color: color-mix(in srgb, var(--accent) 88%, var(--text));
}
.btn.ghost {
  border-color: transparent;
  background: transparent;
  color: var(--text-dim);
}
.btn.ghost:hover {
  background: var(--bg-sunken);
  color: var(--text);
}
.btn.danger {
  color: var(--bad);
}
.btn.danger:hover {
  background: var(--bg-sunken);
  border-color: var(--bad);
}
.btn.sm {
  padding: 3px 7px;
  font-size: 11.5px;
}
.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.btn:focus-visible,
.tab:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: 1px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 13px;
}
.field > label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.2px;
  color: var(--text-dim);
}
input[type="text"],
input[type="number"],
input[type="date"],
input[type="url"],
select,
textarea {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-panel);
  outline: none;
}
input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}
textarea {
  resize: vertical;
  min-height: 60px;
  line-height: 1.4;
}
.row {
  display: flex;
  gap: 8px;
}
.row > * {
  flex: 1;
  min-width: 0;
}

.badge {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-faint);
  white-space: nowrap;
}
.badge.status-active {
  color: var(--accent);
}
.badge.status-done {
  color: var(--text-faint);
}
.badge.status-blocked {
  color: var(--bad);
}
.badge.status-not-started {
  color: var(--text-faint);
}
.badge.commitment-idea {
  font-style: italic;
  color: var(--text-faint);
}
.badge.commitment-maybe {
  color: var(--warn);
}
.badge.commitment-committed {
  color: var(--text-faint);
}
.tag {
  display: inline;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-dim);
}
.tag::before {
  content: "#";
  color: var(--text-faint);
}
.progress {
  height: 4px;
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  overflow: hidden;
}
.progress > span {
  display: block;
  height: 100%;
  background: var(--accent);
}

main#view {
  flex: 1;
  min-height: 0;
  overflow: auto;
  position: relative;
}
.view {
  height: 100%;
  min-height: 0;
}
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-dim);
  gap: 14px;
  text-align: center;
  padding: 40px;
}
.empty-state p {
  margin: 0;
  max-width: 380px;
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 380px;
  max-width: 92vw;
  background: var(--bg-panel);
  border-left: 1px solid var(--border-strong);
  transform: translateX(102%);
  transition: transform 0.16s ease;
  z-index: 60;
  display: flex;
  flex-direction: column;
}
.drawer.open {
  transform: translateX(0);
}
.drawer-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
}
.drawer-head-text {
  flex: 1;
  min-width: 0;
}
.drawer-eyebrow {
  font-size: 12px;
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.drawer-close {
  border: none;
  background: transparent;
  color: var(--text-dim);
  font-size: 15px;
  line-height: 1;
  padding: 4px 6px;
  cursor: pointer;
  border-radius: var(--radius-sm);
}
.drawer-close:hover {
  background: var(--bg-sunken);
  color: var(--text);
}
.drawer-body {
  flex: 1;
  overflow: auto;
  padding: 14px;
}
.drawer-foot {
  border-top: 1px solid var(--border);
  padding: 9px 12px;
  display: flex;
  gap: 6px;
  align-items: center;
}
.editor-title {
  font-size: 15px;
  font-weight: 600;
  padding: 8px 10px;
  margin-bottom: 8px;
}
.editor-desc {
  min-height: 66px;
  margin-bottom: 12px;
}
.editor-statusbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}
.editor-statusbar select {
  width: auto;
  flex: 0 0 auto;
  padding: 5px 7px;
  font-size: 12px;
}
.editor-inline-field {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.editor-inline-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.2px;
  color: var(--text-dim);
}
.editor-derived-status {
  font-size: 12px;
  color: var(--text);
  padding: 5px 0;
}
.editor-status {
  color: var(--accent);
}
.editor-progress {
  margin-left: auto;
  font-size: 12px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}
.editor-section {
  padding: 14px 0 2px;
  border-top: 1px solid var(--border);
  margin-top: 12px;
}
.editor-section-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.4px;
  color: var(--text-faint);
  margin-bottom: 10px;
}
.editor-section .field:last-child {
  margin-bottom: 8px;
}
.editor-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 12px;
}
.editor-hint {
  font-size: 12px;
  color: var(--text-dim);
  margin: -4px 0 8px;
}
.editor-cost {
  display: flex;
  gap: 0;
}
.editor-cost input {
  flex: 1;
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
}
.editor-cost select {
  width: auto;
  flex: 0 0 auto;
}
.editor-cost-cur {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  padding: 0 9px;
  border: 1px solid var(--border);
  border-left: none;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: var(--bg-sunken);
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-dim);
}
.editor-length {
  display: flex;
  align-items: center;
  gap: 8px;
}
.editor-length .seg {
  flex: 0 0 auto;
}
.editor-length .editor-duration {
  flex: 1;
  min-width: 0;
}
.editor-duration {
  display: flex;
  gap: 6px;
}
.editor-dur-num {
  flex: 1;
  min-width: 0;
}
.editor-dur-unit {
  width: auto;
  flex: 0 0 auto;
}
.editor-subfield {
  margin-top: 4px;
}
.editor-color {
  width: 44px;
  height: 30px;
  padding: 2px;
}
.editor-linkrow {
  display: flex;
  gap: 6px;
  margin-bottom: 6px;
}
.editor-linkrow input[type="text"] {
  flex: 0 0 34%;
}
.editor-remove {
  border: none;
  background: transparent;
  color: var(--text-faint);
  cursor: pointer;
  font-size: 13px;
  padding: 0 6px;
}
.editor-remove:hover {
  color: var(--bad);
}
.editor-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px 6px;
  background: var(--bg-panel);
}
.editor-tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.editor-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11.5px;
  background: var(--bg-sunken);
  border-radius: 3px;
  padding: 1px 3px 1px 7px;
  color: var(--text-dim);
}
.editor-tag-x {
  border: none;
  background: transparent;
  color: var(--text-faint);
  cursor: pointer;
  font-size: 11px;
  line-height: 1;
  padding: 0 2px;
}
.editor-tag-x:hover {
  color: var(--bad);
}
.editor-tag-input {
  flex: 1;
  min-width: 110px;
  width: auto;
  border: none !important;
  outline: none !important;
  box-shadow: none !important;
  padding: 2px 3px !important;
  background: transparent;
}
.editor-tag-suggest {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-top: 4px;
  max-height: 150px;
  overflow: auto;
  background: var(--bg-panel);
}
.editor-tag-option {
  display: block;
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  padding: 6px 9px;
  font-size: 12px;
  cursor: pointer;
  color: var(--text);
}
.editor-tag-option:hover {
  background: var(--bg-sunken);
}
.editor-tag-option.create {
  color: var(--accent);
}
.editor-dep-search {
  margin-bottom: 6px;
}
.editor-lanerow {
  display: flex;
  gap: 6px;
}
.editor-lanerow select {
  flex: 1;
  min-width: 0;
}
.editor-lanerow .btn {
  flex: 0 0 auto;
}
.commit-row {
  display: flex;
  gap: 6px;
  margin-bottom: 6px;
}
.commit-row input {
  flex: 1;
  min-width: 0;
}
.commit-row .btn {
  flex: 0 0 auto;
}
.dep-list {
  max-height: 150px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 8px;
}
.dep-item {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 2px 0;
  cursor: pointer;
}
.dep-item input {
  width: auto;
  margin: 0;
}
#scrim {
  position: fixed;
  inset: 0;
  background: rgba(10, 12, 16, 0.32);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.16s;
  z-index: 50;
}
#scrim.open {
  opacity: 1;
  pointer-events: auto;
}

.modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 80;
  padding: 20px;
}
.modal.open {
  display: flex;
}
.modal-card {
  background: var(--bg-panel);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  width: 540px;
  max-width: 100%;
  max-height: 84vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal-head {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 12px;
  color: var(--text-dim);
  display: flex;
  align-items: center;
}
.modal-head .spacer {
  flex: 1;
}
.modal-body {
  padding: 14px;
  overflow: auto;
}
.modal-foot {
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 6px;
}
.section-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.4px;
  color: var(--text-dim);
  margin: 16px 0 8px;
}
.section-title:first-child {
  margin-top: 0;
}
.snap-list {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  max-height: 190px;
  overflow: auto;
}
.snap-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 9px;
  border-bottom: 1px solid var(--border);
}
.snap-row:last-child {
  border-bottom: none;
}
.help-row {
  display: grid;
  grid-template-columns: 84px 1fr;
  gap: 10px;
  padding: 5px 0;
  border-bottom: 1px solid var(--border);
}
.help-row:last-child {
  border-bottom: none;
}
.help-row strong {
  font-weight: 600;
  font-size: 12px;
}

#toast {
  position: fixed;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  background: var(--text);
  color: var(--bg);
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s, transform 0.18s;
  z-index: 100;
}
#toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.muted {
  color: var(--text-dim);
}
.faint {
  color: var(--text-faint);
}
.small {
  font-size: 12px;
}
.mono {
  font-family: var(--mono);
}
.hidden {
  display: none !important;
}
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 760px) {
  .toolbar {
    padding: 0 8px;
    gap: 1px;
  }
  .brand {
    padding-right: 8px;
    margin-right: 3px;
  }
  .tab {
    padding: 0 8px;
  }
}
