.panel-region {
    position: fixed;
    inset: 0;
    z-index: var(--theme-z-modal);
    visibility: hidden;
}

.panel-region.is-open {
    visibility: visible;
}

.panel-backdrop {
    position: absolute;
    inset: 0;
    background: var(--theme-bg-overlay);
    opacity: 0;
    transition: opacity 200ms ease;
}

.panel-region.is-open .panel-backdrop {
    opacity: 1;
}

.panel {
    position: absolute;
    top: 0;
    inset-inline-start: 0;
    height: 100%;
    width: 360px;
    max-width: 86vw;
    display: flex;
    flex-direction: column;
    background: var(--theme-surface-raised);
    border-inline-end: 1px solid var(--theme-border-subtle);
    box-shadow: var(--theme-shadow-lg);
    transform: translateX(-100%);
    transition: transform 240ms ease;
}

[dir="rtl"] .panel {
    transform: translateX(100%);
}

.panel-region-end .panel {
    inset-inline-start: auto;
    inset-inline-end: 0;
    border-inline-end: none;
    border-inline-start: 1px solid var(--theme-border-subtle);
    transform: translateX(100%);
}

[dir="rtl"] .panel-region-end .panel {
    transform: translateX(-100%);
}

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

.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 18px;
    border-bottom: 1px solid var(--theme-border-subtle);
}

.panel-title {
    margin: 0;
    font-family: var(--theme-font-sans);
    font-size: var(--theme-font-lg);
    font-weight: var(--theme-font-weight-semibold);
    color: var(--theme-text-primary);
}

.panel-close {
    display: inline-flex;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--theme-text-secondary);
    padding: 4px;
    border-radius: var(--theme-radius-sm);
}

.panel-close:hover {
    background: var(--theme-bg-secondary);
}

.panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 12px 0;
    font-family: var(--theme-font-sans);
    color: var(--theme-text-primary);
}

.panel-empty {
    padding: 32px 18px;
    text-align: center;
    color: var(--theme-text-tertiary);
    font-size: var(--theme-font-sm);
}

.panel-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.panel-item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 10px 18px;
    cursor: pointer;
    border: none;
    background: none;
    width: 100%;
    text-align: start;
    color: inherit;
    font: inherit;
}

.panel-item:hover {
    background: var(--theme-bg-secondary);
}

.panel-item.is-active {
    background: var(--theme-bg-secondary);
    border-inline-start: 3px solid var(--theme-color-primary);
}

.panel-item-main {
    flex: 1;
    min-width: 0;
}

.panel-item-title {
    font-size: var(--theme-font-sm);
    font-weight: var(--theme-font-weight-medium);
}

.panel-item-sub {
    font-size: var(--theme-font-xs);
    color: var(--theme-text-tertiary);
    margin-top: 2px;
}

.panel-item-section {
    list-style: none;
    padding: 14px 16px 4px;
}

.panel-item-section-title {
    font-weight: var(--theme-font-weight-bold);
    color: var(--theme-color-primary);
    text-transform: uppercase;
    font-size: var(--theme-font-xs);
    letter-spacing: 0.06em;
}

.panel-item-chapter {
    padding-inline-start: 30px;
}

.panel-item-quote {
    font-size: var(--theme-font-sm);
    line-height: var(--theme-line-height-base);
    border-inline-start: 3px solid var(--theme-color-warning);
    padding-inline-start: 8px;
}

.panel-item-note {
    display: block;
    font-size: var(--theme-font-xs);
    color: var(--theme-text-secondary);
    margin-top: 4px;
    font-style: italic;
}

.panel-item-remove {
    flex: 0 0 auto;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--theme-text-tertiary);
    padding: 2px;
}

.panel-item-remove:hover {
    color: var(--theme-color-danger);
}

.panel-section {
    padding: 16px 18px;
    border-bottom: 1px solid var(--theme-border-subtle);
}

.panel-section-label {
    display: block;
    font-size: var(--theme-font-xs);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--theme-text-tertiary);
    margin-bottom: 10px;
}

.panel-search-input {
    width: 100%;
    box-sizing: border-box;
    padding: 10px 12px;
    font: inherit;
    color: var(--theme-text-primary);
    background: var(--theme-bg-primary);
    border: 1px solid var(--theme-border-default);
    border-radius: var(--theme-radius-sm);
}

.panel-segmented {
    display: flex;
    gap: 6px;
}

.panel-segmented button {
    flex: 1;
    padding: 8px;
    font: inherit;
    cursor: pointer;
    color: var(--theme-text-secondary);
    background: var(--theme-bg-primary);
    border: 1px solid var(--theme-border-default);
    border-radius: var(--theme-radius-sm);
}

.panel-segmented button.is-active {
    color: var(--theme-text-inverse);
    background: var(--theme-color-primary);
    border-color: var(--theme-color-primary);
}

.panel-select {
    width: 100%;
    box-sizing: border-box;
    padding: 10px 12px;
    font: inherit;
    color: var(--theme-text-primary);
    background: var(--theme-bg-primary);
    border: 1px solid var(--theme-border-default);
    border-radius: var(--theme-radius-sm);
}

.panel-stepper {
    display: flex;
    align-items: center;
    gap: 12px;
}

.panel-stepper button {
    display: inline-flex;
    width: 36px;
    height: 36px;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--theme-text-primary);
    background: var(--theme-bg-primary);
    border: 1px solid var(--theme-border-default);
    border-radius: var(--theme-radius-sm);
}

.panel-stepper-value {
    min-width: 48px;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.panel-note {
    padding: 24px 18px;
    color: var(--theme-text-secondary);
    font-size: var(--theme-font-sm);
    line-height: var(--theme-line-height-relaxed);
}

.panel-mcp {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.panel-mcp-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.panel-mcp-label {
    font-size: var(--theme-font-sm);
    font-weight: 600;
    color: var(--theme-text-secondary);
}

.panel-mcp-value {
    display: flex;
    align-items: center;
    gap: 8px;
}

.panel-mcp-text {
    flex: 1;
    min-width: 0;
    overflow-x: auto;
    white-space: nowrap;
    padding: 10px 12px;
    font-family: var(--theme-font-mono, monospace);
    font-size: var(--theme-font-sm);
    color: var(--theme-text-primary);
    background: var(--theme-bg-primary);
    border: 1px solid var(--theme-border-default);
    border-radius: var(--theme-radius-sm);
}

.panel-mcp-copy {
    display: inline-flex;
    flex-shrink: 0;
    width: 38px;
    height: 38px;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--theme-text-primary);
    background: var(--theme-bg-primary);
    border: 1px solid var(--theme-border-default);
    border-radius: var(--theme-radius-sm);
}

.panel-mcp-copy:hover {
    background: var(--theme-bg-secondary, var(--theme-bg-primary));
}
