:root {
  color-scheme: dark;
  --bg: #191919;
  --bg-elevated: #202020;
  --bg-hover: #2a2a2a;
  --bg-input: #2f2f2f;
  --border: #373737;
  --border-light: #2e2e2e;
  --text: #ebebeb;
  --text-secondary: #9b9b9b;
  --text-tertiary: #6f6f6f;
  --accent: #4a5568;
  --accent-hover: #5a6578;
  --accent-muted: #3a424f;
  --tag-other: #4f7ec9;
  --tag-status-new: #5a5a5a;
  --tag-status-review: #6b6b3a;
  --tag-status-progress: #3d6b8e;
  --tag-status-done: #3d6b4f;
  --tag-status-muted: #4a4a4a;
  --radius: 4px;
  --radius-lg: 8px;
  --font: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, "Apple Color Emoji", Arial, sans-serif;
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #ffffff;
  --bg-elevated: #f7f8fa;
  --bg-hover: #eef0f3;
  --bg-input: #ffffff;
  --border: #d1d5db;
  --border-light: #e5e7eb;
  --text: #20252d;
  --text-secondary: #525b68;
  --text-tertiary: #626b77;
  --accent: #45566e;
  --accent-hover: #34445b;
  --accent-muted: #e4eaf2;
  --tag-other: #3768aa;
}

.theme-toggle {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-secondary);
  font: inherit;
  padding: 6px;
  cursor: pointer;
}

.theme-toggle[hidden],
.theme-icon-moon,
:root[data-theme="light"] .theme-icon-sun { display: none; }
:root[data-theme="light"] .theme-icon-moon { display: block; }
.theme-toggle:hover { background: var(--bg-hover); color: var(--text); }
.theme-toggle:focus-visible { outline: 2px solid var(--tag-other); outline-offset: 2px; }

@media (max-width: 640px) {
  .notion-shell .notion-topbar { flex-wrap: wrap; }
  .notion-topbar .breadcrumbs { flex-basis: 100%; }
  .topbar-actions { flex-wrap: wrap; gap: 8px; max-width: 100%; }
}

:root[data-theme="light"] .primary-button:hover,
:root[data-theme="light"] input[type="file"]::file-selector-button:hover { color: #fff; }
:root[data-theme="light"] .tag-other { background: #e1eaf8; color: #294f85; }
:root[data-theme="light"] .tag-status-new,
:root[data-theme="light"] .tag-status-muted { background: #e9ebee; color: #4b535e; }
:root[data-theme="light"] .tag-status-review { background: #f1ecd1; color: #65551f; }
:root[data-theme="light"] .tag-status-progress { background: #ddebf5; color: #285777; }
:root[data-theme="light"] .tag-status-done { background: #deeee4; color: #28613e; }
:root[data-theme="light"] .errorlist,
:root[data-theme="light"] .subscriber-form-error { color: #a52c36; }
:root[data-theme="light"] .page-icon svg,
:root[data-theme="light"] .markdown-body a,
:root[data-theme="light"] .EasyMDEContainer .cm-s-easymde .cm-link,
:root[data-theme="light"] .EasyMDEContainer .cm-s-easymde .cm-url { color: #315f99; }
:root[data-theme="light"] .markdown-body a { text-decoration-color: #9db5d3; }
:root[data-theme="light"] .markdown-body a:hover { text-decoration-color: #315f99; }
:root[data-theme="light"] .portal-login-body,
:root[data-theme="light"] .portal-login { background: var(--bg-elevated); }
:root[data-theme="light"] .portal-entry {
  background: var(--bg);
  border-color: var(--border);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.08);
}
:root[data-theme="light"] .portal-entry h1,
:root[data-theme="light"] .portal-session strong { color: var(--text); }
:root[data-theme="light"] .portal-session,
:root[data-theme="light"] .portal-account-switch-link { color: var(--text-secondary); }
:root[data-theme="light"] .portal-login-error,
:root[data-theme="light"] .portal-login-error .portal-account-switch-link { color: #a52c36; }

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
a:hover { color: var(--text); }

.notion-shell { min-height: 100vh; }

.notion-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--border-light);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 10;
}

.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-secondary);
  font-size: 14px;
  min-width: 0;
}

.breadcrumbs a:hover { color: var(--text); }
.breadcrumb-sep { color: var(--text-tertiary); }
.breadcrumb-current { color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.org-switch {
  position: relative;
}

.org-switch > summary {
  list-style: none;
}

.org-switch > summary::-webkit-details-marker {
  display: none;
}

.org-switch-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
}

.org-switch-toggle:hover,
.org-switch[open] .org-switch-toggle {
  background: var(--bg-hover);
  color: var(--text);
}

.org-switch-toggle:focus-visible {
  outline: 2px solid var(--accent-hover);
  outline-offset: 1px;
}

.org-switch-caret {
  font-size: 9px;
  color: var(--text-tertiary);
}

.org-switch-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 20;
  min-width: 180px;
  margin: 0;
  padding: 4px;
  list-style: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-elevated);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.45);
}

.org-switch-option {
  display: block;
  padding: 6px 9px;
  border-radius: var(--radius);
  font-size: 13px;
  color: var(--text-secondary);
  white-space: nowrap;
}

.org-switch-option:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.org-switch-option[aria-current="page"] {
  color: var(--text);
  font-weight: 600;
}

.ghost-button, .link-button {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--text-secondary);
  font: inherit;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius);
}

.ghost-button:hover, .link-button:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.primary-button, button.primary-button, a.primary-button {
  appearance: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--accent-muted);
  color: var(--text);
  font: inherit;
  font-weight: 500;
  padding: 6px 12px;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease;
}

.primary-button:hover, a.primary-button:hover {
  background: var(--accent);
  border-color: var(--accent-hover);
  color: var(--text);
}

.topbar-submit {
  padding: 4px 10px;
  white-space: nowrap;
}

.notion-page {
  max-width: 1280px;
  margin: 0 auto;
  padding: 28px 96px 64px;
}

@media (max-width: 900px) {
  .notion-page { padding: 20px 20px 48px; }
}

.page-icon-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
}

.page-icon {
  display: inline-flex;
  align-items: center;
  line-height: 1;
}

.page-icon svg {
  width: 34px;
  height: 34px;
  color: #7ba7d9;
}

.page-icon-logo {
  display: block;
  width: 34px;
  height: 34px;
  object-fit: contain;
  border-radius: 6px;
}

.page-icon-default {
  display: inline-flex;
  align-items: center;
  line-height: 1;
}

.page-icon-logo ~ .page-icon-default {
  display: none;
}

.page-title {
  margin: 0;
  font-size: 40px;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.2;
}

.view-tabs {
  display: flex;
  align-items: center;
  gap: 2px;
  border-bottom: 1px solid var(--border-light);
  margin-bottom: 0;
  padding-bottom: 0;
}

.view-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px 8px;
  color: var(--text-secondary);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  font-size: 14px;
}

.view-tab-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--bg-hover);
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 600;
}

.view-tab:hover { color: var(--text); background: var(--bg-hover); border-radius: var(--radius) var(--radius) 0 0; }
.view-tab.active {
  color: var(--text);
  border-bottom-color: var(--text);
}

.table-toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  padding: 10px 0 8px;
}

.toolbar-button {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-secondary);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
}

.toolbar-button:hover { background: var(--bg-hover); color: var(--text); }

.toolbar-button[aria-expanded="true"] {
  background: var(--bg-hover);
  border-color: var(--border);
  color: var(--text);
}

.search-input {
  width: 220px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-input);
  color: var(--text);
  padding: 5px 8px;
  font: inherit;
}

.search-input::placeholder { color: var(--text-tertiary); }

.notion-table-wrap {
  overflow-x: auto;
  margin-top: 4px;
}

.notion-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.notion-table th {
  text-align: left;
  color: var(--text-tertiary);
  font-weight: 400;
  padding: 6px 10px;
  border-bottom: 1px solid var(--border-light);
  white-space: nowrap;
}

.notion-table td {
  padding: 4px 10px;
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
  height: 34px;
}

.notion-table tbody tr:hover { background: var(--bg-hover); }

.col-id { width: 56px; color: var(--text-tertiary); }
.col-title { min-width: 280px; }
.col-status, .col-size, .col-type, .col-project { white-space: nowrap; }

.tag {
  display: inline-flex;
  align-items: center;
  border-radius: 3px;
  padding: 1px 6px;
  font-size: 12px;
  line-height: 1.6;
  white-space: nowrap;
}

.tag-other { background: rgba(79, 126, 201, 0.35); color: #c8d8f0; }
.tag-status-new { background: rgba(90, 90, 90, 0.5); color: #d0d0d0; }
.tag-status-review { background: rgba(107, 107, 58, 0.45); color: #e0e0b8; }
.tag-status-progress { background: rgba(61, 107, 142, 0.45); color: #c8dff0; }
.tag-status-done { background: rgba(61, 107, 79, 0.45); color: #c8f0d8; }
.tag-status-muted { background: rgba(74, 74, 74, 0.5); color: #c0c0c0; }

.empty-state {
  padding: 48px 12px;
  text-align: center;
  color: var(--text-tertiary);
}

.messages {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
}

.message {
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  padding: 10px 12px;
  border-radius: var(--radius-lg);
}

.form-page {
  max-width: 708px;
  margin: 0 auto;
}

.form-hero-title {
  margin: 0 0 8px;
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.03em;
  text-align: center;
}

.form-hero-subtitle {
  margin: 0 0 28px;
  text-align: center;
  color: var(--text-secondary);
}

.form-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-elevated);
  padding: 22px;
}

.form-stack { display: grid; gap: 18px; }

.field-block label {
  display: block;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}

input, textarea, select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 10px;
  font: inherit;
  background: var(--bg-input);
  color: var(--text);
}

input[type="file"] {
  padding: 5px 6px;
  color: var(--text-secondary);
  cursor: pointer;
}

input[type="file"]::file-selector-button {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-right: 10px;
  padding: 5px 10px;
  background: var(--accent-muted);
  color: var(--text);
  font: inherit;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease;
}

input[type="file"]::file-selector-button:hover {
  background: var(--accent);
  border-color: var(--accent-hover);
}

.help-text {
  margin: 4px 0 0;
  color: var(--text-secondary);
  font-size: 13px;
}

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

input:focus, textarea:focus, select:focus {
  outline: 2px solid rgba(90, 101, 120, 0.45);
  border-color: var(--accent-hover);
}

.form-actions {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-top: 8px;
}

.secondary-link { color: var(--text-secondary); }
.secondary-link:hover { color: var(--text); }

.panel {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-elevated);
  padding: 18px;
}

.panel h2 {
  margin: 0 0 12px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.property-list {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 8px 14px;
  margin-bottom: 16px;
}

.body-text { white-space: pre-wrap; color: var(--text); }

.timeline { margin: 0; padding-left: 18px; color: var(--text-secondary); }
.timeline li { margin-bottom: 10px; }
.timeline time { display: block; color: var(--text-tertiary); font-size: 12px; }

.property-list {
  display: grid;
  gap: 12px;
  margin: 0 0 20px;
}

.property-list div {
  display: grid;
  gap: 3px;
}

.property-list dt {
  color: var(--text-secondary);
  font-size: 12px;
}

.property-list dd {
  margin: 0;
}

.ticket-label-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 20px;
}

.errorlist {
  color: #ff8e8e;
  margin: 4px 0 0;
  padding-left: 18px;
}

.notion-table th.sortable {
  padding: 0;
}

.notion-table th.sortable a {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  min-height: 32px;
  padding: 6px 10px;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: var(--radius);
  transition: background 120ms ease, color 120ms ease;
}

.notion-table th.sortable a:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.notion-table th.sortable a:hover .sort-icon {
  opacity: 0.85;
  color: var(--text-secondary);
}

.notion-table th.sort-asc a,
.notion-table th.sort-desc a {
  color: var(--text);
  background: var(--bg-hover);
}

.col-label {
  font-weight: 500;
}

.sort-icon {
  flex-shrink: 0;
  min-width: 14px;
  font-size: 12px;
  line-height: 1;
  opacity: 0.4;
  text-align: center;
}

.notion-table th.sort-asc .sort-icon,
.notion-table th.sort-desc .sort-icon {
  opacity: 1;
  color: var(--text);
  font-weight: 700;
}

.notion-table thead tr {
  border-bottom: 1px solid var(--border);
}

.col-updated { color: var(--text-secondary); white-space: nowrap; }

.tab-panel { margin-top: 16px; }

.ticket-header {
  margin-bottom: 8px;
}

.ticket-hero-title {
  margin: 0 0 4px;
  font-size: clamp(28px, 4vw, 42px);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.15;
  color: var(--text);
}

.ticket-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 340px);
  gap: 20px;
  align-items: start;
  margin-top: 16px;
}

.ticket-main {
  min-width: 0;
}

.ticket-description-hero {
  margin-bottom: 20px;
}

.ticket-description {
  margin: 0;
  font-size: 17px;
  line-height: 1.7;
  color: var(--text);
  white-space: pre-wrap;
}

.ticket-meta-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.meta-chip {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 3px;
  background: var(--bg-hover);
  color: var(--text-secondary);
  font-size: 12px;
}

.meta-chip.meta-muted {
  background: transparent;
  color: var(--text-tertiary);
  padding-left: 0;
}

.issue-subscribers {
  position: relative;
}

.issue-subscribers > summary {
  list-style: none;
}

.issue-subscribers > summary::-webkit-details-marker {
  display: none;
}

.subscriber-disclosure {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  gap: 6px;
  border-radius: var(--radius);
  padding: 2px 5px;
  color: var(--text-secondary);
  font-size: 12px;
  cursor: pointer;
}

.subscriber-disclosure:hover,
.issue-subscribers[open] .subscriber-disclosure {
  background: var(--bg-hover);
  color: var(--text);
}

.subscriber-disclosure:focus-visible {
  outline: 2px solid var(--accent-hover);
  outline-offset: 2px;
}

.subscriber-avatar-stack {
  display: inline-flex;
  align-items: center;
  margin-left: 2px;
  padding-left: 6px;
}

.subscriber-avatar {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border: 2px solid var(--bg-elevated);
  border-radius: 50%;
  background: #3d536a;
  color: #e4edf7;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.subscriber-avatar-stack .subscriber-avatar {
  margin-left: -7px;
}

.subscriber-avatar-overflow {
  width: auto;
  min-width: 26px;
  padding: 0 5px;
  background: var(--bg-input);
  color: var(--text-secondary);
}

.subscriber-popover {
  position: absolute;
  z-index: 20;
  top: calc(100% + 8px);
  right: 0;
  width: min(360px, calc(100vw - 32px));
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-elevated);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.45);
}

.subscriber-popover-header {
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--border-light);
}

.subscriber-popover-header h2 {
  margin: 0;
  font-size: 15px;
  line-height: 1.3;
}

.subscriber-popover-header p {
  margin: 3px 0 0;
  color: var(--text-tertiary);
  font-size: 12px;
}

.subscriber-list {
  max-height: 264px;
  overflow-y: auto;
  margin: 0;
  padding: 6px;
  list-style: none;
}

.subscriber-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 50px;
  padding: 7px 8px;
  border-radius: 6px;
}

.subscriber-list li:hover {
  background: var(--bg-hover);
}

.subscriber-identity {
  display: flex;
  min-width: 0;
  flex: 1;
  flex-direction: column;
}

.subscriber-identity strong,
.subscriber-identity span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.subscriber-identity strong {
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
}

.subscriber-identity span {
  color: var(--text-tertiary);
  font-size: 12px;
}

.subscriber-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-tertiary);
  cursor: pointer;
}

.subscriber-remove:hover,
.subscriber-remove:focus-visible {
  background: var(--bg-input);
  color: var(--text);
}

.subscriber-remove:focus-visible {
  outline: 2px solid var(--accent-hover);
  outline-offset: 1px;
}

.subscriber-empty {
  margin: 0;
  padding: 22px 16px;
  color: var(--text-tertiary);
  text-align: center;
}

.subscriber-add-form {
  padding: 12px 16px 14px;
  border-top: 1px solid var(--border-light);
}

.subscriber-add-form > label {
  display: block;
  margin-bottom: 6px;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
}

.subscriber-add-row {
  display: flex;
  align-items: stretch;
  gap: 8px;
}

.subscriber-add-row input {
  min-width: 0;
  padding: 7px 9px;
}

.subscriber-add-button {
  flex: 0 0 auto;
  padding: 6px 12px;
}

.subscriber-form-error,
.subscriber-form-help {
  margin: 6px 0 0;
  font-size: 11px;
}

.subscriber-form-error {
  color: #e8a0a0;
}

.subscriber-form-help {
  color: var(--text-tertiary);
}

@media (max-width: 640px) {
  .issue-subscribers {
    flex-basis: 100%;
  }

  .subscriber-popover {
    right: auto;
    left: 0;
    width: min(360px, calc(100vw - 32px));
  }
}

.ticket-meta-panel {
  min-width: 0;
}

.portal-comment-thread,
.portal-comment-form {
  margin-top: 28px;
  border-top: 1px solid var(--border);
  padding-top: 22px;
}

.portal-comment-thread h2,
.portal-comment-form h2 {
  margin: 0 0 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.comment-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 16px;
}

.comment {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
}

.comment-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.comment-identity {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 8px;
}

.support-avatar-group {
  display: inline-flex;
  flex-shrink: 0;
  align-items: center;
}

.support-avatar {
  display: block;
  width: 24px;
  height: 24px;
  border: 2px solid var(--bg-elevated);
  border-radius: 50%;
  background: var(--bg-input);
  object-fit: cover;
}

.support-avatar + .support-avatar {
  margin-left: -8px;
}

.comment-author {
  overflow: hidden;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.comment-time {
  flex-shrink: 0;
  font-size: 13px;
  color: var(--text-tertiary);
}

.comment-body {
  font-size: 15px;
  line-height: 1.6;
  color: var(--text-secondary);
}

.comment-body > :first-child {
  margin-top: 0;
}

.comment-body > :last-child {
  margin-bottom: 0;
}

.comment-empty {
  margin: 0;
  font-size: 15px;
  color: var(--text-tertiary);
}

.markdown-body img,
.markdown-body video {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 0.5em 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-elevated);
}

.markdown-body a > img {
  cursor: zoom-in;
  transition: border-color 0.12s ease, opacity 0.12s ease;
}

.markdown-body a:hover > img {
  border-color: var(--accent-hover);
  opacity: 0.92;
}

.comment-form {
  display: grid;
  gap: 8px;
}

.comment-body-input {
  width: 100%;
  box-sizing: border-box;
  background: var(--bg-input);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font: inherit;
  font-size: 15px;
}

.comment-body-input {
  resize: vertical;
  min-height: 88px;
  line-height: 1.6;
}

.comment-body-input::placeholder {
  color: var(--text-tertiary);
}

.comment-body-input:focus {
  outline: none;
  border-color: var(--accent-hover);
}

.comment-form-actions {
  display: flex;
  justify-content: flex-end;
}

.inline-form {
  display: inline;
  margin: 0;
}

.page-header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.page-header-row .page-icon-title {
  margin-bottom: 0;
  min-width: 0;
}

.view-tabs {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.view-tabs::-webkit-scrollbar { display: none; }

.view-tab {
  flex-shrink: 0;
  min-height: 40px;
}

.filter-form {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
}

.filter-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
}

.active-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--bg-hover);
  color: var(--text-secondary);
  font-size: 12px;
}

.table-row-link {
  cursor: pointer;
}

.row-title-link {
  display: block;
  padding: 2px 0;
}

.row-title-link:hover {
  text-decoration: underline;
  text-underline-offset: 2px;
}

.search-form {
  display: flex;
  align-items: center;
}

.htmx-indicator {
  opacity: 0;
  pointer-events: none;
  transition: opacity 120ms ease;
}

.htmx-indicator.htmx-request {
  opacity: 1;
}

.inbox-loading {
  height: 2px;
  margin-bottom: 6px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  background-size: 200% 100%;
  animation: loading-slide 900ms linear infinite;
}

@keyframes loading-slide {
  from { background-position: 200% 0; }
  to { background-position: -200% 0; }
}

@media (max-width: 900px) {
  .notion-topbar {
    flex-wrap: nowrap;
    padding: 10px 12px;
  }

  .breadcrumbs {
    flex: 1 1 auto;
    width: auto;
    font-size: 13px;
  }

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

  .page-title {
    font-size: clamp(22px, 7vw, 32px);
  }

  .page-icon {
    font-size: 32px;
  }

  .table-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

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

  .search-form {
    flex: 1;
  }

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

  .notion-table .col-id,
  .notion-table .col-updated {
    display: none;
  }

  .col-title {
    min-width: 180px;
  }

  .notion-table td,
  .notion-table th {
    padding: 8px 8px;
    height: auto;
    min-height: 44px;
  }

  .property-list {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .ticket-layout {
    grid-template-columns: 1fr;
  }

  .ticket-meta-panel {
    order: 1;
  }

  .ticket-main {
    order: 2;
  }

  .ticket-description {
    font-size: 16px;
  }
}

.markdown-body { white-space: normal; }

.markdown-body > :first-child { margin-top: 0; }
.markdown-body > :last-child { margin-bottom: 0; }

.markdown-body p { margin: 0 0 0.7em; }

.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4,
.markdown-body h5,
.markdown-body h6 {
  margin: 1.1em 0 0.45em;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.3;
}

.markdown-body h1 { font-size: 1.35em; }
.markdown-body h2 { font-size: 1.2em; }
.markdown-body h3 { font-size: 1.08em; }
.markdown-body h4,
.markdown-body h5,
.markdown-body h6 { font-size: 1em; }

.markdown-body ul,
.markdown-body ol {
  margin: 0 0 0.7em;
  padding-left: 1.5em;
}

.markdown-body li { margin: 0.15em 0; }

.markdown-body a {
  color: #7ba7d9;
  text-decoration: underline;
  text-decoration-color: rgba(123, 167, 217, 0.4);
  text-underline-offset: 2px;
}

.markdown-body a:hover { text-decoration-color: #7ba7d9; }

.markdown-body code {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
  font-size: 0.88em;
  background: var(--bg-input);
  border: 1px solid var(--border-light);
  border-radius: 3px;
  padding: 1px 5px;
}

.markdown-body pre {
  margin: 0 0 0.8em;
  padding: 10px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  overflow-x: auto;
}

.markdown-body pre code {
  background: transparent;
  border: 0;
  padding: 0;
}

.markdown-body blockquote {
  margin: 0 0 0.8em;
  padding: 2px 0 2px 12px;
  border-left: 3px solid var(--border);
  color: var(--text-secondary);
}

.markdown-body hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 1.2em 0;
}

.markdown-body table {
  border-collapse: collapse;
  margin: 0 0 0.8em;
  font-size: 0.95em;
}

.markdown-body th,
.markdown-body td {
  border: 1px solid var(--border);
  padding: 5px 10px;
  text-align: left;
}

.markdown-body th {
  background: var(--bg-elevated);
  font-weight: 600;
}

.message-success { border-color: var(--tag-status-done); }
.message-error { border-color: #a05252; }
.message-warning { border-color: var(--tag-status-review); }

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

.EasyMDEContainer .editor-toolbar {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-bottom: 0;
  border-radius: var(--radius) var(--radius) 0 0;
  opacity: 1;
  padding: 4px 6px;
}

.EasyMDEContainer .editor-toolbar button {
  color: var(--text-secondary) !important;
  border: 1px solid transparent;
}

.EasyMDEContainer .editor-toolbar button:hover,
.EasyMDEContainer .editor-toolbar button.active {
  background: var(--bg-hover);
  border-color: var(--border);
  color: var(--text) !important;
}

.EasyMDEContainer .editor-toolbar i.separator {
  border-left: 1px solid var(--border);
  border-right: 0;
}

.EasyMDEContainer .CodeMirror {
  background: var(--bg-input);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 0 0 var(--radius) var(--radius);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.55;
  padding: 4px 6px;
}

.EasyMDEContainer .CodeMirror-focused { border-color: var(--accent-hover); }
.EasyMDEContainer .CodeMirror-cursor { border-left: 1px solid var(--text); }
.EasyMDEContainer .CodeMirror-selected { background: var(--accent-muted); }
.EasyMDEContainer .CodeMirror-placeholder { color: var(--text-tertiary) !important; }

.EasyMDEContainer .cm-s-easymde .cm-header { color: var(--text); }
.EasyMDEContainer .cm-s-easymde .cm-quote { color: var(--text-secondary); font-style: italic; }
.EasyMDEContainer .cm-s-easymde .cm-link,
.EasyMDEContainer .cm-s-easymde .cm-url { color: #7ba7d9; }
.EasyMDEContainer .cm-s-easymde .cm-comment {
  background: var(--bg-elevated);
  border-radius: 3px;
}

.EasyMDEContainer .editor-preview {
  background: var(--bg-input);
  color: var(--text);
  padding: 10px 12px;
}

.EasyMDEContainer .editor-preview pre,
.EasyMDEContainer .editor-preview code {
  background: var(--bg-elevated);
}

.messages {
  position: fixed;
  top: 52px;
  right: 16px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0;
  max-width: min(360px, calc(100vw - 32px));
  pointer-events: none;
}

.message {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  pointer-events: auto;
  background: var(--bg-elevated);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(255, 255, 255, 0.04);
  font-size: 13px;
  animation: toast-in 220ms cubic-bezier(0.2, 0.9, 0.3, 1);
  transition: opacity 240ms ease, transform 240ms ease;
}

.message-leaving {
  opacity: 0;
  transform: translateX(12px);
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

.message-text { flex: 1; }

.message-close {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--text-tertiary);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
  border-radius: var(--radius);
}

.message-close:hover { color: var(--text); }

button.is-loading {
  position: relative;
  color: transparent !important;
  pointer-events: none;
}

button.is-loading::after {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  width: 14px;
  height: 14px;
  border: 2px solid var(--text-secondary);
  border-top-color: var(--text);
  border-radius: 50%;
  animation: button-spin 600ms linear infinite;
}

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

:focus-visible {
  outline: 2px solid var(--accent-hover);
  outline-offset: 1px;
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: none;
}

.notion-table tbody tr,
.view-tab,
.tag,
.meta-chip {
  transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

.portal-login-body {
  min-height: 100vh;
  background: #141619;
}

.portal-login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 50% 38%, rgba(88, 101, 124, 0.11), transparent 28rem),
    #141619;
}

.portal-entry {
  width: min(100%, 360px);
  padding: 36px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  background: rgba(29, 32, 37, 0.94);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.32);
}

.portal-entry h1 {
  margin: 0 0 28px;
  color: #f5f6f7;
  font-size: 31px;
  font-weight: 650;
  letter-spacing: -0.045em;
  line-height: 1.1;
  text-align: center;
}

.portal-providers {
  display: grid;
  gap: 10px;
}

.portal-session {
  display: grid;
  gap: 16px;
  color: #c7cbd1;
  font-size: 14px;
  text-align: center;
  overflow-wrap: anywhere;
}

.portal-session p {
  margin: 0;
}

.portal-session strong {
  display: block;
  margin-top: 6px;
  color: #f5f6f7;
}

.portal-providers form {
  display: grid;
}

.portal-password-form {
  gap: 8px;
}

.portal-password-form label {
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
}

.portal-password-form .primary-button {
  min-height: 42px;
  margin: 4px 0 8px;
}

.portal-entry .sso-button {
  width: 100%;
  font: inherit;
  text-align: left;
  cursor: pointer;
  min-height: 48px;
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  border: 1px solid #d4d6da;
  border-radius: 10px;
  background: #fff;
  color: #202226;
  padding: 11px 16px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.18);
  transition: background 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
}

.portal-entry .sso-button:hover {
  border-color: #b8bbc1;
  background: #f6f7f8;
  color: #17191c;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.2);
}

.portal-entry .sso-button:focus-visible {
  outline: 3px solid rgba(143, 174, 222, 0.65);
  outline-offset: 2px;
}

.sso-button__icon {
  width: 22px;
  height: 22px;
  display: inline-flex;
}

.sso-button__label {
  font-size: 14px;
  font-weight: 600;
  text-align: left;
}

.sso-button__icon svg {
  width: 100%;
  height: 100%;
  display: block;
}

.portal-login-error {
  margin: -12px 0 20px;
  padding: 8px 10px;
  border: 1px solid rgba(233, 164, 164, 0.22);
  border-radius: 8px;
  background: rgba(110, 45, 45, 0.14);
  color: #e9a4a4;
  font-size: 12px;
}

.portal-account-switch-link {
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  cursor: pointer;
  color: #c7cbd1;
  text-decoration: underline;
  text-decoration-color: rgba(199, 203, 209, 0.45);
  text-underline-offset: 3px;
}

.portal-account-switch-link:hover {
  color: #fff;
  text-decoration-color: currentColor;
}

.portal-login-error .portal-account-switch-link {
  display: block;
  margin-top: 8px;
  color: #f4c2c2;
  font-weight: 600;
}

@media (max-width: 480px) {
  .portal-login { padding: 16px; }
  .portal-entry { padding: 30px 24px; }
}

.ticket-meta-header {
  margin: 10px 0 4px;
}

.ticket-description,
.ticket-description-hero {
  max-width: 68ch;
}

.filter-inline {
  display: flex;
  align-items: center;
  min-width: 0;
}

.filter-inline[hidden] { display: none !important; }

.filter-inline .filter-form {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.filter-inline select,
.filter-inline input {
  width: auto;
  padding: 5px 8px;
}

/* Section nav (Requests / Progress) */
.section-tabs {
  display: flex;
  gap: 14px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--border-light);
}

.section-tab {
  color: var(--text-secondary);
  font-size: 14px;
  padding: 6px 2px 9px;
  border-bottom: 2px solid transparent;
}

.section-tab:hover { color: var(--text); }

.section-tab.active {
  color: var(--text);
  border-bottom-color: var(--text);
}

/* Acceptance criteria */
.acceptance-card {
  margin-bottom: 8px;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-elevated);
}

.acceptance-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.acceptance-name {
  flex: none;
  width: 178px;
  font-size: 14px;
  font-weight: 600;
}

.acceptance-strip {
  display: flex;
  flex: 1;
  gap: 2px;
  min-width: 0;
  container-type: inline-size;
}

.acceptance-tile {
  display: flex;
  flex: 1 1 0;
  align-items: center;
  justify-content: center;
  min-width: 0;
  height: 14px;
  padding: 0;
  border: 1px solid #2f5a42;
  border-radius: 3px;
  background: #24382d;
  color: #f2b155;
  cursor: pointer;
}

.acceptance-tile-outstanding {
  border-color: #8a6a2c;
  background: #3a2e17;
}

.acceptance-tile:hover,
.acceptance-tile[aria-expanded="true"] {
  outline: 1.5px solid var(--text);
}

.acceptance-code {
  overflow: hidden;
  font-family: ui-monospace, Menlo, monospace;
  font-size: min(10px, calc(100cqw / var(--criteria) / 2.6));
  line-height: 1;
}

.acceptance-percent {
  flex: none;
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
}

.acceptance-percent strong { color: #6fcf97; }

.acceptance-detail {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border-light);
  font-size: 13px;
}

.acceptance-detail[hidden] { display: none; }

.acceptance-detail-head {
  display: flex;
  align-items: center;
  gap: 8px;
}

.acceptance-detail-code {
  font-family: ui-monospace, Menlo, monospace;
  color: var(--text-secondary);
}

.acceptance-detail-state { font-size: 11px; color: #6fcf97; }

.acceptance-detail-outstanding .acceptance-detail-code,
.acceptance-detail-outstanding .acceptance-detail-state { color: #f2b155; }

.acceptance-detail-spacer { flex: 1; }

.acceptance-detail-position {
  font-size: 11px;
  color: var(--text-tertiary);
}

.acceptance-step {
  width: 22px;
  height: 22px;
  padding: 0;
  border: 0;
  border-radius: var(--radius);
  background: var(--bg-hover);
  color: var(--text-secondary);
  cursor: pointer;
}

.acceptance-detail-text {
  margin: 6px 0 0;
  color: var(--text-secondary);
}

:root[data-theme="light"] .acceptance-tile { border-color: #8fc3a4; background: #cfe8d8; }
:root[data-theme="light"] .acceptance-tile-outstanding { border-color: #d2a54a; background: #f7e4b8; color: #7a5410; }
:root[data-theme="light"] .acceptance-percent strong,
:root[data-theme="light"] .acceptance-detail-state { color: #28613e; }
:root[data-theme="light"] .acceptance-detail-outstanding .acceptance-detail-code,
:root[data-theme="light"] .acceptance-detail-outstanding .acceptance-detail-state { color: #7a5410; }

.hover-tooltip {
  position: fixed;
  z-index: 30;
  top: 0;
  left: 0;
  max-width: 320px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-hover);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--text);
  pointer-events: none;
}

.updates-section { margin-top: 40px; }

.section-heading {
  margin: 0 0 14px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-tertiary);
}

.rail { max-width: 780px; }

.rail-entry {
  display: grid;
  grid-template-columns: 110px 34px 1fr;
  padding-bottom: 38px;
}

.rail-date {
  padding-top: 4px;
  font-size: 13px;
  font-weight: 600;
  text-align: right;
}

.rail-date small {
  display: block;
  font-size: 12px;
  font-weight: 400;
  color: var(--text-tertiary);
}

.rail-line { position: relative; }

.rail-line::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: -38px;
  left: 50%;
  width: 1px;
  background: var(--border);
}

.rail-entry:first-child .rail-line::before { top: 14px; }
.rail-entry:last-child .rail-line::before { bottom: auto; height: 14px; }

.rail-dot {
  position: absolute;
  top: 8px;
  left: 50%;
  width: 11px;
  height: 11px;
  margin-left: -5.5px;
  border: 2px solid var(--text-secondary);
  border-radius: 50%;
  background: var(--bg);
}

.rail-dot-release {
  border-color: var(--tag-other);
  background: var(--tag-other);
}

.rail-title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 10px;
  margin: 0;
  font-size: 20px;
  letter-spacing: -0.01em;
}

.rail-summary {
  margin: 6px 0 10px;
  max-width: 62ch;
  color: var(--text-secondary);
}


.rail-summary p { margin: 0 0 8px; }
.rail-summary p:last-child { margin-bottom: 0; }

.rail-update { margin-top: 6px; }
.rail-update .timeline-update-body { max-width: 62ch; font-size: 14px; }

.rail-fold { margin-top: 10px; }

.rail-fold-toggle {
  display: inline-block;
  cursor: pointer;
  list-style: none;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
}

.rail-fold-toggle::-webkit-details-marker { display: none; }
.rail-fold-toggle::before { content: "\25B8\00a0"; }
.rail-fold[open] .rail-fold-toggle::before { content: "\25BE\00a0"; }
.rail-fold-toggle:hover { color: var(--text); }

.rail-groups { margin-top: 14px; }
.rail-group { margin: 0 0 14px; }

.rail-group h4 {
  margin: 0 0 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-tertiary);
}

.rail-group ul { margin: 0; padding-left: 18px; }
.rail-group li { margin: 4px 0; }

.rail-id {
  margin-left: 8px;
  font-size: 12px;
  color: var(--text-tertiary);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.rail-id:hover { color: var(--text); text-decoration: underline; }

@media (max-width: 640px) {
  .rail-entry { grid-template-columns: 70px 26px 1fr; }
  .rail-title { font-size: 17px; }
}

.timeline-update-body {
  max-width: 76ch;
  font-size: 13.5px;
  color: var(--text-secondary);
}

.timeline-update-body p { margin: 0 0 10px; }
.timeline-update-body p:last-child { margin-bottom: 0; }

.timeline-update-foldable .timeline-update-body {
  max-height: 9em;
  overflow: hidden;
  -webkit-mask-image: linear-gradient(to bottom, #000 55%, transparent 100%);
  mask-image: linear-gradient(to bottom, #000 55%, transparent 100%);
}

.timeline-update-foldable:has(.timeline-update-fold[open]) .timeline-update-body {
  max-height: none;
  -webkit-mask-image: none;
  mask-image: none;
}

.timeline-update-toggle {
  display: inline-block;
  margin-top: 8px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  list-style: none;
}

.timeline-update-toggle::-webkit-details-marker { display: none; }
.timeline-update-toggle:hover { color: var(--text); }

.timeline-update-toggle-less,
.timeline-update-fold[open] .timeline-update-toggle-more { display: none; }
.timeline-update-fold[open] .timeline-update-toggle-less { display: inline; }

.section-note {
  margin: 0;
  font-size: 13px;
  color: var(--text-tertiary);
}

.section-empty {
  padding: 18px 16px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-lg);
}
