:root {
  color-scheme: light;
  --font-body: "Source Serif 4", Georgia, "Times New Roman", serif;
  --font-ui: "Source Sans 3", system-ui, -apple-system, sans-serif;
  --radius-sm: 3px;
  --radius-md: 4px;
  --radius-lg: 6px;
  --doc-bg: #f8fafc;
  --doc-surface: #ffffff;
  --doc-border: #e2e8f0;
  --doc-text: #1e293b;
  --doc-muted: #64748b;
  --doc-accent: #2563eb;
  --doc-accent-soft: rgba(37, 99, 235, 0.08);
  font-family: var(--font-body);
  line-height: 1.55;
  font-weight: 400;
  background-color: var(--doc-bg);
  color: var(--doc-text);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--doc-bg);
  font-family: var(--font-body);
}

#root {
  min-height: 100vh;
}

.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 40px;
  border-bottom: 1px solid var(--doc-border);
  background: var(--doc-surface);
  font-family: var(--font-ui);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-logo {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--doc-border);
  display: grid;
  place-items: center;
  overflow: hidden;
  flex-shrink: 0;
  background: var(--doc-surface);
}

.brand-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.brand-title {
  font-size: 1.125rem;
  font-weight: 600;
  font-family: var(--font-ui);
  letter-spacing: -0.01em;
  margin: 0;
}

.brand-subtitle {
  margin: 2px 0 0;
  font-size: 0.8125rem;
  font-family: var(--font-body);
  color: var(--doc-muted);
}

.header-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}

.button {
  border: 1px solid var(--doc-border);
  background: var(--doc-surface);
  padding: 8px 14px;
  border-radius: var(--radius-md);
  font-size: 0.8125rem;
  font-family: var(--font-ui);
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.button:hover {
  background: #f1f5f9;
}

.button.primary {
  background: var(--doc-accent);
  color: #ffffff;
  border-color: var(--doc-accent);
}

.button.primary:hover {
  background: #1d4ed8;
  border-color: #1d4ed8;
}

.button:active {
  transform: none;
}

.app-main {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 0;
  padding: 0;
  flex: 1;
  border-top: 1px solid var(--doc-border);
}

.app-main > .panel:first-of-type {
  border-right: 1px solid var(--doc-border);
}

@media (min-width: 1101px) {
  .list-sidebar-backdrop {
    display: none !important;
  }

  .list-sidebar-close-btn {
    display: none !important;
  }

  .repo-panel-toolbar {
    display: none !important;
  }
}

.panel {
  background: var(--doc-surface);
  border-radius: 0;
  padding: 24px 28px 40px;
  box-shadow: none;
  backdrop-filter: none;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.panel-heading h2 {
  margin: 0;
}

.panel h2 {
  font-size: 0.6875rem;
  font-family: var(--font-ui);
  font-weight: 600;
  margin: 0 0 16px;
  color: var(--doc-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.panel-heading h2 {
  margin-bottom: 0;
}

.list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-radius: var(--radius-md);
  margin-bottom: 4px;
  background: var(--doc-bg);
  border: 1px solid transparent;
  font-size: 0.875rem;
  font-family: var(--font-ui);
}

.list-item.active {
  border-color: var(--doc-accent);
  background: var(--doc-accent-soft);
  color: var(--doc-text);
}

.list-panel-hint {
  margin: 0 0 12px;
}

.repo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}

@media (min-width: 1101px) {
  .repo-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
}

.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.filter-group label {
  font-size: 0.75rem;
  font-family: var(--font-ui);
  color: var(--doc-muted);
}

.filter-group select {
  padding: 6px 8px;
  border-radius: var(--radius-md);
  border: 1px solid var(--doc-border);
  background: var(--doc-surface);
  font-size: 0.75rem;
  font-family: var(--font-ui);
}

.filter-group.search {
  margin-left: auto;
}

.filter-group.search input {
  padding: 6px 8px;
  border-radius: var(--radius-md);
  border: 1px solid var(--doc-border);
  background: var(--doc-surface);
  font-size: 0.75rem;
  font-family: var(--font-ui);
  min-width: 220px;
}

.checkbox {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  font-family: var(--font-ui);
  color: var(--doc-muted);
}

.repo-card {
  background: var(--doc-surface);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  border: 1px solid var(--doc-border);
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 180px;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}

.repo-meta {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  font-size: 0.75rem;
  font-family: var(--font-ui);
  color: var(--doc-muted);
  min-width: 0;
}

.repo-meta span {
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.repo-title {
  font-weight: 600;
  font-size: 0.9375rem;
  font-family: var(--font-ui);
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.repo-desc {
  font-size: 0.8125rem;
  color: var(--doc-muted);
  margin: 0;
  flex: 1;
  min-width: 0;
  overflow-wrap: break-word;
  word-break: break-word;
}

.repo-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 0;
}

.repo-card .button {
  max-width: 100%;
  box-sizing: border-box;
}

.tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-size: 0.6875rem;
  font-family: var(--font-ui);
  font-weight: 500;
  background: var(--doc-accent-soft);
  color: var(--doc-accent);
  border: 1px solid rgba(37, 99, 235, 0.2);
  margin-right: 0;
  max-width: 100%;
  overflow-wrap: anywhere;
}

.list-manage-table {
  border: 1px solid var(--doc-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.list-manage-head,
.list-manage-row {
  display: grid;
  grid-template-columns: 1fr 72px minmax(140px, auto);
  gap: 8px;
  align-items: center;
  padding: 8px 10px;
  font-size: 0.8125rem;
  font-family: var(--font-ui);
}

.list-manage-head {
  font-weight: 600;
  color: var(--doc-muted);
  background: var(--doc-bg);
  border-bottom: 1px solid var(--doc-border);
}

.list-manage-row {
  border-bottom: 1px solid var(--doc-border);
}

.list-manage-row:last-child {
  border-bottom: none;
}

.list-manage-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.list-manage-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}

.drawer {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  display: grid;
  place-items: center;
  z-index: 40;
}

.drawer-panel {
  width: min(560px, 92vw);
  background: var(--doc-surface);
  border-radius: var(--radius-lg);
  padding: 24px;
  border: 1px solid var(--doc-border);
  box-shadow: 0 16px 48px rgba(15, 23, 42, 0.12);
  position: relative;
  font-family: var(--font-body);
}

.drawer-panel.settings {
  max-height: 85vh;
  overflow: visible;
  display: flex;
  flex-direction: column;
}

.settings-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding-right: 8px;
  padding-bottom: 16px;
  border-radius: var(--radius-md);
}

.drawer-panel h3 {
  margin: 0 0 8px;
  font-family: var(--font-ui);
  font-weight: 600;
  font-size: 1.0625rem;
}

.drawer-panel h4 {
  font-family: var(--font-ui);
}

.drawer-panel p {
  margin: 0 0 16px;
  font-size: 0.875rem;
  color: var(--doc-muted);
}

.drawer-panel p + p {
  margin-top: -6px;
}

.settings-section {
  margin-top: 20px;
  padding-top: 14px;
  border-top: 1px solid var(--doc-border);
}

.settings-section h4 {
  margin: 0 0 10px;
  font-size: 0.875rem;
}

.settings-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.settings-actions .button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.input-row.inline {
  display: flex;
  gap: 12px;
}

.input-row.inline > div {
  flex: 1;
}

.helper-text {
  font-size: 0.75rem;
  font-family: var(--font-ui);
  color: var(--doc-muted);
  margin-top: 8px;
}

.prompt-mode-card {
  border: 1px solid var(--doc-border);
  background: var(--doc-bg);
  border-radius: var(--radius-lg);
  padding: 10px 12px;
  margin: 10px 0 12px;
}

.prompt-mode-title {
  margin: 0;
  font-size: 0.75rem;
  font-family: var(--font-ui);
  color: var(--doc-muted);
  font-weight: 600;
}

.prompt-mode-value {
  margin: 4px 0 0;
  font-size: 0.75rem;
  color: var(--doc-text);
}

.advanced-prompts {
  margin-top: 10px;
  padding: 10px 12px;
  border: 1px dashed var(--doc-border);
  border-radius: var(--radius-lg);
  background: var(--doc-bg);
}

.advanced-prompts summary {
  cursor: pointer;
  font-size: 0.75rem;
  font-family: var(--font-ui);
  color: var(--doc-text);
  font-weight: 600;
  list-style: none;
}

.advanced-prompts[open] summary {
  margin-bottom: 8px;
}

.writeback-summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.writeback-summary-item {
  border: 1px solid var(--doc-border);
  border-radius: var(--radius-md);
  background: var(--doc-bg);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.writeback-summary-label {
  font-size: 0.6875rem;
  font-family: var(--font-ui);
  color: var(--doc-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.writeback-summary-value {
  font-size: 1rem;
  font-family: var(--font-ui);
  font-weight: 600;
  color: var(--doc-text);
}

.writeback-issues {
  display: grid;
  gap: 8px;
  max-height: 220px;
  overflow-y: auto;
  padding-right: 4px;
}

.writeback-issue {
  border: 1px solid var(--doc-border);
  border-radius: var(--radius-md);
  background: var(--doc-bg);
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.writeback-issue-reason {
  font-size: 0.6875rem;
  font-family: var(--font-ui);
  color: var(--doc-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.writeback-issue-msg {
  font-size: 0.75rem;
  color: var(--doc-text);
}

.assign-list-grid {
  display: grid;
  gap: 8px;
  max-height: 320px;
  overflow-y: auto;
}

.assign-list-item {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--doc-border);
  border-radius: var(--radius-md);
  background: var(--doc-bg);
  padding: 8px 10px;
  font-size: 0.8125rem;
  font-family: var(--font-ui);
  color: var(--doc-text);
}

.writeback-preview-list {
  display: grid;
  gap: 10px;
  max-height: 320px;
  overflow-y: auto;
  padding-right: 4px;
}

.writeback-preview-item {
  border: 1px solid var(--doc-border);
  border-radius: var(--radius-md);
  background: var(--doc-bg);
  padding: 10px;
}

.writeback-preview-title {
  font-size: 0.8125rem;
  font-family: var(--font-ui);
  font-weight: 600;
  margin-bottom: 6px;
}

.writeback-preview-row {
  display: flex;
  gap: 8px;
  font-size: 0.75rem;
  color: var(--doc-muted);
  margin-top: 4px;
}

.writeback-preview-label {
  min-width: 52px;
  font-weight: 600;
}

.preview-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

.preview-card {
  border: 1px solid var(--doc-border);
  border-radius: var(--radius-lg);
  padding: 12px;
  background: var(--doc-bg);
}

.preview-title {
  font-size: 0.8125rem;
  font-family: var(--font-ui);
  font-weight: 600;
  margin-bottom: 8px;
}

.preview-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 0.75rem;
  color: var(--doc-muted);
}

.diff-grid {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}

.diff-card {
  border: 1px solid var(--doc-border);
  border-radius: var(--radius-lg);
  padding: 12px;
  background: var(--doc-bg);
}

.diff-row {
  display: flex;
  gap: 8px;
  font-size: 0.75rem;
  color: var(--doc-muted);
  margin-top: 6px;
}

.diff-label {
  font-weight: 600;
  min-width: 70px;
}

.empty-state {
  padding: 16px;
  border-radius: var(--radius-lg);
  background: var(--doc-bg);
  border: 1px dashed var(--doc-border);
  font-size: 0.8125rem;
  color: var(--doc-muted);
}

.drawer-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

.input-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}

.input-row input {
  padding: 8px 10px;
  border-radius: var(--radius-md);
  border: 1px solid var(--doc-border);
  font-size: 0.8125rem;
  font-family: var(--font-ui);
  background: var(--doc-surface);
}

.input-row textarea {
  padding: 8px 10px;
  border-radius: var(--radius-md);
  border: 1px solid var(--doc-border);
  font-size: 0.75rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  background: var(--doc-surface);
  resize: vertical;
}

.input-row select {
  padding: 8px 10px;
  border-radius: var(--radius-md);
  border: 1px solid var(--doc-border);
  background: var(--doc-surface);
  font-size: 0.75rem;
  font-family: var(--font-ui);
}

.input-row label {
  font-size: 0.75rem;
  font-family: var(--font-ui);
  color: var(--doc-muted);
}

@media (max-width: 1100px) {
  .app-header {
    padding: 14px 16px;
  }

  .app-main {
    grid-template-columns: 1fr;
    border-top: none;
  }

  .app-main > .panel--star-lists {
    border-right: none;
    height: 0;
    min-height: 0;
    padding: 0;
    margin: 0;
    overflow: visible;
  }

  .panel.panel--star-lists {
    position: fixed;
    left: 0;
    top: 0;
    height: 100vh;
    height: 100dvh;
    width: min(300px, 86vw);
    z-index: 200;
    margin: 0;
    padding: 16px 14px 24px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    box-shadow: 4px 0 24px rgba(15, 23, 42, 0.12);
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    border-right: 1px solid var(--doc-border);
  }

  .panel.panel--star-lists.is-open {
    transform: translateX(0);
  }

  .list-sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 150;
    background: rgba(15, 23, 42, 0.45);
    cursor: pointer;
  }

  .panel-heading--list-sidebar {
    flex-wrap: nowrap;
    align-items: center;
  }

  .panel-heading--list-sidebar h2 {
    flex: 1;
    min-width: 0;
  }

  .list-sidebar-close-btn {
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    padding: 0;
    flex-shrink: 0;
    border: 1px solid var(--doc-border);
    background: var(--doc-surface);
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    font-family: var(--font-ui);
    color: var(--doc-text);
  }

  .repo-panel-toolbar {
    margin-bottom: 12px;
  }

  .list-sidebar-open-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    text-align: left;
    justify-content: flex-start;
  }

  .list-sidebar-open-icon {
    font-size: 1rem;
    opacity: 0.85;
  }

  .list-sidebar-open-text {
    font-weight: 600;
  }

  .list-sidebar-active-chip {
    margin-left: auto;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--doc-accent);
    max-width: 46%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .panel--repos > h2 {
    margin-bottom: 12px;
  }

  .panel.panel--repos {
    padding: 14px 10px 28px;
  }

  .repo-grid {
    grid-template-columns: 1fr;
    gap: 12px;
    min-width: 0;
  }

  .repo-card {
    min-height: 0;
    padding: 12px 12px;
  }

  .filters {
    gap: 10px;
  }

  .filter-group.search {
    margin-left: 0;
    flex: 1 1 100%;
    max-width: 100%;
  }

  .filter-group.search input {
    min-width: 0;
    width: 100%;
    max-width: 100%;
  }

  .writeback-summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
.panel-close {
  position: absolute;
  top: -18px;
  right: -18px;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  border: 1px solid var(--doc-border);
  background: var(--doc-surface);
  cursor: pointer;
  font-size: 14px;
  font-family: var(--font-ui);
  display: grid;
  place-items: center;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.1);
  z-index: 5;
}

.panel-close:hover {
  transform: translateY(-1px);
}
