:root {
  --bg: #f6f8fa;
  --panel: #ffffff;
  --panel-soft: #f6f8fa;
  --header: #1f2328;
  --header-soft: #2d333b;
  --text: #24292f;
  --muted: #57606a;
  --line: #d0d7de;
  --line-strong: #8c959f;
  --accent: #0969da;
  --accent-soft: #ddf4ff;
  --danger: #cf222e;
  --danger-soft: #ffebe9;
  --success: #1a7f37;
  --success-soft: #dafbe1;
  --shadow: 0 1px 2px rgba(27, 31, 36, 0.04);
  --radius: 10px;
  --radius-lg: 14px;
  --max-width: 1280px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 14px;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
}

button,
input,
select,
textarea,
a {
  font: inherit;
}

button {
  cursor: pointer;
}

code {
  padding: 2px 6px;
  border-radius: 6px;
  background: #eef2f6;
  color: var(--text);
}

.hidden {
  display: none !important;
}

.site-header {
  background: var(--header);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  color: #ffffff;
}

.site-header-inner {
  display: flex;
  align-items: center;
  gap: 16px;
  width: min(100%, var(--max-width));
  margin: 0 auto;
  padding: 14px 20px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 7px;
  background: var(--header-soft);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #ffffff;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.brand-copy {
  display: grid;
  gap: 2px;
}

.brand-copy strong {
  font-size: 0.98rem;
  font-weight: 600;
}

.brand-copy span {
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.84rem;
}

.header-search {
  flex: 1 1 360px;
  display: grid;
  gap: 4px;
  max-width: 460px;
}

.header-search-label {
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.82rem;
}

.header-search input {
  width: 100%;
  height: 36px;
  padding: 0 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
  outline: none;
}

.header-search input::placeholder {
  color: rgba(255, 255, 255, 0.55);
}

.header-search input:focus {
  border-color: rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.12);
}

.header-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-left: auto;
}

.auth-pill {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.88);
  white-space: nowrap;
}

.top-button,
.list-button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 0 12px;
  border-radius: 8px;
  border: 1px solid transparent;
  text-decoration: none;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease;
}

.top-button-primary,
.list-button-primary {
  background: var(--accent);
  color: #ffffff;
}

.top-button-primary:hover,
.list-button-primary:hover,
.top-button-primary:focus-visible,
.list-button-primary:focus-visible {
  background: #0550ae;
}

.top-button-secondary,
.list-button-secondary,
.icon-button {
  background: var(--panel);
  color: var(--text);
  border-color: var(--line);
}

.top-button-secondary:hover,
.list-button-secondary:hover,
.icon-button:hover,
.top-button-secondary:focus-visible,
.list-button-secondary:focus-visible,
.icon-button:focus-visible {
  border-color: var(--line-strong);
}

.list-button-danger {
  color: var(--danger);
  background: #ffffff;
  border-color: #f0b6b3;
}

.list-button-danger:hover,
.list-button-danger:focus-visible {
  background: var(--danger-soft);
}

.top-button[disabled],
.list-button[disabled] {
  opacity: 0.55;
  cursor: not-allowed;
}

.page-shell {
  width: min(100%, var(--max-width));
  margin: 0 auto;
  padding: 16px 20px 40px;
}

.section-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 1.5rem;
  line-height: 1.2;
}

h2 {
  font-size: 1.22rem;
  line-height: 1.3;
}

h3 {
  font-size: 1rem;
  line-height: 1.4;
}

.page-description,
.section-note,
.bookmark-subtitle,
.panel-note {
  color: var(--muted);
  line-height: 1.5;
}

.summary-pill {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  color: var(--muted);
  font-weight: 600;
}

.status-message {
  margin: 16px 0 0;
  padding: 11px 14px;
  border: 1px solid #b6e3c2;
  border-radius: 10px;
  background: var(--success-soft);
  color: var(--success);
}

.status-message.error {
  border-color: #f0b6b3;
  background: var(--danger-soft);
  color: var(--danger);
}

.section-panel {
  margin-top: 16px;
  padding: 20px 24px;
}

.page-shell > .section-panel:first-of-type {
  margin-top: 0;
}

.section-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px;
  align-items: end;
}

.section-head-side {
  display: grid;
  gap: 8px;
  justify-items: end;
}

.category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-top: 18px;
}

.category-tile {
  display: grid;
  gap: 14px;
  width: 100%;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  color: var(--text);
  text-align: left;
}

.category-tile:hover,
.category-tile:focus-visible {
  border-color: var(--line-strong);
}

.category-tile.active {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
  background: #f4f9ff;
}

.category-tile-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.icon-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  color: var(--muted);
}

.icon-chip svg {
  width: 18px;
  height: 18px;
}

.category-count {
  color: var(--muted);
  font-size: 0.88rem;
}

.bookmark-table {
  margin-top: 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}

.bookmark-table-head,
.bookmark-row {
  display: grid;
  grid-template-columns: minmax(0, 2.4fr) minmax(180px, 1.1fr) minmax(180px, 1.1fr) auto;
  gap: 16px;
  align-items: center;
}

.bookmark-table-head {
  padding: 11px 16px;
  background: var(--panel-soft);
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.bookmark-row {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: #ffffff;
}

.bookmark-row:last-child {
  border-bottom: 0;
}

.bookmark-main {
  display: flex;
  align-items: start;
  gap: 12px;
  min-width: 0;
}

.bookmark-copy {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.bookmark-title {
  display: inline-block;
  max-width: 100%;
  color: var(--text);
  font-weight: 600;
  text-decoration: none;
}

.bookmark-title-button {
  padding: 0;
  border: 0;
  background: transparent;
  text-align: left;
}

.bookmark-title:hover,
.bookmark-title:focus-visible,
.bookmark-title-button:hover,
.bookmark-title-button:focus-visible {
  color: var(--accent);
}

.bookmark-meta-line {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  color: var(--muted);
  font-size: 0.84rem;
}

.bookmark-type-pill {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  background: #eef2f6;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.bookmark-subtitle {
  margin-top: 4px;
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bookmark-command-preview {
  margin-top: 2px;
}

.bookmark-command-preview code {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.category-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  color: var(--muted);
}

.category-pill svg {
  width: 14px;
  height: 14px;
}

.bookmark-category-stack {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.bookmark-tag-stack {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #ffffff;
  color: var(--muted);
}

button.tag-pill {
  cursor: pointer;
}

button.tag-pill:hover,
button.tag-pill:focus-visible {
  border-color: var(--accent);
  color: var(--accent);
  background: #f4f9ff;
}

.tag-pill-active {
  border-color: var(--accent);
  color: var(--accent);
  background: #f4f9ff;
}

.active-filter-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
}

.filter-label {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.bookmark-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.empty-state {
  margin-top: 18px;
  padding: 30px 16px;
  border: 1px dashed var(--line);
  border-radius: 12px;
  background: var(--panel-soft);
  text-align: center;
  color: var(--muted);
}

.backdrop {
  position: fixed;
  inset: 0;
  background: rgba(31, 35, 40, 0.5);
}

#panel-backdrop {
  z-index: 9;
}

.side-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: min(100%, 420px);
  height: 100vh;
  padding: 20px;
  background: #ffffff;
  border-left: 1px solid var(--line);
  box-shadow: -6px 0 20px rgba(27, 31, 36, 0.12);
  overflow-y: auto;
  z-index: 10;
}

.confirm-backdrop {
  z-index: 19;
}

.confirm-dialog {
  position: fixed;
  top: 50%;
  left: 50%;
  width: min(100% - 24px, 460px);
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: 0 18px 48px rgba(27, 31, 36, 0.18);
  transform: translate(-50%, -50%);
  z-index: 20;
}

.details-backdrop {
  z-index: 24;
}

.details-dialog {
  position: fixed;
  top: 50%;
  left: 50%;
  width: min(100% - 24px, 680px);
  max-height: min(80vh, 720px);
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: 0 18px 48px rgba(27, 31, 36, 0.18);
  transform: translate(-50%, -50%);
  overflow-y: auto;
  z-index: 25;
}

.confirm-dialog-copy {
  display: grid;
  gap: 8px;
}

.details-dialog-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}

.details-dialog-body {
  display: grid;
  gap: 16px;
  margin-top: 16px;
}

.details-description {
  color: var(--muted);
  line-height: 1.5;
}

.details-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.details-item,
.details-section {
  display: grid;
  gap: 6px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-soft);
}

.details-label {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.details-value {
  color: var(--text);
  line-height: 1.5;
}

.details-value-prewrap {
  white-space: pre-wrap;
}

.details-code {
  margin: 0;
  padding: 12px;
  border-radius: 10px;
  background: #0d1117;
  color: #e6edf3;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.9rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.confirm-message {
  color: var(--text);
  line-height: 1.5;
}

.confirm-details {
  color: var(--muted);
  line-height: 1.5;
}

.confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

.details-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}

.confirm-button-danger {
  background: var(--danger);
  color: #ffffff;
}

.confirm-button-danger:hover,
.confirm-button-danger:focus-visible {
  background: #a40e26;
}

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

.icon-button {
  width: 34px;
  padding: 0;
}

.panel-form {
  display: grid;
  gap: 12px;
}

.panel-form-inline {
  grid-template-columns: minmax(0, 1fr) 120px auto;
  align-items: end;
}

.field {
  display: grid;
  gap: 6px;
}

.field span {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 600;
}

.field-small {
  min-width: 0;
}

.field-hint {
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.45;
}

.bookmark-type-fields {
  display: grid;
  gap: 12px;
}

.bookmark-category-checklist {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.bookmark-category-option {
  position: relative;
  display: block;
}

.bookmark-category-option input {
  position: absolute;
  width: 1px;
  height: 1px;
  min-height: 1px;
  margin: 0;
  padding: 0;
  opacity: 0;
  pointer-events: none;
}

.bookmark-category-option-label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-soft);
  color: var(--text);
}

.bookmark-category-option-label .icon-chip {
  width: 28px;
  height: 28px;
}

.bookmark-category-option input:checked + .bookmark-category-option-label {
  border-color: var(--accent);
  background: #f4f9ff;
  box-shadow: inset 0 0 0 1px var(--accent);
}

.bookmark-category-option input:focus-visible + .bookmark-category-option-label {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(9, 105, 218, 0.12);
}

input,
select,
textarea {
  width: 100%;
  min-height: 36px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
  outline: none;
}

textarea {
  min-height: 90px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(9, 105, 218, 0.12);
}

.panel-note {
  margin-top: 14px;
}

.form-error {
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px solid #f0b6b3;
  border-radius: 8px;
  background: var(--danger-soft);
  color: var(--danger);
}

.panel-actions {
  display: flex;
  gap: 10px;
}

.category-manager-list {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.category-manage-row {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-soft);
}

.category-manage-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.category-manage-main {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.category-manage-copy {
  min-width: 0;
}

.category-manage-copy strong {
  display: block;
}

.category-manage-copy span {
  color: var(--muted);
  font-size: 0.88rem;
}

.category-manage-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.category-edit-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 120px auto auto;
  gap: 8px;
  align-items: end;
}

body.panel-open {
  overflow: hidden;
}

@media (max-width: 980px) {
  .site-header-inner,
  .section-head {
    align-items: start;
  }

  .site-header-inner,
  .section-head,
  .panel-form-inline,
  .category-edit-grid {
    grid-template-columns: none;
  }

  .site-header-inner {
    flex-direction: column;
  }

  .header-search {
    max-width: none;
    width: 100%;
  }

  .header-actions {
    margin-left: 0;
  }

  .section-head-side {
    justify-items: start;
  }

  .bookmark-table-head {
    display: none;
  }

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

  .bookmark-actions {
    justify-content: start;
  }

  .details-grid {
    grid-template-columns: 1fr;
  }

  .bookmark-category-checklist {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .page-shell,
  .site-header-inner {
    padding-left: 14px;
    padding-right: 14px;
  }

  .page-shell {
    padding-top: 18px;
    padding-bottom: 28px;
  }

  .section-panel,
  .confirm-dialog,
  .details-dialog {
    padding: 16px;
  }

  .header-actions,
  .panel-actions,
  .confirm-actions,
  .details-actions {
    flex-direction: column;
    width: 100%;
  }

  .top-button,
  .list-button {
    width: 100%;
  }

  .side-panel {
    width: 100%;
    padding: 16px;
  }
}
