/* public/style.css */
*,::before,::after{box-sizing:border-box;margin:0;padding:0}
html{-webkit-text-size-adjust:100%}
body{font-family:"IBM Plex Sans","Noto Sans Arabic",system-ui,-apple-system,"Segoe UI",Roboto,sans-serif;background-color:#f2f6f9;background-image:linear-gradient(rgba(34,74,120,.09) 1px,transparent 1px),linear-gradient(90deg,rgba(34,74,120,.09) 1px,transparent 1px);background-size:24px 24px;color:#12263f;line-height:1.5;min-height:100vh;min-height:100dvh;-webkit-tap-highlight-color:transparent}
body.sheet-open{overflow:hidden}
button{font:inherit;color:inherit;cursor:pointer}
svg{display:block}
[hidden]{display:none!important}

.topbar{position:sticky;top:0;z-index:5;display:flex;align-items:center;gap:10px;min-height:56px;padding:6px 16px;padding-top:max(6px,env(safe-area-inset-top));background:#12263f;color:#fff}
.topbar-icon{display:grid;place-items:center;width:36px;height:36px;color:#ffe36e}
.topbar-icon svg{width:22px;height:22px}
.topbar h1{font-size:1.2em;font-weight:600;letter-spacing:.005em}
.back{display:grid;place-items:center;width:44px;height:44px;margin-left:-12px;border-radius:50%;color:#fff;text-decoration:none}
.back:active{background:rgba(255,255,255,.15)}

main{max-width:720px;margin:0 auto;padding:16px 14px 60px;padding-bottom:max(60px,env(safe-area-inset-bottom))}
h2{font-size:1.05em;margin-bottom:10px;font-weight:700;display:flex;align-items:center;gap:8px}
h2 .hicon{width:18px;height:18px;color:#4b5f78;flex:none}
.hicon svg,.slot-icon svg,.note-icon svg{width:100%;height:100%}

.panel{background:#fff;border:1px solid #c5d2de;border-radius:10px;padding:16px;margin-bottom:16px}

.no-items{color:#4b5f78;font-style:italic;padding:10px 0;font-size:.93em}
.banner{background:#fff4d6;border:1px solid #e6c667;border-radius:6px;padding:8px 12px;margin-bottom:14px;font-size:.9em;display:flex;align-items:center;gap:8px}
.banner svg{flex:none;color:#8a5d00}

/* subjects screen (only shown when there is more than one subject) */
.subject-grid{display:grid;grid-template-columns:repeat(2,1fr);gap:12px}
.subject-card{display:flex;flex-direction:column;justify-content:center;gap:8px;min-height:104px;padding:16px;background:#fff;border:1px solid #c5d2de;border-radius:10px;color:#12263f;text-decoration:none;font-weight:700;font-size:1.05em}
.subject-card:active{background:rgba(255,227,110,.25);border-color:#12263f}
.subject-card .subject-icon{width:32px;height:32px;color:#4b5f78}
.subject-card .subject-icon svg{width:100%;height:100%}
@media(min-width:560px){.subject-grid{grid-template-columns:repeat(3,1fr)}}

/* code gate */
.gate{display:flex;flex-direction:column;gap:10px;padding:14px;background:#fff;border:1px solid #c5d2de;border-radius:10px;margin-bottom:16px}
.gate-head{display:flex;align-items:center;gap:10px;color:#4b5f78;font-size:.93em}
.gate-head svg{color:#12263f;flex:none}
.gate-row{display:flex;gap:8px}
.gate-input{flex:1;min-width:0;min-height:44px;padding:8px 12px;border:1px solid #c5d2de;border-radius:6px;font:inherit;font-size:1em;color:#12263f;background:#fff}
.gate-input:focus{outline:none;border-color:#12263f;box-shadow:0 0 0 2px rgba(18,38,63,.15)}
.gate-btn{min-height:44px;padding:0 18px;background:#12263f;color:#fff;border:0;border-radius:6px;font-weight:700;font-size:.95em}
.gate-btn:active{background:#2a4a7f}
.gate-btn:disabled{opacity:.5}
.gate-err{color:#b3261e;font-size:.88em;font-weight:500;min-height:1.2em}

/* upload panel */
.upload-panel{background:#fff;border:1px solid #c5d2de;border-radius:10px;padding:16px;margin-bottom:16px}
.comment-area{margin-bottom:12px}
.comment-area label{display:block;font-size:.85em;font-weight:600;margin-bottom:4px;color:#12263f}
.comment-area input{width:100%;min-height:44px;padding:8px 12px;border:1px solid #c5d2de;border-radius:6px;font:inherit;font-size:1em;color:#12263f;background:#fff}
.comment-area input:focus{outline:none;border-color:#12263f;box-shadow:0 0 0 2px rgba(18,38,63,.15)}

.slot-wrap{position:relative;margin-bottom:10px}
.slot{display:flex;align-items:center;gap:12px;min-height:60px;padding:10px 52px 10px 12px;background:#fff;border:2px dashed #12263f;border-radius:8px;cursor:pointer;transition:border-color .2s,background-color .2s}
.slot:hover,.slot.drag-over{border-color:#c9a400;background:rgba(255,227,110,.12)}
.slot:focus-within{outline:2px solid #12263f;outline-offset:2px}
.slot.filled{border-style:solid;border-color:#12263f}
.slot-icon{width:28px;height:28px;color:#4b5f78;flex:none}
.slot.filled .slot-icon{color:#12263f}
.slot-text{min-width:0;flex:1}
.slot-title{display:block;font-weight:600;font-size:.95em}
.slot-sub{display:block;font-size:.85em;color:#4b5f78;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.slot-sub.error{color:#b3261e;white-space:normal;font-weight:500}
.slot-sub.synced{color:#1d7a4b;font-weight:600}
.slot input[type=file]{position:absolute;width:1px;height:1px;opacity:0;overflow:hidden}
.slot-clear{position:absolute;right:4px;top:10px;width:40px;height:40px;display:grid;place-items:center;border:0;border-radius:50%;background:none;color:#4b5f78}
.slot-clear svg{width:18px;height:18px}
.slot-clear:active{background:rgba(18,38,63,.1)}

.bar-wrap{height:5px;background:#c5d2de;border-radius:3px;overflow:hidden;margin-top:6px}
.bar{height:100%;width:0;background:#2a6fdb;transition:width .15s}

.action-msg{font-size:.88em;color:#4b5f78;margin:4px 0 10px;display:flex;align-items:center;gap:6px}
.action-msg svg{flex:none;width:14px;height:14px}
.action-msg.warn{color:#8a5d00}
.btn{display:flex;align-items:center;justify-content:center;gap:8px;width:100%;min-height:46px;padding:10px 16px;background:#12263f;color:#fff;border:0;border-radius:8px;font-weight:700;font-size:.95em}
.btn:active{background:#2a4a7f}
.btn:disabled{opacity:.5}
.btn svg{width:16px;height:16px}

/* status dots */
.dot{display:inline-block;width:10px;height:10px;border-radius:50%;flex:none;background:#9aa9ba;box-shadow:0 0 0 2px rgba(154,169,186,.25)}
.dot.pending{background:#e0a100;box-shadow:0 0 0 2px rgba(224,161,0,.22)}
.dot.uploading{background:#2a6fdb;box-shadow:0 0 0 2px rgba(42,111,219,.22);animation:pulse 1s ease-in-out infinite}
.dot.synced{background:#1d7a4b;box-shadow:0 0 0 2px rgba(29,122,75,.2)}
.dot.none{visibility:hidden}
.dot.error{background:#b3261e;box-shadow:0 0 0 2px rgba(179,38,30,.2)}
@keyframes pulse{50%{opacity:.35}}

/* pamphlet display */
.pamphlet-card{background:#fff;border:1px solid #c5d2de;border-radius:10px;padding:16px;margin-bottom:16px}
.pamphlet-head{display:flex;align-items:center;justify-content:space-between;gap:10px;margin-bottom:10px}
.pamphlet-head h2{margin:0}
.pamphlet-row{display:flex;align-items:center;gap:10px}
.pamphlet-link{font-weight:700;font-size:1.05em;color:#12263f;text-decoration:underline;padding:6px 0}
.pamphlet-link:hover{color:#2a4a7f}
.pamphlet-updated{margin:2px 0 0 20px}
.date-btn{display:inline-flex;align-items:center;gap:8px;min-height:40px;padding:6px 10px;margin-left:-10px;background:none;border:0;border-radius:6px;color:#4b5f78;font-size:.88em}
.date-btn:active,.date-btn:hover{background:rgba(18,38,63,.07);color:#12263f}
.date-btn svg{flex:none;width:14px;height:14px}

/* notes list */
.notes-head{display:flex;align-items:center;justify-content:space-between;gap:10px;margin-bottom:10px}
.notes-head h2{margin:0}
.notes-count{font-size:.82em;color:#4b5f78;font-weight:500}
.note-link{display:flex;align-items:center;gap:10px;padding:10px 6px;min-height:48px;color:#12263f;text-decoration:none;border-radius:6px;font-size:.93em;border-bottom:1px solid #e3eaf1}
.note-link:last-of-type{border-bottom:0}
.note-link:active,.note-link:hover{background:rgba(18,38,63,.05)}
.note-icon{width:20px;height:20px;color:#b3261e;flex:none}
.note-text{min-width:0;flex:1;display:flex;gap:6px;flex-wrap:wrap;align-items:baseline}
.note-date{font-family:"IBM Plex Mono",ui-monospace,monospace;white-space:nowrap;font-size:.92em}
.note-comment{overflow:hidden;text-overflow:ellipsis;color:#4b5f78}
.load-more{display:flex;align-items:center;justify-content:center;gap:6px;width:100%;min-height:44px;margin-top:8px;padding:10px;background:#fff;border:1px solid #c5d2de;border-radius:8px;color:#12263f;font-weight:600;font-size:.9em}
.load-more:active{background:rgba(255,227,110,.25)}
.load-more svg{width:14px;height:14px}

/* history sheet */
.sheet-backdrop{position:fixed;inset:0;z-index:20;background:rgba(18,38,63,.5);display:flex;align-items:flex-end;justify-content:center}
.sheet{width:100%;max-width:720px;max-height:85vh;max-height:85dvh;display:flex;flex-direction:column;background:#fff;border-radius:14px 14px 0 0;animation:sheet-up .22s ease-out}
@keyframes sheet-up{from{transform:translateY(40px);opacity:.5}to{transform:none;opacity:1}}
.sheet-head{display:flex;align-items:center;justify-content:space-between;padding:6px 8px 6px 16px;border-bottom:1px solid #c5d2de}
.sheet-head h2{margin:0;display:flex;align-items:center;gap:8px}
.sheet-close{width:44px;height:44px;display:grid;place-items:center;border:0;border-radius:50%;background:none}
.sheet-close svg{width:20px;height:20px}
.sheet-close:active{background:rgba(18,38,63,.1)}
.sheet-body{overflow-y:auto;padding:6px 16px;padding-bottom:max(18px,env(safe-area-inset-bottom))}
.hist-row{display:flex;align-items:center;justify-content:space-between;gap:10px;padding:12px 0;border-bottom:1px solid #e3eaf1}
.hist-row:last-child{border-bottom:0}
.hist-date{font-weight:600;font-size:.95em;display:flex;align-items:center;gap:8px}
.hist-sub{font-size:.82em;color:#4b5f78;margin-top:2px}
.badge{display:inline-block;padding:1px 8px;border-radius:10px;background:#1d7a4b;color:#fff;font-size:.75em;font-weight:600;vertical-align:1px}
.hist-actions{display:flex;gap:6px;flex:none}
.btn-small{min-height:38px;padding:6px 12px;background:#fff;color:#12263f;border:1px solid #12263f;border-radius:6px;font-weight:600;font-size:.85em;text-decoration:none;display:inline-flex;align-items:center;gap:4px}
.btn-small:active{background:rgba(255,227,110,.35)}
.btn-small:disabled{opacity:.5}
.btn-small svg{width:13px;height:13px}

:focus-visible{outline:2px solid #12263f;outline-offset:2px}
@keyframes flash-bg{0%{background-color:#ffe36e}100%{background-color:transparent}}
.flash{animation:flash-bg 1.5s ease-out}
@media(prefers-reduced-motion:reduce){.flash,.sheet,.dot.uploading{animation:none}.slot,.bar{transition:none}}
