/* Kanagawa Wave theme for strand */

:root {
  --bg-darkest:   #16161D;
  --bg-main:      #1F1F28;
  --bg-panel:     #2A2A37;
  --bg-hover:     #363646;
  --text-primary: #DCD7BA;
  --text-muted:   #727169;
  --accent-blue:  #7E9CD8;
  --accent-link:  #7FB4CA;
  --accent-orange:#FFA066;
  --warn-yellow:  #FF9E3B;
  --err-red:      #C34043;
  --ok-green:     #76946A;
  --accent-violet:#957FB8;
  --accent-aqua:  #7AA89F;
  --radius:       8px;
  --radius-sm:    4px;
}

/* Reset */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg-main);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

a {
  color: var(--accent-link);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* Top nav — desktop */
.top-nav {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0.75rem 1.25rem;
  background: var(--bg-darkest);
  border-bottom: 1px solid var(--bg-panel);
}

.nav-brand {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--accent-orange);
}

.nav-brand:hover {
  text-decoration: none;
}

.nav-links {
  display: flex;
  gap: 1rem;
}

.nav-link {
  color: var(--text-muted);
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-sm);
  transition: color 0.15s, background 0.15s;
}

.nav-link:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
  text-decoration: none;
}

.nav-link.active {
  color: var(--accent-blue);
}

/* Bottom nav — mobile */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-darkest);
  border-top: 1px solid var(--bg-panel);
  padding: 0.5rem 0;
  padding-bottom: max(0.5rem, env(safe-area-inset-bottom));
  z-index: 100;
}

.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.125rem;
  color: var(--text-muted);
  padding: 0.25rem;
  min-width: 64px;
  min-height: 44px;
  justify-content: center;
  transition: color 0.15s;
}

.bottom-nav-item:hover {
  text-decoration: none;
}

.bottom-nav-item.active {
  color: var(--accent-blue);
}

.nav-icon {
  font-size: 1.25rem;
  line-height: 1;
}

.nav-label {
  font-size: 0.7rem;
  font-weight: 500;
}

/* Content */
.content {
  flex: 1;
  padding: 1rem 1.25rem;
  padding-bottom: 1rem;
  max-width: 48rem;
  width: 100%;
  margin: 0 auto;
}

/* Page header */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.page-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--accent-orange);
}

/* Filter bar */
.filter-bar {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.filter-bar select {
  background: var(--bg-panel);
  color: var(--text-primary);
  border: 1px solid var(--bg-hover);
  border-radius: var(--radius-sm);
  padding: 0.375rem 0.625rem;
  font-size: 0.875rem;
  cursor: pointer;
  min-height: 36px;
}

.filter-bar select:focus {
  outline: none;
  border-color: var(--accent-blue);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  border: none;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
  min-height: 44px;
  color: var(--text-primary);
}

.btn:hover {
  text-decoration: none;
}

.btn-primary {
  background: var(--accent-blue);
  color: var(--bg-darkest);
}

.btn-primary:hover {
  opacity: 0.9;
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  padding: 0.375rem 0.5rem;
  min-height: 36px;
}

.btn-ghost:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.btn-danger {
  background: transparent;
  color: var(--err-red);
  padding: 0.375rem 0.5rem;
  min-height: 36px;
}

.btn-danger:hover {
  background: var(--bg-hover);
}

.btn-done {
  background: transparent;
  color: var(--ok-green);
  padding: 0.375rem 0.5rem;
  min-height: 36px;
}

.btn-done:hover {
  background: var(--bg-hover);
}

/* Task list */
.task-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.task-empty {
  text-align: center;
  color: var(--text-muted);
  padding: 3rem 1rem;
  font-size: 0.9375rem;
}

/* Task card */
.task-card {
  background: var(--bg-panel);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  border-left: 3px solid transparent;
  transition: background 0.15s;
}

.task-card:hover {
  background: var(--bg-hover);
}

.task-card.priority-urgent {
  border-left-color: var(--err-red);
}

.task-card.priority-high {
  border-left-color: var(--warn-yellow);
}

.task-card.priority-medium {
  border-left-color: var(--accent-blue);
}

.task-card.priority-low {
  border-left-color: var(--text-muted);
}

.task-card.status-done {
  opacity: 0.6;
}

.task-card-header {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
}

.task-card-main {
  flex: 1;
  min-width: 0;
}

.task-title {
  font-size: 0.9375rem;
  font-weight: 500;
  word-break: break-word;
}

.task-title a {
  color: var(--text-primary);
}

.task-title a:hover {
  color: var(--accent-link);
}

.task-card.status-done .task-title {
  text-decoration: line-through;
  color: var(--text-muted);
}

.task-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem 0.75rem;
  margin-top: 0.25rem;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.task-meta-item {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.task-date.overdue {
  color: var(--err-red);
  font-weight: 500;
}

.task-actions {
  display: flex;
  gap: 0.25rem;
  flex-shrink: 0;
}

/* Tags */
.tag {
  display: inline-block;
  font-size: 0.75rem;
  padding: 0.125rem 0.5rem;
  border-radius: 9999px;
  background: var(--bg-hover);
  color: var(--accent-aqua);
}

/* Priority badge */
.priority-badge {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.priority-badge.priority-urgent {
  color: var(--err-red);
}

.priority-badge.priority-high {
  color: var(--warn-yellow);
}

.priority-badge.priority-medium {
  color: var(--text-primary);
}

.priority-badge.priority-low {
  color: var(--text-muted);
}

/* Status badge */
.status-badge {
  font-size: 0.75rem;
  padding: 0.125rem 0.5rem;
  border-radius: 9999px;
}

.status-badge.status-pending {
  background: var(--bg-hover);
  color: var(--text-muted);
}

.status-badge.status-in-progress {
  background: var(--bg-hover);
  color: var(--accent-blue);
}

.status-badge.status-done {
  background: var(--bg-hover);
  color: var(--ok-green);
}

.status-badge.status-active {
  background: var(--bg-hover);
  color: var(--accent-orange);
}

.status-badge.status-backlog {
  background: var(--bg-hover);
  color: var(--accent-violet);
}

/* Task detail */
.task-detail {
  padding: 1rem 0;
}

.task-detail-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.task-detail-title {
  font-size: 1.125rem;
  font-weight: 600;
}

.task-detail-body {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.task-description {
  color: var(--text-primary);
  font-size: 0.9375rem;
  line-height: 1.6;
  white-space: pre-wrap;
}

.task-field {
  display: flex;
  gap: 0.5rem;
  font-size: 0.875rem;
}

.task-field-label {
  color: var(--text-muted);
  min-width: 5rem;
}

.task-field-value {
  color: var(--text-primary);
}

/* Steps */
.steps-list {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.step-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.375rem 0.5rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s;
  min-height: 44px;
}

.step-item:hover {
  background: var(--bg-hover);
}

.step-checkbox {
  width: 1.125rem;
  height: 1.125rem;
  border-radius: var(--radius-sm);
  border: 2px solid var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 0.75rem;
  color: transparent;
  transition: all 0.15s;
}

.step-item.done .step-checkbox {
  border-color: var(--ok-green);
  background: var(--ok-green);
  color: var(--bg-darkest);
}

.step-text {
  font-size: 0.875rem;
}

.step-item.done .step-text {
  text-decoration: line-through;
  color: var(--text-muted);
}

/* Forms */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  margin-bottom: 0.75rem;
}

.form-label {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-muted);
}

.form-input,
.form-select,
.form-textarea {
  background: var(--bg-main);
  color: var(--text-primary);
  border: 1px solid var(--bg-hover);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.75rem;
  font-size: 0.9375rem;
  font-family: inherit;
  min-height: 44px;
  transition: border-color 0.15s;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--accent-blue);
}

.form-textarea {
  resize: vertical;
  min-height: 5rem;
}

.form-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

/* Task form panel */
.task-form-panel {
  background: var(--bg-panel);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1rem;
}

/* Chat */
.chat-container {
  display: flex;
  flex-direction: column;
  height: calc(100dvh - 7rem);
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 0.5rem 0;
}

.chat-message {
  max-width: 85%;
  padding: 0.625rem 0.875rem;
  border-radius: var(--radius);
  font-size: 0.9375rem;
  line-height: 1.5;
  word-break: break-word;
}

.chat-message.user {
  align-self: flex-end;
  background: var(--accent-blue);
  color: var(--bg-darkest);
  border-bottom-right-radius: var(--radius-sm);
}

.chat-message.assistant {
  align-self: flex-start;
  background: var(--bg-panel);
  color: var(--text-primary);
  border-bottom-left-radius: var(--radius-sm);
}

.chat-message.assistant p {
  margin: 0.25rem 0;
}

.chat-message.assistant p:first-child {
  margin-top: 0;
}

.chat-message.assistant p:last-child {
  margin-bottom: 0;
}

.chat-message.assistant code {
  background: var(--bg-main);
  padding: 0.125rem 0.375rem;
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
}

.chat-message.assistant pre {
  background: var(--bg-main);
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  margin: 0.5rem 0;
}

.chat-message.assistant pre code {
  background: none;
  padding: 0;
}

.chat-message.assistant ul,
.chat-message.assistant ol {
  padding-left: 1.25rem;
  margin: 0.25rem 0;
}

.chat-input-area {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem 0;
  border-top: 1px solid var(--bg-panel);
  align-items: flex-end;
  flex-wrap: wrap;
}

.chat-project-select {
  background: var(--bg-panel);
  color: var(--text-primary);
  border: 1px solid var(--bg-hover);
  border-radius: var(--radius-sm);
  padding: 0.375rem 0.625rem;
  font-size: 0.8125rem;
  font-family: inherit;
  min-height: 44px;
  cursor: pointer;
  flex-shrink: 0;
}

.chat-project-select:focus {
  outline: none;
  border-color: var(--accent-blue);
}

.chat-input-wrapper {
  flex: 1;
  position: relative;
  min-width: 0;
}

.chat-input {
  width: 100%;
  background: var(--bg-panel);
  color: var(--text-primary);
  border: 1px solid var(--bg-hover);
  border-radius: var(--radius);
  padding: 0.625rem 0.875rem;
  font-size: 0.9375rem;
  font-family: inherit;
  min-height: 44px;
  resize: none;
}

.chat-input:focus {
  outline: none;
  border-color: var(--accent-blue);
}

/* Mention popup */
.mention-popup {
  position: absolute;
  bottom: 100%;
  left: 0;
  right: 0;
  background: var(--bg-darkest);
  border: 1px solid var(--bg-hover);
  border-radius: var(--radius);
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.3);
  max-height: 15rem;
  overflow-y: auto;
  z-index: 200;
  margin-bottom: 0.25rem;
}

.mention-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  min-height: 44px;
  cursor: pointer;
  transition: background 0.1s;
}

.mention-item:hover,
.mention-item.selected {
  background: var(--bg-hover);
}

.mention-item-id {
  color: var(--accent-blue);
  font-weight: 600;
  font-size: 0.8125rem;
  flex-shrink: 0;
  min-width: 2.5rem;
}

.mention-item-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.875rem;
}

.mention-item-meta {
  color: var(--text-muted);
  font-size: 0.75rem;
  flex-shrink: 0;
}

.chat-send {
  background: var(--accent-blue);
  color: var(--bg-darkest);
  border: none;
  border-radius: var(--radius);
  padding: 0.5rem 1rem;
  font-size: 0.9375rem;
  font-weight: 500;
  cursor: pointer;
  min-height: 44px;
  min-width: 44px;
  transition: opacity 0.15s;
}

.chat-send:hover {
  opacity: 0.9;
}

/* Spinner / loading indicator */
.htmx-indicator {
  display: none;
}

.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
  display: inline-block;
}

.spinner {
  display: inline-block;
  color: var(--text-muted);
  font-size: 0.875rem;
  padding: 0.5rem;
}

.spinner::after {
  content: "";
  display: inline-block;
  width: 1rem;
  height: 1rem;
  border: 2px solid var(--bg-hover);
  border-top-color: var(--accent-blue);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  vertical-align: middle;
  margin-left: 0.375rem;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* History page */
.history-group {
  margin-bottom: 1.5rem;
}

.history-date {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
  padding-bottom: 0.25rem;
  border-bottom: 1px solid var(--bg-panel);
}

/* Utility */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.text-muted {
  color: var(--text-muted);
}

.mt-1 { margin-top: 0.5rem; }
.mb-1 { margin-bottom: 0.5rem; }

/* --- Responsive --- */

@media (max-width: 640px) {
  .top-nav .nav-links {
    display: none;
  }

  .bottom-nav {
    display: flex;
    justify-content: space-around;
  }

  .content {
    padding: 0.75rem;
    padding-bottom: 5rem;
  }

  .chat-container {
    height: calc(100dvh - 9rem);
  }

  .chat-input-area {
    flex-wrap: wrap;
  }

  .chat-project-select {
    width: 100%;
    order: -1;
  }

  .form-row {
    grid-template-columns: 1fr;
  }
}

@media (min-width: 641px) {
  .bottom-nav {
    display: none;
  }
}
