.app-sidebar-secondary:has(.epic-sidebar) .app-navigation-toolbar {
  box-sizing: border-box;
  height: 56px;
  min-height: 56px;
  padding: 0 20px;
  align-items: center;
}

.app-navigation-projects:has(> .epic-sidebar) {
  display: flex;
  overflow: hidden;
  padding: 4px 8px 16px;
}

.epic-sidebar {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.epic-sidebar .app-project-link {
  box-sizing: border-box;
  flex-shrink: 0;
  min-height: 36px;
  padding: 8px 12px;
  line-height: 20px;
}

.epic-sidebar .app-project-link:hover { background: transparent; color: #475569; }
.epic-sidebar .app-project-link.is-active,
.epic-sidebar .app-project-link.is-active:hover { background: #e5e7eb; color: #111827; font-weight: 600; }
.epic-sidebar > .app-project-create { margin: 0 0 8px; }

.epic-item-list {
  display: flex;
  flex: 0 1 auto;
  flex-direction: column;
  gap: 2px;
  min-height: 36px;
  max-height: min(250px, 35dvh);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.epic-sidebar:not(:has(.epic-source-navigation)) .epic-item-list { flex: 1; max-height: none; }
.epic-item-list:empty { min-height: 0; }
.epic-sidebar-more { flex-shrink: 0; }
.epic-sidebar-more .app-project-link { width: 100%; justify-content: center; }
.epic-sidebar-more button:disabled { opacity: .6; cursor: wait; }
.epic-sidebar .epic-source-navigation {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
  margin-top: 12px;
  padding-top: 12px;
}

.epic-sidebar .epic-sidebar-tabs { flex-shrink: 0; margin-bottom: 8px; }
.epic-sidebar .epic-sidebar-tabs button { min-height: 32px; padding: 6px 3px; line-height: 18px; }
.epic-sidebar [role="tabpanel"] { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.epic-sidebar [role="tabpanel"] > .app-project-link { min-height: 32px; padding: 6px 12px; }

@media (hover: hover) {
  .epic-sidebar .app-project-link:not(.is-active):not(.app-project-create):hover { background: #f3f4f6; color: #111827; }
}

@media (max-width: 1023.98px) {
  .app-navigation-projects:has(> .epic-sidebar) { padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
  .epic-sidebar .app-project-link { min-height: 44px; padding-block: 12px; }
  .epic-sidebar .epic-item-list { min-height: 44px; max-height: 35dvh; }
  .epic-sidebar:not(:has(.epic-source-navigation)) .epic-item-list { max-height: none; }
  .epic-sidebar .epic-sidebar-tabs button { min-height: 44px; }
  .epic-sidebar [role="tabpanel"] > .app-project-link { min-height: 44px; padding-block: 12px; }
}

.epic-item-list .app-project-link { display: flex; align-items: center; gap: 8px; }
.epic-item-kind { display: inline-flex; flex: 0 0 16px; color: #64748b; }
.epic-item-kind .epic-icon { width: 16px; height: 16px; }
.epic-item-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.epic-sidebar .epic-sidebar-tabs { display: flex; align-items: stretch; width: 100%; }
.epic-sidebar .epic-sidebar-tabs > button:not(.epic-sidebar-resolution) { flex: 1; }
.epic-resolution-sidebar { --epic-line: #dce4ef; --epic-muted: #5d6d86; width: 100%; min-width: 0; padding: 4px 8px 12px; }
.epic-resolution-sidebar .epic-dialog-form { display: block; }
.epic-resolution-sidebar .epic-dialog-body { padding: 0; background: transparent; overflow: visible; }
.epic-resolution-sidebar .epic-resolution-entry,
.epic-resolution-sidebar .epic-resolution-entry:first-of-type { padding: 16px 0; margin: 0; border: 0; border-bottom: 1px solid var(--epic-line); border-radius: 0; background: transparent; }
.epic-resolution-sidebar .epic-resolution-question legend { font-size: 14px; line-height: 1.7; overflow-wrap: anywhere; }
.epic-resolution-sidebar .epic-resolution-number { font-size: 11px; margin-bottom: 6px; }
.epic-resolution-sidebar .epic-resolution-reason, .epic-resolution-sidebar .epic-resolution-quote { font-size: 12px; }
.epic-resolution-sidebar .epic-choice { font-size: 13px; padding: 8px; gap: 6px; }
.epic-resolution-sidebar .epic-choice input { flex-shrink: 0; }
.epic-resolution-sidebar textarea { width: 100%; box-sizing: border-box; font-size: 14px; padding: 8px; }
.epic-resolution-sidebar .epic-dialog-foot { display: flex; flex-direction: column; align-items: stretch; max-width: none; width: 100%; padding: 12px 0; gap: 8px; }
.epic-resolution-sidebar .epic-dialog-foot > .epic-button { width: 100%; padding: 8px; font-size: 13px; }
.epic-resolution-sidebar .epic-resolution-refresh { display: block; padding: 12px 0; border-top: 0; }
.epic-resolution-sidebar .epic-resolution-refresh .epic-analysis-form { align-items: stretch; }
.epic-resolution-sidebar .epic-resolution-refresh .epic-analysis-action > .epic-form-feedback[role="status"] { text-align: center; }
.epic-resolution-sidebar .epic-text-link { color: #5d6d86; font-size: 13px; }
.epic-resolution-sidebar .epic-save-status { font-size: 12px; overflow-wrap: anywhere; }
.epic-resolution-sidebar { --epic-ink: #152038; --epic-blue: #0671e8; color: var(--epic-ink); }
.epic-resolution-sidebar textarea:focus { outline: none; box-shadow: none; }
.epic-sidebar .epic-sidebar-tabs > .epic-sidebar-resolution { border-radius: 0; }
.epic-resolution-sidebar .epic-resolution-refresh button { width: 100%; min-height: 36px; padding: 8px; border: 1px solid var(--epic-line); border-radius: 6px; background: #fff; text-decoration: none; }
.epic-resolution-sidebar input:focus { outline: none; box-shadow: none; }

/* Item navigation belongs to the item: under the title, on the same level as the item tabs.
   Below 1024px it opens from the outline button as its own drawer. */
.epic-detail-sidebar { display: flex; flex-direction: column; min-height: 0; background: #fff; overflow: hidden; }
.epic-detail-sidebar .epic-source-navigation { margin: 0; padding: 0; border: 0; }
.epic-detail-sidebar .epic-sidebar-switcher { flex-shrink: 0; min-height: 56px; margin-bottom: 0; padding: 0 12px; border-bottom: 1px solid var(--epic-line); }
.epic-detail-sidebar .epic-sidebar-tabs { margin: 0; }
.epic-detail-sidebar [role="tabpanel"] { padding: 12px 8px; }
.epic-detail-sidebar .epic-detail-back { display: none; }
.epic-detail-back .epic-icon { transform: rotate(180deg); }
.epic-detail-sidebar .epic-sidebar-tabs > button { height: 56px; min-height: 56px; }
.epic-detail-backdrop { display: none; }
@media (min-width: 1024px) {
  .epic-item-layout { margin-inline: -24px; }
  .epic-item-main { min-width: 0; padding-inline: 24px; container: epic / inline-size; }
  .epic-item-layout.has-navigation { display: grid; grid-template-columns: 240px minmax(0, 1fr); align-items: start; }
  .epic-item-navigation { position: sticky; top: 0; z-index: 3; height: 100dvh; }
  .epic-item-navigation .epic-detail-sidebar { height: 100%; border-right: 1px solid var(--epic-line); }
  .epic-item-navigation .epic-sidebar-switcher { height: 54px; min-height: 54px; }
  .epic-item-navigation .epic-sidebar-tabs > button { height: 53px; min-height: 53px; }
  .epic-item-main > .epic-tabs { min-height: 54px; }
}
@media (max-width: 1023.98px) {
  .epic-item-navigation { display: contents; }
  .epic-detail-backdrop { display: block; position: fixed; inset: 0; z-index: 57; background: rgba(0, 0, 0, .5); opacity: 0; visibility: hidden; transition: opacity .2s ease, visibility 0s linear .2s; }
  .epic-detail-sidebar { position: fixed; inset: 0 auto 0 0; z-index: 58; width: min(336px, calc(100vw - 16px)); border-right: 1px solid #d9dee7; box-shadow: 12px 0 24px rgba(15, 23, 42, .08); transform: translateX(-100%); visibility: hidden; transition: transform .2s ease, visibility 0s linear .2s; }
  html[data-epic-nav-open="true"] .epic-detail-backdrop { opacity: 1; visibility: visible; transition: opacity .2s ease; }
  html[data-epic-nav-open="true"] .epic-detail-sidebar { transform: none; visibility: visible; transition: transform .2s ease; }
  .epic-detail-sidebar .epic-detail-back { display: inline-flex; flex: 0 0 32px; width: 32px; height: 56px; min-height: 56px; }
  .epic-detail-sidebar .epic-sidebar-switcher { padding-inline: 4px; gap: 2px; }
}
@media (max-width: 1023.98px) and (prefers-reduced-motion: reduce) {
  .epic-detail-backdrop, .epic-detail-sidebar, html[data-epic-nav-open="true"] .epic-detail-backdrop, html[data-epic-nav-open="true"] .epic-detail-sidebar { transition: none; }
}

.epic-resolution-history { margin-top: 12px; border-top: 1px solid var(--epic-line); }
.epic-resolution-history summary { min-height: 44px; padding: 12px 0; font-size: 13px; color: var(--epic-muted); cursor: pointer; }

.epic-navigation-empty { margin: 0; padding: 28px 12px; color: var(--epic-faint, #64748b); font-size: 13px; line-height: 1.7; text-align: center; }

/* Planned items share the existing update-ordered list. */
.epic-sidebar-row { display: flex; align-items: center; min-width: 0; }
.epic-sidebar-row > .app-project-link { flex: 1; min-width: 0; }
.epic-sidebar-row .epic-item-title { flex: 1; min-width: 0; }
.epic-plan-tag { font-size: 11px; color: #64748b; flex: none; }
.epic-sidebar-row > form { flex: none; }
.epic-sidebar-row > form button { padding: 8px 4px; font-size: 12px; }
.epic-item-menu { flex: none; }
.epic-item-menu > button { width: 30px; min-height: 36px; }
.epic-item-popover { position: fixed; inset: auto; margin: 0; width: 176px; padding: 8px; border: 1px solid #e2e8f0; border-radius: 14px; background: white; box-shadow: 0 8px 28px #1e3a5f20; }
.epic-item-popover button { width: 100%; min-height: 44px; padding: 8px 12px; text-align: left; }
.epic-item-popover button:hover { background: #f1f5f9; }
.epic-hidden-items { margin-top: auto; justify-content: space-between; }
.epic-plan-dialog { position: fixed; inset: auto; top: var(--plan-top, 100px); left: var(--plan-left, 300px); width: 340px; max-width: calc(100vw - 16px); box-sizing: border-box; margin: 0; padding: 16px; border: 1px solid white; border-radius: 18px; background: white; color: #172338; box-shadow: 0 16px 48px #14375a25; }
.epic-plan-dialog::backdrop { background: #17324f18; }
.epic-plan-dialog label { display: block; margin-bottom: 8px; font-size: 13px; }
.epic-plan-dialog input[type="text"] { width: 100%; box-sizing: border-box; min-height: 44px; padding: 10px 12px; border: 1px solid #e2e8f0; border-radius: 12px; background: #f4f8fc; font-size: 16px; }
.epic-plan-dialog .epic-plan-actions { display: flex; justify-content: flex-end; gap: 12px; margin-top: 12px; }
.epic-plan-dialog .epic-save-status:empty { display: none; }
.epic-plan-chip { display: inline-block; margin-bottom: 12px; padding: 4px 10px; border-radius: 20px; background: #ffffffb3; color: #475569; font-size: 12px; }
.epic-plan-home .epic-import-zone { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 300px; border: 1px solid #ffffffcf; border-radius: 28px; background: #ffffffa8; box-shadow: 0 10px 34px #285c8c14; }
.epic-plan-home .epic-import-prompt > p { display: none; }
.epic-plan-home .epic-import-actions:not(:has(> :not([hidden]))) { display: none; }
.epic-plan-home .epic-import-actions [data-epic-import-target="cancelResume"] { display: none; }
.epic-plan-home .epic-import-status:empty { display: none; }
.epic-plan-mobile-actions { display: none; }
.epic-plan-dialog input:focus, .epic-plan-dialog button:focus, .epic-plan-dialog input[type="submit"]:focus, .epic-item-menu button:focus { outline: none; --tw-ring-shadow: 0 0 #0000; box-shadow: none; }
@media (max-width: 719px) {
  .epic-plan-dialog { top: auto; bottom: 0; left: 0; width: 100%; max-width: none; border-radius: 22px 22px 0 0; padding-bottom: max(16px, env(safe-area-inset-bottom)); }
  .epic-plan-mobile-actions { display: flex; gap: 12px; position: fixed; z-index: 35; bottom: 0; left: 0; right: 0; padding: 8px 12px max(8px, env(safe-area-inset-bottom)); background: #ffffffed; }
  .epic-plan-mobile-actions > button { min-height: 48px; }
  .epic-plan-mobile-actions > .epic-button { flex: 1; }
  .epic-workspace:has(.epic-plan-home) { padding-bottom: 88px; }
}
.epic-workspace:has(.epic-plan-home) > .epic-heading,
.epic-workspace:has(.epic-plan-home) > .epic-item-layout { max-width: 760px; width: 100%; margin-inline: auto; }
.epic-workspace:has(.epic-plan-home) .epic-item-settings { margin-left: auto; }
.epic-workspace:has(.epic-plan-home) .epic-heading { gap: 12px; }
.epic-plan-dialog .epic-button { border-radius: 22px; }
.epic-item-popover button, .epic-plan-dialog .epic-text-link, .epic-plan-mobile-actions .epic-text-link, .epic-sidebar-row > form .epic-text-link { text-decoration: none; color: #475569; }
.epic-plan-dialog input[type="text"]:focus { border-color: #e2e8f0; }
.epic-workspace:has(.epic-plan-home) .epic-item-heading { grid-template-columns: minmax(0, 1fr) auto auto; }
.epic-workspace:has(.epic-plan-home) .epic-item-heading > .epic-item-menu { grid-column: 3; grid-row: 1; align-self: center; }
.epic-workspace:has(.epic-plan-home) .epic-title-editor { white-space: pre-wrap; overflow: visible; max-width: none; }
.epic-plan-mobile-actions > .epic-button { border-radius: 24px; }
.epic-sidebar > button.app-project-link:focus, .epic-plan-mobile-actions > button:focus { outline: none; --tw-ring-shadow: 0 0 #0000; box-shadow: none; }
.epic-plan-dialog .is-error { color: #b42318; }
