/* Shared author admin UI (Resource Book, Article, …) */
.rb-page {
    display: flex;
    flex-direction: column;
    gap: 20px;
    max-width: 1200px;
}

.rb-panel {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 20px 22px;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
}

.rb-panel-title {
    margin: 0 0 16px;
    font-size: 1rem;
    font-weight: 600;
    color: #0f172a;
}

.rb-form-grid {
    display: grid;
    grid-template-columns: 140px 1fr 1fr;
    gap: 14px 16px;
    align-items: end;
}

.rb-filter-row {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 14px 16px;
}

.rb-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.rb-field--wide {
    grid-column: 1 / -1;
}

.rb-field--grow {
    flex: 1 1 220px;
    min-width: 200px;
}

.rb-field label {
    font-size: 0.8rem;
    font-weight: 600;
    color: #475569;
}

.rb-input {
    width: 100%;
    box-sizing: border-box;
    padding: 10px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-size: 0.92rem;
    color: #0f172a;
    background: #fff;
}

.rb-input:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 1px;
    border-color: #3b82f6;
}

.rb-input--readonly {
    background: #f8fafc;
    color: #64748b;
    cursor: not-allowed;
}

.rb-actions {
    display: flex;
    gap: 10px;
    margin-top: 0;
    align-items: center;
    flex-wrap: wrap;
}

/* Save / Cancel and modal action rows — space from fields above */
.rb-form .rb-actions,
.rb-form-panel .rb-actions,
.rb-modal .rb-actions {
    margin-top: 20px;
    padding-top: 4px;
}

.rb-btn {
    padding: 9px 18px;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: background 0.15s ease, opacity 0.15s ease;
}

.rb-btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.rb-btn--primary {
    background: #1e293b;
    color: #fff;
}

.rb-btn--primary:hover:not(:disabled) {
    background: #0f172a;
}

.rb-btn--busy {
    opacity: 0.85;
    cursor: wait;
}

.rb-btn--secondary {
    background: #e2e8f0;
    color: #334155;
}

.rb-btn--secondary:hover:not(:disabled) {
    background: #cbd5e1;
}

.rb-btn--ghost {
    background: #f8fafc;
    color: #334155;
    border: 1px solid #e2e8f0;
}

.rb-btn--ghost:hover:not(:disabled) {
    background: #f1f5f9;
}

a.rb-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
}

.rb-btn--disabled {
    opacity: 0.45;
    pointer-events: none;
}

.rb-status {
    margin: 14px 0 0;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 0.88rem;
}

.rb-status--ok {
    background: #ecfdf5;
    color: #047857;
    border: 1px solid #a7f3d0;
}

.rb-status--error {
    background: #fef2f2;
    color: #b91c1c;
    border: 1px solid #fecaca;
}

.rb-grid-panel--loading {
    opacity: 0.55;
    pointer-events: none;
    transition: opacity 0.15s ease;
}

.rb-grid-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.rb-grid-head-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.rb-form-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}

.rb-form-header .rb-panel-title {
    margin-bottom: 0;
}

.rb-form-grid--edit {
    grid-template-columns: repeat(2, minmax(200px, 1fr));
}

/* Edit article — three compact rows + full-width body */
.rb-form-rows {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.rb-form-row {
    display: grid;
    gap: 14px 16px;
    align-items: end;
}

.rb-form-row--article-1 {
    grid-template-columns: 100px minmax(140px, 1fr) minmax(140px, 1fr);
}

.rb-form-row--article-2 {
    grid-template-columns: minmax(200px, 1fr) 200px 200px;
}

.rb-form-row--article-3 {
    grid-template-columns: 100px minmax(200px, 1fr);
    align-items: start;
}

/* Edit publication */
.rb-form-row--pub-1 {
    grid-template-columns: 100px minmax(160px, 1.2fr) minmax(140px, 1fr);
}

.rb-form-row--pub-meta {
    grid-template-columns: 90px 220px 140px 140px 140px auto;
    align-items: end;
}

.rb-field--date-only .rb-input {
    max-width: 140px;
}

.rb-form-row--pub-4 {
    grid-template-columns: 220px minmax(200px, 1fr);
}

.rb-field--medium .rb-input {
    max-width: 220px;
}

.rb-form-row--pub-meta .rb-field--medium .rb-input {
    max-width: 100%;
}

.rb-field--compact-wide .rb-input {
    max-width: 220px;
}

.rb-field-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: #475569;
}

.rb-field--switch {
    display: flex;
    flex-direction: column;
    gap: 8px;
    justify-content: flex-end;
    padding-bottom: 2px;
}

.rb-switch {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
}

.rb-switch input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.rb-switch-track {
    position: relative;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
    background: #cbd5e1;
    border-radius: 999px;
    transition: background 0.2s ease;
}

.rb-switch-track::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 18px;
    height: 18px;
    background: #fff;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.2);
    transition: transform 0.2s ease;
}

.rb-switch input:checked + .rb-switch-track {
    background: #1e293b;
}

.rb-switch input:checked + .rb-switch-track::after {
    transform: translateX(20px);
}

.rb-switch input:focus-visible + .rb-switch-track {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

.rb-switch-text {
    font-size: 0.9rem;
    font-weight: 600;
    color: #334155;
}

.rb-textarea--scroll {
    overflow-y: auto;
}

.pub-title-block {
    margin-top: 4px;
}

.pub-title-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 6px;
}

.pub-title-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: #475569;
}

.pub-toggle-fields {
    border: none;
    background: none;
    padding: 0;
    font-size: 0.85rem;
    font-weight: 600;
    color: #2563eb;
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.pub-toggle-fields:hover {
    color: #1d4ed8;
}

.pub-body-block {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 14px;
}

.pub-body-block > label {
    font-size: 0.8rem;
    font-weight: 600;
    color: #475569;
}

.pub-edit-fields[hidden] {
    display: none !important;
}

.pub-edit--body-expanded .pub-body-textarea--html {
    min-height: 400px;
}

.pub-edit--body-expanded .pub-body-editor {
    min-height: 420px;
    max-height: none;
}

.pub-body-head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 10px 16px;
    margin-bottom: 6px;
}

.pub-body-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: #475569;
}

.pub-body-label-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.pub-body-speak-btn {
    flex-shrink: 0;
}

.pub-body-mode-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.pub-body-mode-hint {
    font-size: 0.72rem;
    color: #64748b;
    margin-right: 4px;
}

.pub-body-mode-btn {
    border: 1px solid #cbd5e1;
    background: #f8fafc;
    color: #334155;
    font-size: 0.78rem;
    font-weight: 600;
    padding: 6px 10px;
    border-radius: 6px;
    cursor: pointer;
}

.pub-body-mode-btn:hover {
    background: #e2e8f0;
}

.pub-body-mode-btn--active {
    border-color: #2563eb;
    background: #eff6ff;
    color: #1d4ed8;
}

.publication-speak-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 0;
    background: transparent;
    color: #b8860b;
    cursor: pointer;
    line-height: 0;
    transition: color .15s ease, opacity .15s ease;
}

.publication-speak-btn svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

.publication-speak-btn:hover {
    color: #96700a;
}

.publication-speak-btn.is-speaking {
    color: #b8860b;
    opacity: .72;
}

.pub-body-html-scroll {
    max-height: 420px;
    overflow: auto;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    background: #f8fafc;
}

.pub-edit--body-expanded .pub-body-html-scroll {
    max-height: min(72vh, 640px);
}

.pub-body-textarea--html {
    display: block;
    width: 100%;
    min-height: 280px;
    max-height: none;
    margin: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 0.82rem;
    line-height: 1.55;
    white-space: pre;
    overflow: visible;
    resize: none;
    tab-size: 2;
    color: #0f172a;
    background: transparent;
}

.pub-body-textarea--html::selection {
    background: #bfdbfe;
}

textarea#publication-body[hidden] {
    display: none !important;
}

.pub-body-visual-wrap {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 10px;
}

.pub-body-visual-wrap[hidden] {
    display: none !important;
}

.pub-body-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    padding: 8px 10px;
    background: #f1f5f9;
    border: 1px solid #cbd5e1;
    border-radius: 6px 6px 0 0;
}

.pub-body-toolbar-sep {
    width: 1px;
    height: 22px;
    background: #cbd5e1;
    margin: 0 2px;
}

.pub-body-tool-btn {
    border: 1px solid #cbd5e1;
    background: #fff;
    color: #1e293b;
    font-size: 0.78rem;
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
}

.pub-body-tool-btn:hover {
    background: #f8fafc;
}

.pub-body-editor {
    min-height: 280px;
    max-height: 520px;
    overflow: auto;
    padding: 12px 14px;
    border: 1px solid #cbd5e1;
    border-top: 0;
    border-radius: 0 0 6px 6px;
    background: #fff;
    font-size: 0.9rem;
    line-height: 1.55;
    color: #0f172a;
}

.pub-body-editor:focus {
    outline: 2px solid #93c5fd;
    outline-offset: 0;
}

.rb-field--compact .rb-input {
    max-width: 100%;
}

.rb-field--datetime .rb-input {
    max-width: 200px;
}

.rb-textarea--short {
    min-height: 3.25rem;
    resize: vertical;
}

.rb-textarea {
    resize: vertical;
    min-height: 100px;
    font-family: inherit;
}

.rb-field--check {
    justify-content: flex-end;
}

.rb-check {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    color: #475569;
    cursor: pointer;
}

.rb-col-status {
    width: 90px;
    white-space: nowrap;
}

.rb-col-price {
    width: 120px;
    white-space: nowrap;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.rb-table th.rb-col-price {
    text-align: right;
}

.rb-detail-grid {
    display: grid;
    grid-template-columns: 140px 1fr;
    gap: 10px 16px;
    margin: 0 0 20px;
    font-size: 0.92rem;
}

.rb-detail-grid dt {
    margin: 0;
    font-weight: 600;
    color: #475569;
}

.rb-detail-grid dd {
    margin: 0;
    color: #0f172a;
    word-break: break-word;
}

.rb-detail-note {
    white-space: pre-wrap;
}

.rb-grid-head .rb-panel-title {
    margin: 0;
}

.rb-grid-meta {
    font-size: 0.85rem;
    color: #64748b;
}

.rb-table-wrap {
    overflow-x: auto;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
}

.rb-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.rb-table th,
.rb-table td {
    padding: 11px 14px;
    text-align: left;
    border-bottom: 1px solid #eef2f7;
}

.rb-table th {
    background: #f8fafc;
    font-size: 0.8rem;
    font-weight: 600;
    color: #475569;
    white-space: nowrap;
}

.rb-table tbody tr:hover {
    background: #f8fafc;
}

.rb-sort-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: inherit;
    text-decoration: none;
    font-weight: 600;
}

.rb-sort-link:hover {
    color: #1e293b;
}

.rb-sort-link.is-active {
    color: #1d4ed8;
}

.rb-sort-indicator {
    font-size: 0.7rem;
    opacity: 0.85;
}

.rb-col-num {
    width: 90px;
}

.rb-col-rank {
    width: 72px;
}

.rb-col-date {
    width: 170px;
}

.rb-cell-title {
    max-width: 360px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.rb-empty {
    text-align: center;
    color: #94a3b8;
    padding: 24px !important;
}

.rb-pager {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 14px;
    flex-wrap: wrap;
}

.rb-pager-info {
    font-size: 0.88rem;
    color: #475569;
}

.rb-page-size-form {
    margin: 0;
    margin-left: auto;
}

.rb-page-size {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: #64748b;
}

.rb-page-size select {
    padding: 6px 10px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 0.85rem;
}

.rb-col-action {
    width: 72px;
    text-align: center;
}

.rb-cell-website {
    max-width: 280px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.rb-row--selected {
    background: #eff6ff !important;
}

.rb-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    background: #fff;
    color: #475569;
    text-decoration: none;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.rb-icon-btn:hover {
    background: #f1f5f9;
    color: #1e293b;
    border-color: #cbd5e1;
}

/* Modal popup (Resource Book edit) */
.rb-modal[hidden] {
    display: none !important;
}

.rb-modal {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
}

.rb-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    cursor: pointer;
}

.rb-modal-panel {
    position: relative;
    z-index: 1;
    width: min(560px, 100%);
    max-height: calc(100vh - 48px);
    overflow-y: auto;
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 24px 48px rgba(15, 23, 42, 0.22);
    padding: 22px 24px;
}

.rb-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}

.rb-modal-title {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: #0f172a;
}

.rb-modal-hint {
    margin: 0 0 16px;
    font-size: 0.9rem;
    line-height: 1.5;
    color: #475569;
}

.rb-textarea {
    min-height: 160px;
    resize: vertical;
    font-family: inherit;
    line-height: 1.5;
}

.rb-modal-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 8px;
    background: #f1f5f9;
    color: #475569;
    font-size: 1.5rem;
    line-height: 1;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.15s ease;
}

.rb-modal-close:hover {
    background: #e2e8f0;
    color: #0f172a;
}

.rb-modal .rb-form-grid {
    grid-template-columns: 1fr 1fr;
}

.rb-modal .rb-field--wide {
    grid-column: 1 / -1;
}

.rb-modal-panel--wide {
    width: min(640px, 100%);
}

body.rb-modal-open {
    overflow: hidden;
}

@media (max-width: 768px) {
    .rb-form-grid {
        grid-template-columns: 1fr;
    }

    .rb-form-row--article-1,
    .rb-form-row--article-2,
    .rb-form-row--article-3,
    .rb-form-row--pub-1,
    .rb-form-row--pub-meta,
    .rb-form-row--pub-4 {
        grid-template-columns: 1fr;
    }

    .rb-field--datetime .rb-input,
    .rb-field--date-only .rb-input,
    .rb-field--medium .rb-input,
    .rb-field--compact-wide .rb-input {
        max-width: none;
    }

    .rb-modal .rb-form-grid {
        grid-template-columns: 1fr;
    }

    .rb-page-size-form {
        margin-left: 0;
        width: 100%;
    }
}
