:root {
  --bg: #f3efe7;
  --surface: #fffaf2;
  --surface-strong: #fff;
  --border: #d9ceba;
  --text: #1f2933;
  --muted: #64707d;
  --accent: #1e5f5a;
  --accent-soft: #dcefe6;
  --danger: #8c2f39;
  --shadow: 0 14px 35px rgba(53, 41, 27, 0.08);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(30, 95, 90, 0.14), transparent 30%),
    linear-gradient(180deg, #f8f5ef, var(--bg));
  color: var(--text);
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin-top: 0; font-family: "Iowan Old Style", "Georgia", serif; }
pre { white-space: pre-wrap; font-family: inherit; margin: 0; }
textarea, input, select, button {
  font: inherit;
}

.site-header {
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  backdrop-filter: blur(8px);
  background: rgba(255, 250, 242, 0.85);
  position: sticky;
  top: 0;
  z-index: 10;
}
.site-header__inner, .page-shell {
  width: min(1380px, calc(100% - 32px));
  margin: 0 auto;
}
.site-header__inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 68px;
}
.brand {
  font-size: 1.2rem;
  font-weight: 700;
}
.nav-links, .header-actions, .form-actions, .inline-actions, .note-item__footer, .chat-message__meta, .suggestion-actions, .row-actions {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}
.page-shell {
  padding: 24px 0 48px;
}
.card, .auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
}
.card {
  padding: 20px;
}
.compact-card {
  padding: 18px;
}
.auth-card, .narrow-card {
  width: min(560px, 100%);
  margin: 48px auto 0;
  padding: 28px;
}
.stack-form {
  display: grid;
  gap: 14px;
}
label {
  display: grid;
  gap: 6px;
  font-weight: 600;
}
input, textarea, select {
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid #b7c0c8;
  background: var(--surface-strong);
}
button, .button-link {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  border-radius: 999px;
  border: none;
  padding: 10px 16px;
  background: var(--accent);
  color: white;
  cursor: pointer;
  text-decoration: none;
}
.button-link--secondary, .mini-button, .link-button {
  background: var(--accent-soft);
  color: var(--accent);
}
.mini-button {
  padding: 6px 10px;
}
.link-button {
  padding: 0;
  border-radius: 0;
}
.danger-button, .danger-link {
  background: #f7e0e3;
  color: var(--danger);
}
.inline-form {
  display: inline;
}
.muted, .helper-text {
  color: var(--muted);
}
.flash {
  margin-bottom: 18px;
  padding: 12px 16px;
  border-radius: 14px;
}
.flash-success { background: #dbeee0; color: #144e2e; }
.flash-error { background: #f8d7da; color: #6d1f29; }
.flash-info { background: #d9ebf8; color: #184f70; }
.page-header, .detail-header, .section-title {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 18px;
}
.detail-grid {
  display: grid;
  grid-template-columns: 1.05fr 1.45fr 1.2fr;
  gap: 18px;
  align-items: start;
}
.panel {
  display: grid;
  gap: 18px;
}
.panel-right {
  position: sticky;
  top: 92px;
}
.meta-badges {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.badge, .status-pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.9rem;
  background: #efe4d3;
}
.status-pill--todo { background: #e7edf3; color: #43515d; }
.status-pill--doing { background: #dbeafe; color: #1d4f91; }
.status-pill--done { background: #c8ead1; color: #22543d; }
.status-pill--blocked { background: #f7dfe2; color: #7a2631; }
.status-pill--parked { background: #f0ead3; color: #66511c; }
.focus-inline {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.focus-inline__link {
  font-weight: 600;
  text-decoration: none;
}
.focus-inline__link:hover {
  text-decoration: underline;
}
.focus-title {
  font-weight: 700;
  font-size: 1.05rem;
}
.card-subsection {
  padding-top: 16px;
  margin-top: 16px;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
}
.compact-section-title {
  margin-bottom: 10px;
}
.compact-section-title h2 {
  margin: 0;
}
.card-title-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}
.compact-helper-text {
  margin: 0 0 10px;
}
.compact-entry-form {
  gap: 10px;
}
.task-tree-heading {
  margin-bottom: 10px;
}
.task-tree-heading h2 {
  margin: 0;
}
.task-tree-root-form {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  align-items: center;
  padding-top: 10px;
  padding-bottom: 12px;
  margin-top: 10px;
  margin-bottom: 12px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}
.selected-task-card {
  padding: 14px;
}
.selected-task-heading {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.selected-task-heading h2 {
  margin: 0;
  font-size: 1.2rem;
}
.selected-task-card h3 {
  margin: 0;
  font-size: 1rem;
}
.selected-task-card .card-subsection {
  padding-top: 10px;
  margin-top: 10px;
}
.selected-task-card label {
  gap: 4px;
  font-size: 0.92rem;
}
.selected-task-card input,
.selected-task-card textarea,
.selected-task-card select {
  padding: 8px 10px;
  border-radius: 10px;
}
.selected-task-card textarea {
  min-height: 58px;
  resize: vertical;
}
.selected-task-form {
  gap: 9px;
}
.compact-button {
  justify-self: start;
  padding: 7px 12px;
  font-size: 0.92rem;
  white-space: nowrap;
}
.selected-task-child-heading {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}
.selected-task-child-heading span {
  font-weight: 600;
  font-size: 0.92rem;
}
.selected-task-title-actions {
  display: flex;
  align-items: center;
  margin-left: auto;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}
.selected-task-inline-field {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.selected-task-inline-field select {
  width: auto;
}
.selected-task-inline-field select {
  width: 116px;
}
.selected-task-status-row {
  display: block;
  margin-bottom: 9px;
}
.selected-task-status-row select {
  width: 116px;
}
.selected-task-section-title {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}
.selected-progress-section {
  display: grid;
  gap: 9px;
}
.selected-progress-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 9px;
}
.selected-progress-grid__full {
  grid-column: 1 / -1;
}
.selected-task-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}
.selected-task-delete {
  display: inline-flex;
}
.tree-list {
  display: grid;
  gap: 10px;
}
.tree-node {
  padding-left: 10px;
  border-left: 2px solid #d7ccb8;
}
.tree-node__toggle {
  margin: 0;
}
.tree-node__summary {
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  cursor: pointer;
  padding: 10px 12px;
  border-radius: 12px;
}
.tree-node__summary::-webkit-details-marker { display: none; }
.tree-node__summary--selected {
  background: #f0f7f3;
  outline: 1px solid #afd3c6;
}
.tree-node__link {
  display: flex;
  gap: 8px;
  align-items: center;
  flex: 1;
}
.tree-node__description {
  display: block;
  margin: 0 0 8px 14px;
  color: var(--muted);
}
.tree-node__children {
  display: none;
}
.tree-node[data-open="true"] > .tree-node__children {
  display: grid;
  gap: 10px;
}
.project-table {
  display: grid;
  gap: 10px;
}
.project-table__head, .project-table__row {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 0.9fr 1.2fr 1.2fr;
  gap: 12px;
  align-items: center;
}
.project-table__head {
  font-weight: 700;
}
.project-table__row {
  padding: 14px;
  background: rgba(255, 255, 255, 0.55);
  border-radius: 14px;
}
.project-group-title {
  margin-bottom: 14px;
}
.badge--active {
  background: #e4efe8;
  color: #1f5a43;
}
.badge--completed {
  background: #e8ecef;
  color: #43515d;
}
.note-list, .chat-list, .suggestion-list {
  display: grid;
  gap: 12px;
}
.note-list {
  max-height: 400px;
  overflow-y: scroll;
  padding-right: 6px;
}
.note-list::-webkit-scrollbar {
  width: 6px;
}
.note-list::-webkit-scrollbar-track {
  background: transparent;
}
.note-list::-webkit-scrollbar-thumb {
  background: #c1cad1;
  border-radius: 3px;
}
.note-list::-webkit-scrollbar-thumb:hover {
  background: #8a9baa;
}
.ai-card {
  overflow: hidden;
}
.ai-chat-list {
  max-height: 520px;
  overflow-y: auto;
  padding-right: 6px;
  align-content: start;
}
.panel-left .ai-chat-list {
  max-height: 560px;
}
.note-item, .chat-message, .suggestion-item {
  padding: 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.6);
  border: 1px solid rgba(0, 0, 0, 0.06);
}
.chat-message--assistant {
  background: #f5fbf8;
}

@media (max-width: 1100px) {
  .detail-grid {
    grid-template-columns: 1fr;
  }
  .panel-right {
    position: static;
  }
  .ai-card,
  .ai-chat-list,
  .note-list {
    max-height: none;
    overflow: visible;
  }
}

@media (max-width: 760px) {
  .site-header__inner, .page-shell {
    width: min(100% - 20px, 100%);
  }
  .project-table__head, .project-table__row {
    grid-template-columns: 1fr;
  }
  .detail-header, .page-header, .section-title {
    align-items: flex-start;
    flex-direction: column;
  }
  .task-tree-heading {
    align-items: center;
    flex-direction: row;
  }
  .compact-section-title {
    align-items: center;
    flex-direction: row;
  }
  .task-tree-root-form {
    grid-template-columns: 1fr;
  }
  .selected-progress-grid {
    grid-template-columns: 1fr;
  }
  .selected-progress-grid__full {
    grid-column: auto;
  }
  .selected-task-section-title {
    align-items: flex-start;
    flex-direction: column;
  }
}
