@font-face {
  font-family: 'Literata';
  src: url('assets/literata.ttf') format('truetype');
  font-weight: 200 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'IBM Plex Mono';
  src: url('assets/ibm-plex-mono.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  --paper: #e7eedf;
  --surface: #f5f3e6;
  --line: #7c8f6a;
  --line-soft: #cdd7bd;
  --ink: #1e2a1f;
  --ink-soft: #52604a;
  --status-todo: #4f5d47;
  --status-progress: #8f5f13;
  --status-blocked: #a3352a;
  --status-done: #2a6b41;
  --focus-ring: #1e2a1f;

  --font-serif: 'Literata', Georgia, 'Times New Roman', serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;
}

* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
}

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

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--ink);
  color: var(--paper);
  padding: 0.6em 1em;
  z-index: 100;
  border-radius: 0 0 4px 0;
}

.skip-link:focus {
  left: 0;
}

:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

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

.mono {
  font-family: var(--font-mono);
}

/* ---------- Header ---------- */

.app-header {
  border-bottom: 1px solid var(--line);
  padding: 1.5rem clamp(1rem, 3vw, 2.5rem) 1.25rem;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1.25rem;
  background: var(--paper);
}

.brand-mark {
  margin: 0;
  font-size: 1.9rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.brand-tag {
  margin: 0.15rem 0 0;
  color: var(--ink-soft);
  font-size: 0.95rem;
}

.controls {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  align-items: flex-end;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.field label {
  font-size: 0.85rem;
  color: var(--ink-soft);
}

.field input,
.field select {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 3px;
  padding: 0.5rem 0.7rem;
  font-size: 0.95rem;
  color: var(--ink);
  min-width: 14rem;
}

.field select {
  min-width: 12rem;
}

.field input:focus-visible,
.field select:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 1px;
}

/* ---------- Workspace layout ---------- */

.workspace {
  display: flex;
  align-items: stretch;
  min-height: calc(100vh - 96px);
}

.list-pane {
  flex: 1 1 46%;
  max-width: 640px;
  border-right: 1px solid var(--line);
  padding: 1.5rem clamp(1rem, 3vw, 2rem);
  overflow-y: auto;
}

.list-pane-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.list-pane-head h2 {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 600;
}

.list-count {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--ink-soft);
}

.task-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--line-soft);
}

.task-item {
  border-bottom: 1px solid var(--line-soft);
}

.task-open {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  padding: 0.9rem 0.4rem;
  cursor: pointer;
  border-radius: 3px;
}

.task-open:hover {
  background: var(--surface);
}

.task-item.is-active .task-open {
  background: var(--surface);
  box-shadow: inset 3px 0 0 var(--ink);
}

.task-no {
  flex: 0 0 auto;
  color: var(--ink-soft);
  font-size: 0.78rem;
  min-width: 3.4rem;
}

.task-main {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.task-title {
  font-size: 1.02rem;
  font-weight: 500;
  color: var(--ink);
  overflow-wrap: anywhere;
}

.task-meta {
  display: flex;
  flex-wrap: wrap;
  color: var(--ink-soft);
  font-size: 0.85rem;
}

.task-meta .meta-item {
  padding-left: 0;
}

.task-meta .meta-item + .meta-item {
  border-left: 1px solid var(--line);
  margin-left: 0.55rem;
  padding-left: 0.55rem;
}

.task-status {
  flex: 0 0 auto;
  font-size: 0.75rem;
  padding: 0.15rem 0.45rem;
  border: 1px solid currentColor;
  border-radius: 2px;
  white-space: nowrap;
}

.status-todo { color: var(--status-todo); }
.status-in-progress { color: var(--status-progress); }
.status-blocked { color: var(--status-blocked); }
.status-done { color: var(--status-done); }

.empty-state {
  padding: 2.5rem 1rem;
  text-align: center;
  color: var(--ink-soft);
}

.empty-state p {
  margin: 0 0 1rem;
}

.empty-state button {
  border: 1px solid var(--ink);
  background: var(--surface);
  padding: 0.5rem 1rem;
  border-radius: 3px;
  cursor: pointer;
  font-size: 0.9rem;
}

.empty-state button:hover {
  background: var(--paper);
}

/* ---------- Detail pane ---------- */

.detail-pane {
  flex: 1 1 54%;
  padding: 1.5rem clamp(1rem, 3vw, 2.5rem);
  overflow-y: auto;
  background: var(--paper);
}

.detail-placeholder {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-soft);
  text-align: center;
  padding: 2rem;
}

.detail-card {
  max-width: 640px;
}

.detail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.docket-no {
  color: var(--ink-soft);
  font-size: 0.85rem;
  margin: 0;
}

.close-detail {
  border: 1px solid var(--line);
  background: var(--surface);
  padding: 0.4rem 0.9rem;
  border-radius: 3px;
  cursor: pointer;
  font-size: 0.9rem;
}

.close-detail:hover {
  background: var(--paper);
  border-color: var(--ink);
}

.detail-title {
  margin: 0 0 1rem;
  font-size: 1.7rem;
  font-weight: 600;
  line-height: 1.25;
  max-width: 30ch;
}

.stamp {
  display: inline-block;
  border: 2px solid var(--status-todo);
  color: var(--status-todo);
  font-family: var(--font-mono);
  font-size: 0.95rem;
  padding: 0.3rem 0.9rem;
  border-radius: 2px;
  transform: rotate(-2deg);
  margin-bottom: 1.5rem;
}

.stamp.status-todo { border-color: var(--status-todo); color: var(--status-todo); }
.stamp.status-in-progress { border-color: var(--status-progress); color: var(--status-progress); }
.stamp.status-blocked { border-color: var(--status-blocked); color: var(--status-blocked); }
.stamp.status-done { border-color: var(--status-done); color: var(--status-done); }

@media (prefers-reduced-motion: no-preference) {
  .stamp.just-stamped {
    animation: stamp-hit 0.32s ease-out;
  }
}

@keyframes stamp-hit {
  0% { transform: rotate(-2deg) scale(1.35); opacity: 0.4; }
  100% { transform: rotate(-2deg) scale(1); opacity: 1; }
}

.detail-fields {
  margin: 0 0 1.25rem;
  border-top: 1px solid var(--line-soft);
}

.field-row {
  display: grid;
  grid-template-columns: 7rem 1fr;
  gap: 0.75rem;
  align-items: center;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--line-soft);
  margin: 0;
}

.field-row dt.field-label,
.field-row label.field-label {
  color: var(--ink-soft);
  font-size: 0.9rem;
}

.field-row dd.field-value {
  margin: 0;
}

.status-select {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 3px;
  padding: 0.4rem 0.6rem;
  font-size: 0.95rem;
  width: fit-content;
}

.status-select:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 1px;
}

.detail-feedback {
  min-height: 1.4rem;
  color: var(--status-done);
  font-size: 0.9rem;
  margin: -0.5rem 0 1.25rem;
}

.detail-feedback:empty {
  margin: 0;
}

.detail-body p {
  margin: 0 0 1rem;
  max-width: 62ch;
}

/* ---------- Responsive: mobile overlay detail ---------- */

@media (max-width: 780px) {
  .app-header {
    padding: 1.25rem 1rem 1rem;
  }

  .controls {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
  }

  .field {
    flex: 1 1 auto;
  }

  .field input,
  .field select {
    min-width: 0;
    width: 100%;
  }

  .workspace {
    display: block;
  }

  .list-pane {
    max-width: none;
    border-right: none;
    padding: 1.25rem 1rem;
  }

  .detail-pane {
    position: fixed;
    inset: 0;
    top: 0;
    transform: translateX(100%);
    transition: transform 0.28s ease;
    z-index: 20;
    padding: 1.25rem 1rem 2rem;
    overflow-y: auto;
  }

  .detail-pane.is-open {
    transform: translateX(0);
  }

  @media (prefers-reduced-motion: reduce) {
    .detail-pane {
      transition: none;
    }
  }

  .detail-placeholder {
    display: none;
  }

  .task-no {
    display: none;
  }

  .task-open {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .task-meta {
    flex-direction: column;
    gap: 0.15rem;
  }

  .task-meta .meta-item + .meta-item {
    border-left: none;
    margin-left: 0;
    padding-left: 0;
  }
}
