/* Compact phone layout. Desktop and the approved large portrait layout stay intact. */
body:not(.user-view) .user-only { display: none !important; }
.primary-actions > button { grid-column: 1 / -1; }
@media (max-width: 780px), (max-width: 1000px) and (max-height: 500px) and (pointer: coarse) {
  body { min-width: 320px; font-size: 14px; }
  .topbar { position: static; display: grid; grid-template-columns: 1fr auto; gap: 10px; min-height: 0; padding: 12px 14px; }
  .logo { width: 126px; height: 34px; grid-template-columns: 40px 1fr; font-size: 17px; }
  .type-toggle { display: none; }
  .account-nav { display: flex; gap: 6px; }
  .account-nav a { font-size: 12px; display: grid; place-items: center; min-height: 34px; }
  .outline-pill, .help-pill { min-width: 43px; height: 34px; }
  .search { grid-column: 1 / -1; grid-row: 2; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 0; }
  .search label { min-width: 0; }
  .search input { height: 42px; min-width: 0; padding: 0 8px 0 32px; font-size: 16px; }
  .search label > svg { left: 10px; top: 13px; width: 16px; height: 16px; }
  .search label:first-child input { border-radius: 24px 0 0 24px; border-right: 1px solid #ccc; }
  .search label:nth-of-type(2) input { border-radius: 0 24px 24px 0; }
  .template-note { margin: 12px 14px; padding: 0; font-size: 11px; line-height: 1.6; }
  .storage-notice { margin: 12px 14px; padding: 12px; font-size: 13px; }
  body .teacher-manager { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); align-items: end; gap: 8px; margin: 0 14px 16px; padding: 0; }
  body .teacher-manager label { grid-column: 1 / -1; min-width: 0; gap: 4px; font-size: 11px; }
  body .teacher-manager select { min-width: 0; width: 100%; height: 42px; padding: 0 24px 0 9px; font-size: 16px; }
  body .teacher-manager .manager-button, body .teacher-manager .mode-button { width: 100%; height: 42px; min-height: 42px; margin: 0; padding: 0 6px; gap: 4px; font-size: 12px; white-space: nowrap; }
  body .teacher-manager button svg { width: 14px; height: 14px; flex-shrink: 0; }
  body.user-view .teacher-manager label { grid-column: 1 / 3; }
  body.user-view .teacher-manager .mode-button { grid-column: 3; }
  .mini-profile { display: none; }
  .profile-shell, .content-shell { display: grid; grid-template-columns: minmax(0,1fr); padding: 0 14px; gap: 18px; min-height: 0; }
  .profile-main { display: grid; grid-template-columns: minmax(105px,.85fr) minmax(0,1.4fr); grid-template-areas: "identity identity" "score stats" "actions actions"; align-items: center; gap: 18px 14px; }
  .identity-row { grid-area: identity; grid-template-columns: clamp(68px,18vw,88px) minmax(0,1fr); gap: 12px; align-items: center; }
  .teacher-photo { width: 100%; }
  .photo-placeholder { gap: 2px; }
  .photo-placeholder svg { width: 22px; height: 22px; }
  .photo-placeholder b, .photo-placeholder small { font-size: 10px; }
  .name-line { gap: 4px; align-items: flex-start; }
  .name-line h1 { margin: 0 0 6px; font-size: clamp(20px,5.4vw,26px); line-height: 1.18; }
  .bookmark { width: 36px; height: 40px; flex-shrink: 0; }
  .bookmark svg { width: 20px; height: 20px; }
  .identity-copy p { font-size: 12px; line-height: 1.7; overflow-wrap: anywhere; }
  .score-row { grid-area: score; margin: 0; }
  .big-score { font-size: clamp(46px,12vw,60px); line-height: 1; }
  .score-denominator { font-size: 15px; }
  .score-row p { margin: 5px 0 0; font-size: 11px; line-height: 1.6; }
  .score-row p a { display: inline-block; }
  .stat-pair { grid-area: stats; justify-content: center; gap: 12px; margin: 0; }
  .stat-pair div { min-width: 0; }
  .stat-pair div + div { padding-left: 12px; border-color: #ddd; }
  .stat-pair strong { font-size: clamp(22px,6vw,28px); line-height: 1.3; }
  .stat-pair span { font-size: 11px; white-space: nowrap; }
  .primary-actions { grid-area: actions; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 10px; width: 100%; max-width: none; }
  body.user-view .rate-button { grid-column: 1 / -1; }
  .rate-button, .compare-button { min-height: 42px; font-size: 14px; padding: 0 10px; }
  .profile-side { grid-column: 1; display: grid; grid-template-columns: minmax(0,1fr); grid-template-rows: auto; gap: 12px; }
  .distribution, .similar { margin: 0; padding: 14px; }
  .panel-title h2 { margin: 0 0 12px; font-size: 16px; }
  .panel-title .icon-only { width: 36px; height: 36px; margin-top: -6px; }
  .distribution ul { gap: 9px; }
  .distribution li { grid-template-columns: 64px minmax(0,1fr) 32px; gap: 8px; font-size: 12px; }
  .bar-track { height: 20px; }
  .similar-list { grid-template-columns: repeat(3,minmax(0,1fr)); gap: 8px; }
  .similar-list b { height: 32px; margin-bottom: 5px; font-size: 14px; }
  .similar-list span { font-size: 12px; overflow-wrap: anywhere; }
  .similar-empty { padding: 4px 0; font-size: 12px; }
  .content-shell { margin-top: 20px; }
  .section-head { gap: 8px; }
  .section-head h2 { padding: 12px 0; font-size: 17px; }
  .section-head h2:after { height: 3px; }
  .section-rate { min-height: 40px; width: auto; padding: 0 10px; font-size: 12px; gap: 4px; }
  .filter-row { margin: 12px 0; gap: 6px; }
  .course-filter { width: 100%; }
  .course-filter select { height: 42px; font-size: 16px; }
  .filter-row > span { font-size: 12px; }
  .ratings-list { gap: 12px; }
  .rating-card { grid-template-columns: minmax(0,1fr); gap: 12px; padding: 14px; }
  .rating-metrics { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px; }
  .metric { display: flex; align-items: center; justify-content: space-between; min-height: 44px; padding: 8px 10px; gap: 6px; }
  .metric span { width: auto; font-size: 11px; }
  .metric strong { font-size: 24px; }
  .rating-head { flex-direction: row; align-items: baseline; gap: 4px 10px; }
  .rating-head a { font-size: 14px; }
  .rating-head time { font-size: 11px; }
  .rating-meta { gap: 4px 12px; margin: 8px 0 12px; }
  .rating-meta span { font-size: 12px; }
  .rating-body > p { margin-bottom: 12px; font-size: 14px; line-height: 1.8; }
  .tags { gap: 6px; margin-bottom: 8px; }
  .tags span { padding: 4px 7px; font-size: 11px; }
  .rating-actions { gap: 4px; }
  .rating-actions button { min-height: 40px; padding: 4px 6px; font-size: 12px; }
  .rating-actions svg { width: 17px; height: 17px; }
  .empty-state { padding: 24px 14px; font-size: 13px; }
  .site-footer { margin-top: 32px; padding: 20px 18px 28px; font-size: 11px; }
  .site-footer .footer-logo { margin: 14px auto 0; font-size: 18px; }
  .site-footer .text-button { min-height: 40px; }
  .appreciation-card { margin-top: 20px; padding-top: 20px; }
  .appreciation-card h2 { font-size: 16px; }
  .appreciation-intro { font-size: 12px; margin-top: 8px; }
  .appreciation-card .appreciation-code { width: 160px; margin-top: 12px; }
  .modal { width: calc(100% - 24px); max-width: 520px; max-height: calc(100dvh - 24px); margin: auto; overflow-x: hidden; }
  .modal form > header, .help-header { padding: 14px 16px; gap: 8px; }
  .modal h2, .help-header h2 { font-size: 20px; }
  .modal-kicker { font-size: 11px; }
  .close-modal { flex-shrink: 0; width: 40px; height: 40px; }
  .form-grid { grid-template-columns: minmax(0,1fr); padding: 16px; gap: 14px; }
  .form-grid label { font-size: 12px; gap: 5px; }
  .form-grid input, .form-grid select, .form-grid textarea { font-size: 16px; padding: 10px; min-height: 44px; }
  .score-inputs { grid-template-columns: repeat(2,minmax(0,1fr)); padding: 16px 16px 0; gap: 12px; }
  .score-inputs legend { font-size: 12px; }
  .rating-choice { gap: 4px; }
  .rating-choice span { height: 40px; font-size: 14px; }
  .modal form > footer { padding: 12px 16px 16px; gap: 8px; }
  .primary-button { min-height: 44px; min-width: 112px; padding: 0 18px; font-size: 14px; }
  .modal form > footer .text-button { font-size: 13px; }
  .distribution-fields, .similar-fields { padding: 16px; gap: 12px; }
  .distribution-fields { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .similar-field { grid-template-columns: 24px minmax(0,1fr) 40px; gap: 8px; align-items: center; }
  .similar-field > span { width: 24px; height: 40px; }
  .similar-field .synced-score { grid-column: 2; height: auto; padding: 6px 10px; display: flex; align-items: center; gap: 8px; }
  .similar-field .remove-similar { grid-column: 3; grid-row: 1; width: 40px; height: 40px; }
  .similar-field select, .distribution-field input { min-width: 0; font-size: 16px; height: 44px; }
  .dialog-toolbar { padding: 0 16px 8px; gap: 8px; }
  .help-content { padding: 0 16px 16px; font-size: 14px; }
  .toast { font-size: 13px; padding: 10px 14px; bottom: max(12px,env(safe-area-inset-bottom)); }
}
@media (max-width: 350px) {
  .logo { width: 112px; }
  body .teacher-manager .mode-button { font-size: 11px; }
  body .teacher-manager .mode-button svg { display: none; }
  .score-inputs { grid-template-columns: minmax(0,1fr); }
}
.course-manager-button{flex-shrink:0;min-height:40px;padding:0 14px;border:1px solid #111;border-radius:99px;background:#fff;font:inherit;font-size:13px;font-weight:700;cursor:pointer}
.course-edit-note{margin:0;color:#666;font-size:12px;line-height:1.7}
#courseForm input[readonly]{background:#eee;color:#666}
@media(max-width:780px){.filter-row .course-filter{width:auto;flex:1;min-width:0}.course-manager-button{font-size:12px;padding:0 12px}}

/* Author footer: use the same typography and restrained rules as the page. */
.footer-links{display:flex;align-items:center;justify-content:space-between;gap:32px;max-width:600px;margin:24px auto 0;padding:22px 0;border-top:1px solid #ddd}
.site-footer .footer-links .footer-logo{margin:0;font-size:24px;white-space:nowrap}
.footer-author{display:flex;align-items:center;gap:14px;max-width:100%;min-width:0;text-align:left;text-decoration:none;color:#111}
.author-avatar{position:relative;display:block;width:64px;height:64px;flex-shrink:0;overflow:hidden;border-radius:50%;background:#fff}
.author-avatar img{position:absolute;width:391.666667%;max-width:none;height:auto;left:-33.333333%;top:-105.952381%}
.author-info{display:grid;gap:3px;min-width:0}
.author-info strong{font-size:18px;font-weight:800}
.author-account{font-size:12px;font-weight:400;color:#666}
.author-bio{font-size:12px;font-weight:400;color:#777}
.author-arrow{margin-left:8px;font-size:24px;color:#555}
.footer-author:hover .author-info strong{text-decoration:underline;text-underline-offset:4px}
.site-footer .appreciation-card{margin-top:8px}
@media(max-width:780px){.footer-links{flex-direction:column;gap:20px;padding:20px 0;margin-top:16px}.site-footer .footer-links .footer-logo{font-size:20px}.author-avatar{width:52px;height:52px}.footer-author{gap:12px}.author-info strong{font-size:16px}.author-arrow{font-size:21px}}

/* Horizontal editorial footer. */
.site-footer{max-width:1200px;margin:64px auto 0;padding:40px 24px 48px;border-top:1px solid #ddd;text-align:left}
.footer-grid{display:grid;grid-template-columns:1fr 1.25fr 1.1fr 1fr;gap:36px;align-items:start}
.footer-grid>*{min-width:0}
.site-footer .footer-logo{margin:0 0 18px;font-size:26px}
.footer-brand p,.footer-column p{margin:0 0 12px;color:#66717b;font-size:13px;line-height:1.9;font-weight:400}
.footer-brand .footer-storage{margin-top:20px;font-size:12px;color:#888}
.footer-column h2{margin:0 0 20px;color:#111;font-size:16px;font-weight:800}
.footer-grid .footer-author{gap:10px;align-items:flex-start}
.footer-grid .author-avatar{width:42px;height:42px}
.footer-grid .author-info strong{font-size:16px}
.footer-grid .author-account{font-size:11px;overflow-wrap:anywhere}
.footer-grid .author-bio{font-size:12px;line-height:1.7;margin-top:6px}
.footer-grid .author-arrow{margin-left:0;font-size:18px}
.footer-support .appreciation-code{width:150px;max-width:100%;margin:8px 0 0}
@media(max-width:1000px){.footer-grid{grid-template-columns:repeat(2,minmax(0,1fr));gap:32px 28px}}
@media(max-width:780px){.site-footer{margin-top:32px;padding:26px 16px 30px}.footer-grid{gap:28px 20px}.site-footer .footer-logo{font-size:22px;margin-bottom:12px}.footer-column h2{font-size:14px;margin-bottom:14px}.footer-brand p,.footer-column p{font-size:12px}.footer-brand .footer-storage{font-size:11px;margin-top:12px}.footer-grid .author-avatar{width:32px;height:32px}.footer-grid .author-info strong{font-size:14px}.footer-grid .author-arrow{display:none}.footer-grid .footer-author{gap:8px}.footer-grid .author-bio{font-size:11px}.footer-support .appreciation-code{width:136px}}
.site-footer .footer-logo{display:inline-flex;align-items:center;gap:10px;line-height:1;letter-spacing:-.5px}
.footer-logo img{display:block;width:38px;height:38px;flex-shrink:0}
@media(max-width:780px){.site-footer .footer-logo{gap:8px}.footer-logo img{width:30px;height:30px}}
/* Quiet, typographic brand signature. */
.site-footer .footer-logo{font-family:-apple-system,BlinkMacSystemFont,"PingFang SC","Microsoft YaHei",sans-serif;font-weight:500;font-size:28px;letter-spacing:2px;line-height:1.2;color:#1d1d1f}
@media(max-width:780px){.site-footer .footer-logo{font-size:24px;letter-spacing:1.5px}}

/* Collapsed mobile navigation; desktop navigation remains unchanged. */
.mobile-login,.mobile-search-toggle{display:none}
@media (max-width:780px), (max-width:1000px) and (max-height:500px) and (pointer:coarse){
 .topbar .account-nav{gap:12px}
 .topbar .account-nav #registerLink,.topbar .account-nav #helpButton,.desktop-login{display:none}
 .mobile-login{display:inline}
 .topbar .account-nav #loginLink{min-height:44px;padding:0 4px;font-size:16px;font-weight:400}
 .mobile-search-toggle{display:grid;place-items:center;width:44px;height:44px;padding:0;border:0;background:transparent;color:#65a4ff;cursor:pointer}
 .mobile-search-toggle svg{width:24px;height:24px;stroke-width:2}
 .topbar .search{display:none}
 .topbar.search-open .search{display:grid}
}
.mobile-footer-help{display:none;border:0;background:none;color:#111;font:inherit;font-size:13px;font-weight:700;padding:0;min-height:44px;text-decoration:underline;text-underline-offset:4px;cursor:pointer}
@media(max-width:1080px){.mobile-footer-help{display:inline-flex;align-items:center}}

.page-tools{max-width:1184px;margin:18px auto;display:flex;align-items:center;justify-content:space-between;gap:12px;padding:0 24px}
.page-tools .template-note{display:block;margin:0;padding:0;font-size:12px}
.page-tool-actions{display:flex;align-items:center;gap:14px;flex-shrink:0}
.page-tools .mobile-footer-help{font-size:12px;white-space:nowrap}
.export-open{min-height:38px;padding:0 16px;border:1px solid #111;border-radius:99px;background:#fff;color:#111;font:inherit;font-size:13px;font-weight:700;cursor:pointer}
.export-open:disabled{opacity:.4;cursor:default}
.export-dialog{width:min(860px,calc(100% - 24px))}
.export-dialog>.help-header{position:sticky;top:0;background:#fff;z-index:2}
.export-description{font-size:13px;color:#666;line-height:1.8;margin:0}
#exportStatus{margin:0;padding:0 24px 16px;font-size:13px;color:#555}
#exportPreviews{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:20px;padding:0 24px 24px}
.export-preview{margin:0;min-width:0;display:flex;flex-direction:column;align-items:start;gap:10px}
.export-preview img{width:100%;height:auto;border:1px solid #ddd;background:#fff}
.export-preview figcaption{font-size:12px;color:#666}
.export-preview a{font-size:13px;color:var(--blue);padding:8px 0}
@media(max-width:780px){.page-tools{margin:10px 14px 14px;padding:0;flex-wrap:wrap;gap:4px}.page-tools .template-note{font-size:11px}.page-tool-actions{margin-left:auto;gap:12px}.page-tools .mobile-footer-help{min-height:38px}.export-open{font-size:12px}.export-dialog .form-grid{gap:12px}.export-dialog #exportPreviews{grid-template-columns:minmax(0,1fr);padding:0 16px 16px}.export-dialog #exportStatus{padding:0 16px 14px}}
.comments-export{display:flex;justify-content:center;max-width:1200px;margin:28px auto 0;padding:0 16px}
.comments-export .export-open{min-height:44px;padding:0 28px}
.export-selection{min-width:0;margin:0;padding:14px;border:1px solid #ddd}
.export-selection legend{font-size:13px;font-weight:700;padding:0 6px}
.export-selection-heading{display:flex;align-items:center;justify-content:space-between;gap:10px;margin-bottom:10px}
.export-selection-heading label{display:flex;align-items:center;gap:8px}
#exportSelectionCount{font-size:12px;color:#666;white-space:nowrap}
#exportCommentChoices{max-height:260px;overflow:auto;overscroll-behavior:contain;margin-bottom:10px}
.form-grid .export-selection input[type=checkbox]{width:18px;height:18px;min-height:18px;padding:0;flex-shrink:0;accent-color:var(--blue)}
.form-grid .export-selection-row{display:grid;grid-template-columns:18px minmax(0,1fr);align-items:start;gap:10px;padding:12px 2px;border-top:1px solid #eee;cursor:pointer}
.export-selection-row>span{min-width:0;display:grid;gap:5px;overflow-wrap:anywhere}
.export-selection-row strong{font-size:12px;line-height:1.6}
.export-selection-row>span>span{font-size:12px;font-weight:400;line-height:1.6;color:#666}
