/* Manual timetable editor: scoped UI v2 design, isolated from legacy app_ui.css. */
.r2-manual-editor__workspace{display:grid;grid-template-columns:minmax(170px,200px) minmax(0,1fr) minmax(224px,252px);align-items:stretch;gap:12px;margin-top:8px;min-width:0}
.r2-manual-editor__classes,.r2-manual-editor__library,.r2-manual-editor__main{min-width:0;background:var(--r2-surface);border:1px solid var(--r2-border);border-radius:12px}
.r2-manual-editor__classes,.r2-manual-editor__library{padding:12px;display:flex;flex-direction:column;gap:12px;min-height:0;overflow:hidden}
.r2-manual-editor__main{padding:12px;display:flex;flex-direction:column;gap:0;min-width:0}
.r2-manual-editor__side-head{display:flex;justify-content:space-between;align-items:center;gap:8px;flex-shrink:0}
.r2-manual-editor__side-head strong{font-size:.95rem;color:var(--r2-text)}
.r2-manual-editor__side-head span{font-size:.78rem;color:var(--r2-text-muted)}
.r2-manual-editor__classes input,.r2-manual-editor__library input,.r2-manual-editor__library select{min-width:0;width:100%}
.r2-manual-editor__group-list,.r2-manual-editor__subject-list{display:flex;flex-direction:column;gap:4px;overflow:auto;min-height:0;flex:1;align-content:flex-start;overscroll-behavior:contain}
.r2-manual-editor__group-name{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.r2-manual-editor__side-link{font-size:.82rem;color:var(--r2-primary);text-decoration:none}
.r2-manual-editor__toolbar{display:grid;gap:10px;padding-bottom:12px}
.r2-manual-editor__title{display:flex;justify-content:space-between;align-items:baseline;gap:8px}
.r2-manual-editor__title h2{margin:0;font-size:1.125rem}
.r2-manual-editor__title span{font-size:.78rem;color:var(--r2-text-muted);text-align:right}
.r2-manual-editor__toolbar-actions{display:flex;align-items:center;flex-wrap:wrap;gap:6px;min-width:0}
.r2-manual-editor__toolbar-actions .r2-button{white-space:nowrap}
.r2-manual-editor__mode{display:inline-flex;gap:2px;border:1px solid var(--r2-border);border-radius:7px;padding:2px;background:var(--r2-surface-muted)}
.r2-manual-editor__notice{margin-bottom:12px;padding:8px 10px;background:var(--r2-surface-muted);border-radius:6px;color:var(--r2-text-secondary);font-size:.8rem;line-height:1.4}
.r2-manual-editor__notice.is-error{background:var(--r2-danger-soft);color:var(--r2-danger)}
.r2-manual-editor__grid-wrap{overflow:auto;max-width:100%}
.r2-manual-editor__grid{display:grid;grid-template-columns:44px repeat(var(--manual-day-count,5),minmax(112px,1fr));min-width:610px;gap:1px;background:var(--r2-border);border:1px solid var(--r2-border);border-radius:8px;overflow:hidden}
.r2-manual-editor__head,.r2-manual-editor__number,.r2-manual-editor__cell{background:var(--r2-surface)}
.r2-manual-editor__head{text-align:center;font-size:.8rem;font-weight:650;padding:10px 4px;background:var(--r2-surface-muted)}
.r2-manual-editor__number{display:flex;align-items:center;justify-content:center;color:var(--r2-text-muted);font-size:.82rem}
.r2-manual-editor__cell{position:relative;min-height:69px;padding:5px;cursor:pointer;outline-offset:-2px;transition:background .15s ease}
.r2-manual-editor__cell.is-empty:hover{background:var(--r2-primary-soft)}
.r2-manual-editor__empty{display:flex;align-items:center;justify-content:center;height:100%;min-height:58px;color:var(--r2-primary);font-size:.76rem;opacity:0;pointer-events:none}
.r2-manual-editor__cell.is-empty:hover .r2-manual-editor__empty,.r2-manual-editor__cell.is-empty:focus-visible .r2-manual-editor__empty{opacity:1}
.r2-manual-editor__cell.is-selected{outline:2px solid var(--r2-primary);z-index:1}
.r2-manual-editor__cell.is-drag-over{background:var(--r2-primary-soft);outline:2px dashed var(--r2-primary);z-index:1}
.r2-manual-editor__cell:focus-visible{outline:2px solid var(--r2-primary);outline-offset:-2px}
.r2-manual-editor__lesson{height:100%;min-height:58px;border:1px solid var(--r2-success-border);background:var(--r2-success-soft);border-radius:6px;padding:6px;display:flex;flex-direction:column;gap:3px;overflow:hidden;cursor:grab}
.r2-manual-editor__lesson strong{font-size:.78rem;line-height:1.3;overflow-wrap:anywhere}
.r2-manual-editor__lesson span,.r2-manual-editor__lesson small{font-size:.7rem;color:var(--r2-text-secondary);line-height:1.25;overflow:hidden;text-overflow:ellipsis}
.r2-manual-editor__lesson.is-unassigned{background:var(--r2-warning-soft);border-color:var(--r2-warning-border)}
.r2-manual-editor__add-row{align-self:flex-start;margin-top:10px}
.r2-manual-editor__details{display:grid;gap:10px;padding:12px;background:var(--r2-primary-soft);border:1px solid var(--r2-primary-border);border-radius:8px;flex:0 0 auto}
.r2-manual-editor__details[hidden],.r2-manual-editor__details [hidden]{display:none !important}
.r2-manual-editor__details h3{font-size:.9rem;margin:0;color:var(--r2-text)}
.r2-manual-editor__details label{display:grid;gap:5px;font-size:.8rem;color:var(--r2-text-secondary)}
.r2-manual-editor__details .r2-button--danger{justify-self:start}
.r2-manual-editor__no-subjects{padding:16px 6px;font-size:.82rem;text-align:center;color:var(--r2-text-muted)}
.r2-manual-editor__issues{border:1px solid var(--r2-danger-border);background:var(--r2-danger-soft);padding:10px 12px;margin:0 0 12px;border-radius:8px;display:grid;gap:5px;color:var(--r2-danger);font-size:.8rem}
.r2-manual-editor__issues[hidden]{display:none}
.r2-manual-editor__cell.is-invalid{box-shadow:inset 0 0 0 2px var(--r2-danger);background:var(--r2-danger-soft)}
/* app_ui.css uses body.has-app-shell button[type=button]: isolate editor buttons only. */
body.has-app-shell .r2-manual-editor button[type="button"]{min-height:32px;padding:6px 10px;border:1px solid transparent;border-radius:6px;background:transparent;box-shadow:none;color:var(--r2-text);font-size:.78rem;font-weight:600;line-height:1.35;text-align:center;transform:none;transition:background .15s ease,border-color .15s ease}
body.has-app-shell .r2-manual-editor button[type="button"]:hover{transform:none;box-shadow:none}
body.has-app-shell .r2-manual-editor button[type="button"]:focus-visible{outline:2px solid var(--r2-primary);outline-offset:2px}
body.has-app-shell .r2-manual-editor button[type="button"].r2-button--primary{background:var(--r2-primary);border-color:var(--r2-primary);color:white !important}
body.has-app-shell .r2-manual-editor button[type="button"].r2-button--primary:hover:not(:disabled){background:var(--r2-primary-hover);border-color:var(--r2-primary-hover)}
body.has-app-shell .r2-manual-editor button[type="button"].r2-button--secondary{border-color:var(--r2-border-strong);background:var(--r2-surface);color:var(--r2-text) !important}
body.has-app-shell .r2-manual-editor button[type="button"].r2-button--secondary:hover:not(:disabled){background:var(--r2-primary-soft);border-color:var(--r2-primary-border)}
body.has-app-shell .r2-manual-editor button[type="button"].r2-button--quiet{color:var(--r2-primary) !important;background:transparent}
body.has-app-shell .r2-manual-editor button[type="button"].r2-button--quiet:hover:not(:disabled){background:var(--r2-primary-soft)}
body.has-app-shell .r2-manual-editor button[type="button"].r2-button--danger{color:var(--r2-danger) !important;background:var(--r2-surface);border-color:var(--r2-danger-border)}
body.has-app-shell .r2-manual-editor button[type="button"].r2-button--danger:hover:not(:disabled){background:var(--r2-danger-soft)}
body.has-app-shell .r2-manual-editor button[type="button"].r2-manual-editor__group{display:flex;align-items:center;justify-content:space-between;gap:6px;min-height:40px;flex:none;padding:8px 10px;background:var(--r2-surface-subtle);color:var(--r2-text);border-color:var(--r2-border);font-weight:600;font-size:.84rem;text-align:left;box-shadow:none}
body.has-app-shell .r2-manual-editor button[type="button"].r2-manual-editor__group small{font-size:.72rem;color:var(--r2-text-muted);font-weight:400;white-space:nowrap}
body.has-app-shell .r2-manual-editor button[type="button"].r2-manual-editor__group:hover{background:var(--r2-primary-soft);border-color:var(--r2-primary-border)}
body.has-app-shell .r2-manual-editor button[type="button"].r2-manual-editor__group.is-active{background:var(--r2-primary-soft);border-color:var(--r2-primary);color:var(--r2-primary)}
body.has-app-shell .r2-manual-editor button[type="button"].r2-manual-editor__subject{display:grid;gap:4px;justify-items:start;justify-content:stretch;align-content:center;flex:none;text-align:left;min-height:54px;padding:9px 10px;background:var(--r2-surface-subtle);border-color:var(--r2-border);color:var(--r2-text);box-shadow:none;cursor:grab}
body.has-app-shell .r2-manual-editor button[type="button"].r2-manual-editor__subject strong{font-size:.84rem;font-weight:600;line-height:1.32;overflow-wrap:anywhere}
body.has-app-shell .r2-manual-editor button[type="button"].r2-manual-editor__subject span{font-size:.72rem;color:var(--r2-text-muted);font-weight:400}
body.has-app-shell .r2-manual-editor button[type="button"].r2-manual-editor__subject:hover{border-color:var(--r2-primary-border);background:var(--r2-primary-soft)}
body.has-app-shell .r2-manual-editor button[type="button"].r2-manual-editor__subject.is-armed{border-color:var(--r2-primary);background:var(--r2-primary-soft)}
body.has-app-shell .r2-manual-editor button[type="button"].r2-manual-editor__issue{display:block;text-align:left;padding:5px;color:var(--r2-danger);background:none;border:0;font-weight:500}
body.has-app-shell .r2-manual-editor button[type="button"].r2-manual-editor__issue:hover{text-decoration:underline;background:none}
body.has-app-shell .r2-manual-editor__mode button[data-editor-mode]{border:0;background:transparent;color:var(--r2-text-secondary) !important;box-shadow:none}
body.has-app-shell .r2-manual-editor__mode button[data-editor-mode].is-active{background:var(--r2-primary);color:white !important}
body.has-app-shell .r2-manual-editor button[type="button"]:disabled{opacity:.5;cursor:not-allowed}
@media(max-width:1150px){.r2-manual-editor__workspace{grid-template-columns:180px minmax(0,1fr)}.r2-manual-editor__library{grid-column:1/-1;min-height:320px;max-height:420px}.r2-manual-editor__subject-list{display:grid;grid-template-columns:repeat(auto-fill,minmax(150px,1fr));align-content:start}}
@media(max-width:700px){.r2-manual-editor__workspace{grid-template-columns:minmax(0,1fr)}.r2-manual-editor__classes{max-height:260px}.r2-manual-editor__library{grid-column:auto;max-height:460px;min-height:260px}.r2-manual-editor__group-list{max-height:180px}.r2-manual-editor__toolbar-actions{gap:6px}.r2-manual-editor__subject-list{grid-template-columns:repeat(2,minmax(0,1fr))}}
@media(prefers-reduced-motion:reduce){.r2-manual-editor__cell,body.has-app-shell .r2-manual-editor button[type="button"]{transition:none}}

/* Batch 6: place the timetable first; keep long side lists usable without page scrolling. */
.r2-manual-editor{display:flex;flex-direction:column;gap:8px;min-width:0}
.r2-manual-editor__topbar{display:flex;align-items:center;flex-wrap:wrap;gap:8px 20px;min-height:42px}
.r2-manual-editor__topbar h1{margin:0;font-size:1.25rem;line-height:1.3;white-space:nowrap}
.r2-manual-editor .r2-manual-editor__topbar .r2-tabbar{margin:0;min-width:0;flex:1;border-bottom:0;align-self:stretch}
.r2-manual-editor__topbar .r2-tab{display:flex;align-items:center;padding:8px 12px}
.r2-manual-editor__view-link{margin-left:auto;white-space:nowrap}
.r2-manual-editor__workspace{margin-top:0;flex:1;min-height:0}
.r2-manual-editor__classes,.r2-manual-editor__library,.r2-manual-editor__main{min-height:0;max-height:100%;overflow:hidden}
.r2-manual-editor__main .r2-manual-editor__grid-wrap{flex:1;min-height:0;overflow:auto;overscroll-behavior:contain}
.r2-manual-editor__library-browser{display:flex;flex-direction:column;gap:12px;flex:1;min-height:0;overflow:hidden}
.r2-manual-editor__library-browser[hidden]{display:none !important}
.r2-manual-editor__library-browser > input,.r2-manual-editor__library-browser > select{flex:none}
.r2-manual-editor__library .r2-manual-editor__details{align-content:start;min-height:0;max-height:calc(100% - 42px);overflow-y:auto;flex:0 1 auto}
.r2-manual-editor__panel-tabs{display:flex;gap:12px;align-items:center;min-width:0}
body.has-app-shell .r2-manual-editor button[type="button"].r2-manual-editor__panel-tab{padding:4px 2px 6px;border:0;border-bottom:2px solid transparent;border-radius:0;min-height:30px;background:transparent;color:var(--r2-text-muted);font-weight:600;font-size:.84rem}
body.has-app-shell .r2-manual-editor button[type="button"].r2-manual-editor__panel-tab.is-active{color:var(--r2-primary);border-bottom-color:var(--r2-primary)}
body.has-app-shell .r2-manual-editor button[type="button"].r2-manual-editor__panel-tab:hover:not(:disabled){color:var(--r2-primary);background:var(--r2-primary-soft)}
.r2-manual-editor__panel-tab[hidden]{display:none !important}
@media(min-width:1151px) and (min-height:620px){
    .r2-manual-editor{height:calc(100dvh - 114px);min-height:500px}
}
@media(max-width:1150px){
    .r2-manual-editor__workspace{flex:none}
    .r2-manual-editor__classes,.r2-manual-editor__library,.r2-manual-editor__main{max-height:none}
    .r2-manual-editor__library-browser{min-height:240px}
}
@media(max-width:700px){
    .r2-manual-editor__topbar .r2-tabbar{order:3;flex-basis:100%;overflow-x:auto}
    .r2-manual-editor__view-link{margin-left:auto}
    .r2-manual-editor__library-browser{min-height:200px}
}

/* Shared legacy rules can set display:flex on buttons even when hidden. */
.r2-manual-editor [hidden]{display:none !important}

/* Batch 7: independently adjustable class and subject panels on desktop. */
.r2-manual-editor__resizer{display:none}
@media(min-width:1151px){
    .r2-manual-editor__workspace{
        display:grid;
        grid-template-columns:var(--manual-left-width,200px) 14px minmax(0,1fr) 14px var(--manual-right-width,252px);
        column-gap:0;
        row-gap:0;
    }
    .r2-manual-editor__resizer{
        display:flex;
        align-items:center;
        justify-content:center;
        width:14px;
        min-width:14px;
        cursor:col-resize;
        touch-action:none;
        outline-offset:-1px;
        border-radius:6px;
        position:relative;
        z-index:2;
    }
    .r2-manual-editor__resizer::before{
        content:"";
        display:block;
        height:48px;
        width:3px;
        border-radius:8px;
        background:var(--r2-border-strong,#bcc7d7);
        transition:background .15s ease,width .15s ease;
    }
    .r2-manual-editor__resizer:hover::before,
    .r2-manual-editor__resizer:focus-visible::before,
    .r2-manual-editor__resizer.is-active::before{
        background:var(--r2-primary,#2563a5);
        width:4px;
    }
    .r2-manual-editor__resizer:focus-visible{outline:2px solid var(--r2-primary,#2563a5)}
    .r2-manual-editor.is-resizing,.r2-manual-editor.is-resizing *{user-select:none !important;cursor:col-resize !important}
}
@media(prefers-reduced-motion:reduce){.r2-manual-editor__resizer::before{transition:none}}

/* Batch 8: compact recovery choice only when edits genuinely diverge. */
.r2-manual-editor__conflict-actions{display:flex;align-items:center;flex-wrap:wrap;gap:8px;margin:-4px 0 12px}
.r2-manual-editor__conflict-actions[hidden]{display:none!important}
