/* Phone & tablet optimisation */

/* Phone day view of the weekly plan (built by renderWeeklyPlanDay) */
.day-tabs { display: none; }
.mplan { display: flex; flex-direction: column; gap: 10px; }
.mhead { background: linear-gradient(120deg, var(--sea-900), var(--sea-700)); color: #fff; border-radius: 18px; padding: 14px 16px; }
.mhead .mtheme .cv { font-family: var(--thaana-head); font-size: 24px; line-height: 1.5; min-height: 1.4em; }
.mhead .mmeta { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; font-size: 12.5px; color: #bfe0e4; margin-top: 4px; }
.mday-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.mday-actions .btn { height: 46px; font-size: 14px; }
.mrow { background: var(--paper); border: 1px solid var(--line); border-radius: 16px; padding: 12px 14px; }
.mrow .mlabel { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; font-family: var(--thaana); font-weight: 700; color: var(--sea-800); font-size: 15px; }
.mrow .mtime { font-family: var(--font); font-weight: 600; font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.mrow .men { font-size: 11px; color: var(--muted); margin-bottom: 6px; }
.mrow .cprompt { font-size: 12px; color: var(--muted); margin: 4px 0 2px; }
.mrow .cv { min-height: 2.4em; font-size: 16px; line-height: 1.8; white-space: pre-wrap; padding: 6px 8px; margin: 0 -8px; border-radius: 10px; background: #fcfaf6; }
.mrow .cv:focus { background: #eefaf8; box-shadow: 0 0 0 2px var(--lagoon-soft); }
.mrow[data-row="learning_intention"] { border-color: #a7e3da; background: #f4fcfa; }
.mrow[data-row="success_criteria"] { border-color: #f3dca3; background: #fffbf0; }
details.mrow > summary { list-style: none; cursor: pointer; }
details.mrow > summary::-webkit-details-marker { display: none; }
details.mrow > summary::after { content: "\25BE"; margin-inline-start: 6px; color: var(--muted); }
details.mrow[open] > summary { margin-bottom: 8px; }
details.mrow .mrow { border: 0; padding: 8px 0 0; background: transparent; }
.msubj { border-top: 1px dashed var(--line); padding: 10px 0; }
.msname { font-family: var(--thaana-head); font-size: 17px; color: var(--sea-800); }

@media (max-width: 860px) {
  .topbar-logout { display: inline-flex; align-items: center; gap: 6px; margin-left: auto; padding: 7px 12px; border-radius: 10px; border: 1px solid rgba(255,255,255,.22); color: #fff; font-size: 13px; font-weight: 600; text-decoration: none !important; }
  .topbar-logout svg { width: 16px; height: 16px; }
  /* leave room below the menu so "Sign out" is never hidden behind the phone's home bar */
  .side { padding-bottom: 96px; height: 100vh; height: 100dvh; }
}

@media (max-width: 760px) {
  /* Inputs at 16px stop iOS from zooming in when tapped */
  input, select, textarea { font-size: 16px; }
  .main { padding: 14px 12px 80px; }
  h1 { font-size: 26px; }
  .page-head { margin-bottom: 14px; }
  .page-head p { font-size: 14px; }
  .dv-sub { display: block; margin: 4px 0 0; font-size: 18px; }
  .card { padding: 16px; border-radius: 16px; }
  .hero { padding: 20px 18px; border-radius: 20px; }
  .hero h1 { font-size: 26px; }
  .hero .row .btn { flex: 1 1 auto; }
  .hero-waves { width: 260px; opacity: .5; }

  /* Stepper becomes a compact horizontal strip */
  .stepper { flex-wrap: nowrap; overflow-x: auto; margin: 0 -12px 14px; padding: 2px 12px 6px; scrollbar-width: none; }
  .stepper::-webkit-scrollbar { display: none; }
  .stepper .step { flex: none; padding: 6px 10px 6px 6px; }
  .stepper .arrow { display: none; }

  /* Toolbars: let segmented controls scroll sideways instead of wrapping into many rows */
  .toolbar { gap: 8px; }
  .toolbar > .seg, .page-head + .seg, #view > .seg { max-width: 100%; overflow-x: auto; flex-wrap: nowrap; scrollbar-width: none; }
  .seg button, .seg a { white-space: nowrap; padding: 8px 12px; }

  /* Sticky action bar: icons only, scrolls sideways if needed */
  .doc-bar { flex-wrap: nowrap; overflow-x: auto; gap: 6px; margin: -14px -12px 10px; padding: 10px 12px; scrollbar-width: none; background: var(--sand); box-shadow: 0 6px 12px -10px rgba(7,37,48,.25); }
  .doc-bar::-webkit-scrollbar { display: none; }
  .doc-bar .btn { flex: none; padding: 0 12px; }
  .doc-bar .btn .bl { display: none; }
  .doc-bar .chip { flex: none; }
  .doc-bar .grow { display: none; }
  .doc-bar .seg { flex: none; }
  .doc-bar { top: 56px; }
  .edit-hint { display: none; }

  /* Weekly plan: day tabs + cards instead of the wide table */
  .day-tabs { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; position: sticky; top: 116px; z-index: 15; background: var(--sand); padding: 4px 0 8px; }
  .day-tabs button { position: relative; display: flex; flex-direction: column; align-items: center; gap: 0; padding: 8px 2px; border-radius: 12px; border: 1px solid var(--line); background: var(--paper); cursor: pointer; font: inherit; color: var(--ink); }
  .day-tabs button b { font-family: var(--thaana-head); font-weight: 400; font-size: 15px; line-height: 1.4; }
  .day-tabs button span { font-size: 10.5px; color: var(--muted); }
  .day-tabs button.on { background: var(--sea-900); border-color: var(--sea-900); color: #fff; }
  .day-tabs button.on span { color: #9cc3c9; }
  .day-tabs button i { position: absolute; top: 5px; left: 6px; width: 7px; height: 7px; border-radius: 50%; background: var(--coral); }
  .plan-scroll { overflow: visible; padding: 0; }
  .gen-progress { position: sticky; top: 176px; z-index: 16; }

  /* Year plan */
  .yp-week > summary { padding: 10px 12px; gap: 8px; }
  .yp-week > summary .muted { width: 100%; order: 5; }
  .yp-body { padding: 12px; }
  .yp-grid { grid-template-columns: 1fr; }
  .yp-entry .row.between { flex-wrap: nowrap; }
  .yp-entry .btn.ghost { font-size: 12px; padding: 0 8px; }

  /* Week tiles: two per row */
  .week-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .week-tile { min-height: 116px; padding: 12px; border-radius: 14px; }
  .week-tile .theme { font-size: 16px; }
  .week-tile .chip { font-size: 10px; padding: 2px 6px; }

  /* Curriculum outcome table → stacked cards */
  .oc-table thead { display: none; }
  .oc-table, .oc-table tbody, .oc-table tr, .oc-table td { display: block; width: 100%; }
  .oc-table tr { position: relative; border-bottom: 1px solid var(--line); padding: 8px 4px 10px; }
  .oc-table td { border: 0; padding: 2px 4px; }
  .oc-table td[data-l]::before { content: attr(data-l); display: block; font: 600 11px var(--font); color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin-top: 4px; direction: ltr; text-align: left; }
  .oc-table td:last-child { position: absolute; top: 4px; right: 0; left: auto; width: auto; }
  .oc-table td[data-l="No."] input { max-width: 120px; }
  .oc-table input, .oc-table textarea { border-color: var(--line); background: #fff; }
  .subj-h { flex-wrap: wrap; }
  .subj-h .nm, .subj-h .nm-en { max-width: none; flex: 1 1 140px; }

  /* Worksheet list + paper */
  .ws-days { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ws-week .card-head { flex-direction: column; align-items: stretch; }
  .ws-name { grid-template-columns: 1fr 1fr; }
  .ws-name div:first-child { grid-column: 1 / -1; }
  .ws-trace .tr { font-size: 52px; min-width: 56px; }
  .ws-trace .tr.word { font-size: 36px; }
  .ws-trace .tr[dir="rtl"] { font-size: 56px; }
  .ws-circle .opt { font-size: 26px; padding: 6px 12px; min-width: 64px; }
  .ws-count .pics { font-size: 24px; }
  .ws-match .l .e { font-size: 32px; }
  .ws-match .l, .ws-match .r { font-size: 19px; }
  .ws-draw .box-draw { height: 200px; }
  .add-section { position: static; }

  /* Tables inside cards scroll instead of squashing */
  .table-wrap { -webkit-overflow-scrolling: touch; }
  table.t th, table.t td { padding: 9px 10px; }

  /* Settings */
  .form-grid { grid-template-columns: 1fr; }
  .import-summary b { font-size: 20px; }

  /* Dashboard */
  .flow-card { padding: 14px; }
  .flow-n { font-size: 26px; }
  .list-item { gap: 10px; }
  .list-item .nowrap { display: none; }

  /* Modals fill the screen width, buttons easier to tap */
  .modal-back { padding: 8px; align-items: end; }
  .modal { border-radius: 20px 20px 14px 14px; max-height: calc(100vh - 16px); }
  .modal-f .btn { flex: 1; height: 46px; }

  #toasts { left: 12px; right: 12px; bottom: 12px; }
  .toast { max-width: none; }
}

@media (max-width: 380px) {
  .day-tabs button b { font-size: 13px; }
  .week-grid { grid-template-columns: 1fr 1fr; }
  .mday-actions { grid-template-columns: 1fr; }
}
