/* Docket, team task inbox.
   Neutral zinc/stone surface, single emerald accent, functional status hues. */

:root {
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, "Helvetica Neue", Arial, sans-serif;

  --bg: #f7f7f5;
  --surface: #ffffff;
  --surface-sunken: #f1f1ef;
  --border: #e3e3df;
  --border-strong: #d0d0cb;
  --text: #1c1c1a;
  --text-muted: #55554f;
  --text-faint: #6a6a62;

  --accent: #0e7a5c;
  --accent-strong: #0a5c46;
  --accent-soft: #dcf1e8;
  --accent-contrast: #ffffff;

  --status-todo-bg: #eeeeec;
  --status-todo-fg: #45453f;
  --status-inprogress-bg: #e1ecfc;
  --status-inprogress-fg: #1d4ed8;
  --status-blocked-bg: #fbe9d2;
  --status-blocked-fg: #92400e;
  --status-done-bg: #d9f1e6;
  --status-done-fg: #0a5c46;

  --danger-fg: #a3221c;

  --radius-control: 8px;
  --radius-panel: 16px;
  --shadow-panel: 0 24px 48px -20px rgba(20, 20, 18, 0.35);
  --focus-ring: 0 0 0 3px rgba(14, 122, 92, 0.35);

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161615;
    --surface: #1f1f1d;
    --surface-sunken: #262624;
    --border: #34342f;
    --border-strong: #46453f;
    --text: #f3f3ef;
    --text-muted: #b7b7ae;
    --text-faint: #9c9c90;

    --accent: #35c290;
    --accent-strong: #4fdba9;
    --accent-soft: #1c3830;
    --accent-contrast: #0c1a15;

    --status-todo-bg: #2d2d29;
    --status-todo-fg: #d4d4c9;
    --status-inprogress-bg: #1c2c4d;
    --status-inprogress-fg: #9db8f5;
    --status-blocked-bg: #402b13;
    --status-blocked-fg: #f0b871;
    --status-done-bg: #17342a;
    --status-done-fg: #6fdcb1;

    --danger-fg: #f3897f;

    --shadow-panel: 0 24px 48px -20px rgba(0, 0, 0, 0.6);
    --focus-ring: 0 0 0 3px rgba(79, 219, 169, 0.4);

    color-scheme: dark;
  }
}

* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
}

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

h1, h2, h3, p, dl, dd, ul {
  margin: 0;
}

button, input, select {
  font: inherit;
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

.skip-link {
  position: absolute;
  left: 0.5rem;
  top: -3rem;
  background: var(--accent);
  color: var(--accent-contrast);
  padding: 0.6rem 1rem;
  border-radius: var(--radius-control);
  transition: top 0.15s ease;
  z-index: 100;
}
.skip-link:focus {
  top: 0.5rem;
}

/* Topbar */
.topbar {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  padding: 0.85rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 7px;
  background: var(--accent);
  color: var(--accent-contrast);
  font-weight: 700;
  font-size: 14px;
}
.brand-name {
  font-weight: 650;
  font-size: 17px;
  letter-spacing: -0.01em;
}
.brand-tag {
  color: var(--text-faint);
  font-size: 13px;
}

/* Layout */
.layout {
  display: grid;
  grid-template-columns: 208px minmax(0, 1fr);
  min-height: calc(100dvh - 58px);
}

.rail {
  border-right: 1px solid var(--border);
  padding: 1rem 0.75rem;
  background: var(--surface);
}
.rail ul {
  list-style: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.rail-item {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  width: 100%;
  padding: 0.5rem 0.6rem;
  border: none;
  background: transparent;
  border-radius: var(--radius-control);
  text-align: left;
  cursor: pointer;
  color: var(--text-muted);
}
.rail-item:hover {
  background: var(--surface-sunken);
  color: var(--text);
}
.rail-item[aria-current="true"] {
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 600;
}
.rail-label {
  flex: 1;
  font-size: 13.5px;
}
.rail-count {
  font-variant-numeric: tabular-nums;
  font-size: 12.5px;
  color: var(--text-faint);
}
.rail-item[aria-current="true"] .rail-count {
  color: var(--accent-strong);
}
.rail-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.status-dot-todo { background: var(--status-todo-fg); opacity: 0.6; }
.status-dot-in-progress { background: var(--status-inprogress-fg); }
.status-dot-blocked { background: var(--status-blocked-fg); }
.status-dot-done { background: var(--status-done-fg); }

/* Content */
.content {
  padding: 1.5rem 1.75rem 3rem;
  min-width: 0;
}

.toolbar {
  display: flex;
  gap: 1rem;
  align-items: flex-end;
  flex-wrap: wrap;
  margin-bottom: 0.6rem;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.field label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
}
.search-field {
  flex: 1 1 280px;
  min-width: 220px;
}
.search-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--text-faint);
  pointer-events: none;
}
#search-input {
  width: 100%;
  padding: 0.55rem 0.75rem 0.55rem 2.1rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-control);
  background: var(--surface);
  color: var(--text);
}
#search-input:focus-visible {
  box-shadow: var(--focus-ring);
  outline: none;
}
.filter-field {
  flex: 0 0 auto;
}
#filter-select {
  padding: 0.55rem 2rem 0.55rem 0.75rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-control);
  background: var(--surface);
  color: var(--text);
  min-width: 168px;
}
#filter-select:focus-visible {
  box-shadow: var(--focus-ring);
  outline: none;
}

.result-summary {
  color: var(--text-faint);
  font-size: 13px;
  margin: 0.75rem 0 0.6rem;
  font-variant-numeric: tabular-nums;
}

/* Item list */
.item-list {
  list-style: none;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-panel);
  overflow: hidden;
  background: var(--surface);
}
.item {
  border-bottom: 1px solid var(--border);
}
.item:last-child {
  border-bottom: none;
}
.item-open {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  width: 100%;
  text-align: left;
  padding: 0.85rem 1.1rem;
  border: none;
  background: transparent;
  cursor: pointer;
}
.item-open:hover {
  background: var(--surface-sunken);
}
.item-open:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
  border-radius: 0;
}
.item-top {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem 0.65rem;
}
.item-title {
  flex: 1 1 160px;
  min-width: 0;
  overflow-wrap: anywhere;
  font-weight: 600;
  font-size: 15px;
  color: var(--text);
}
.status-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
}
.status-todo { background: var(--status-todo-bg); color: var(--status-todo-fg); }
.status-in-progress { background: var(--status-inprogress-bg); color: var(--status-inprogress-fg); }
.status-blocked { background: var(--status-blocked-bg); color: var(--status-blocked-fg); }
.status-done { background: var(--status-done-bg); color: var(--status-done-fg); }

.priority-flag {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-faint);
  flex-shrink: 0;
}
.priority-high { color: var(--danger-fg); }

.item-meta {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  font-size: 13px;
  color: var(--text-muted);
}
.meta-assignee {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}
.avatar {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 9.5px;
  font-weight: 700;
  color: #fff;
  background: var(--avatar-color, #55554f);
  flex-shrink: 0;
}
.meta-due.is-overdue {
  color: var(--danger-fg);
  font-weight: 600;
}
.item-tags {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}
.tag-chip {
  font-size: 11.5px;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  color: var(--text-muted);
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 3.5rem 1.5rem;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-panel);
  background: var(--surface);
}
.empty-title {
  font-weight: 650;
  font-size: 16px;
  margin-bottom: 0.35rem;
}
.empty-hint {
  color: var(--text-muted);
  font-size: 13.5px;
  max-width: 42ch;
  margin: 0 auto 1.1rem;
}

.btn {
  border-radius: var(--radius-control);
  padding: 0.55rem 1.1rem;
  font-weight: 600;
  font-size: 13.5px;
  cursor: pointer;
  border: 1px solid transparent;
}
.btn:active {
  transform: scale(0.98);
}
.btn-secondary {
  background: var(--surface);
  border-color: var(--border-strong);
  color: var(--text);
}
.btn-secondary:hover {
  background: var(--surface-sunken);
}

/* Detail dialog */
.detail-dialog {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
  overflow: visible;
}
.detail-dialog:not([open]) {
  display: none;
}
.detail-dialog::backdrop {
  background: rgba(20, 20, 18, 0.4);
}
.detail-inner {
  position: absolute;
  top: 0;
  right: 0;
  width: min(440px, 100%);
  height: 100%;
  background: var(--surface);
  box-shadow: var(--shadow-panel);
  padding: 1.5rem 1.5rem 2.5rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

@media (prefers-reduced-motion: no-preference) {
  .detail-inner {
    animation: slide-in 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  }
}
@keyframes slide-in {
  from { transform: translateX(24px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

.detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.detail-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.7rem;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
}
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-control);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
}
.icon-btn svg {
  width: 14px;
  height: 14px;
}
.icon-btn:hover {
  background: var(--surface-sunken);
  color: var(--text);
}

#detail-title {
  font-size: 21px;
  font-weight: 650;
  letter-spacing: -0.01em;
  line-height: 1.3;
}

.status-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.9rem;
  background: var(--surface-sunken);
  border-radius: var(--radius-control);
}
.status-field label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
}
#status-control {
  padding: 0.5rem 2rem 0.5rem 0.7rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-control);
  background: var(--surface);
  width: max-content;
  max-width: 100%;
}
#status-control:focus-visible {
  box-shadow: var(--focus-ring);
  outline: none;
}
.detail-feedback {
  font-size: 13px;
  color: var(--accent-strong);
  font-weight: 600;
  min-height: 1.2em;
}

.detail-meta-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.9rem 1rem;
}
.detail-meta-grid dt {
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-faint);
  margin-bottom: 0.2rem;
}
.detail-meta-grid dd {
  font-size: 14px;
  color: var(--text);
}

.detail-tags {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  list-style: none;
  padding: 0;
}
.detail-tags:empty {
  display: none;
}

.detail-body {
  border-top: 1px solid var(--border);
  padding-top: 1.1rem;
  color: var(--text-muted);
  font-size: 14.5px;
  line-height: 1.65;
  white-space: pre-line;
}

/* Mobile */
@media (max-width: 760px) {
  .layout {
    grid-template-columns: 1fr;
  }
  .rail {
    display: none;
  }
  .content {
    padding: 1.1rem 1rem 2.5rem;
  }
  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }
  .filter-field {
    flex: 1 1 auto;
  }
  #filter-select {
    width: 100%;
  }
  .item-meta {
    gap: 0.6rem 0.9rem;
  }
  .detail-inner {
    width: 100%;
    padding: 1.25rem 1.1rem 2rem;
  }
  .detail-meta-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}
