/* ═══ 6. دفتري ═══ */
.nb-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.nb-action { display: flex; align-items: center; gap: 12px; padding: 16px; border-radius: 22px; text-align: start; background: color-mix(in srgb, var(--c) 12%, var(--surface)); border: 1px solid color-mix(in srgb, var(--c) 22%, var(--line)); font-size: 15px; transition: transform .15s var(--spring); }
.nb-action .ico-tile { background: var(--c); color: #fff; }
.nb-action:active { transform: scale(.97); }
@media (max-width: 480px) { .nb-action { flex-direction: column; align-items: flex-start; } }
.nb-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 16px; }
.nb-grid > .empty { grid-column: 1 / -1; }
.nb-card { display: grid; gap: 8px; cursor: pointer; }
.papers { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.paper { display: grid; justify-items: center; gap: 6px; cursor: pointer; }
.paper input { position: absolute; opacity: 0; pointer-events: none; }
.paper__img { width: 100%; aspect-ratio: 1 / 1.3; border-radius: 10px; border: 2px solid var(--line-2); background-color: #fff; transition: border-color .15s, transform .15s var(--spring); }
.paper input:checked + .paper__img { border-color: var(--primary); transform: scale(1.04); box-shadow: 0 0 0 3px var(--primary-soft); }
.p-lined { background-image: repeating-linear-gradient(to bottom, transparent 0 7px, #DCE3F0 7px 8px); }
.p-grid { background-image: linear-gradient(#DCE3F0 1px, transparent 1px), linear-gradient(90deg, #DCE3F0 1px, transparent 1px); background-size: 8px 8px; }
.p-dotted { background-image: radial-gradient(#C7CFE2 1px, transparent 1.4px); background-size: 8px 8px; }
.p-cornell { background-image: linear-gradient(90deg, transparent 68%, #C8C0E0 68% 70%, transparent 70%), repeating-linear-gradient(to bottom, transparent 0 7px, #DCE3F0 7px 8px); }
.swatches.big .swatch { width: 44px; height: 44px; }

/* Editor */
.ed { position: fixed; inset: 0; display: flex; flex-direction: column; background: var(--surface-3); z-index: 50; }
:root[data-tone="dark"] .ed { background: #0D0F17; }
.ed__top { display: flex; align-items: center; gap: 2px; padding: calc(var(--safe-t) + 6px) 8px 6px; background: var(--surface); border-bottom: 1px solid var(--line); flex: none; z-index: 3; }
.ed__title { font-weight: 700; font-size: 16px; padding: 6px 8px; border-radius: 10px; max-width: 46vw; }
.ed__title:hover { background: var(--hover); }
.ed__top .icon-btn:disabled { opacity: .3; }
.ed__tools {
  position: absolute; z-index: 4; left: 50%; translate: -50% 0; top: calc(var(--safe-t) + 66px); display: flex; align-items: center; gap: 6px; max-width: calc(100vw - 16px);
  padding: 6px; border-radius: 20px; background: var(--surface); box-shadow: var(--shadow-2); border: 1px solid var(--line); overflow-x: auto; scrollbar-width: none;
}
.ed__tools::-webkit-scrollbar { display: none; }
@media (max-width: 719px) { .ed__tools { top: auto; bottom: calc(var(--safe-b) + 10px); } }
.tgroup { display: flex; align-items: center; gap: 2px; flex: none; }
.tsep { width: 1px; height: 26px; background: var(--line-2); flex: none; }
.tool { width: 40px; height: 40px; border-radius: 13px; display: grid; place-items: center; color: var(--ink-2); flex: none; transition: background .15s, color .15s, transform .15s var(--spring); }
.tool:hover { background: var(--hover); }
.tool.on { background: var(--primary); color: var(--on-primary); }
.tool:active { transform: scale(.9); }
.ink { width: 28px; height: 28px; border-radius: 50%; background: var(--c); border: 3px solid var(--surface); box-shadow: 0 0 0 1px var(--line-2); flex: none; margin: 0 2px; transition: transform .15s var(--spring); }
.ink.on { box-shadow: 0 0 0 2px var(--ink); transform: scale(1.1); }
.size { width: 34px; height: 40px; display: grid; place-items: center; border-radius: 12px; color: var(--ink-2); flex: none; }
.size i { border-radius: 50%; background: currentColor; }
.size.on { background: var(--primary-soft); color: var(--primary); }
.ed__scroll { flex: 1; overflow: auto; -webkit-overflow-scrolling: touch; padding: 76px 8px calc(var(--safe-b) + 100px); }
@media (min-width: 720px) { .ed__scroll { padding: 84px 24px 60px; } }
.ed__pages { display: grid; gap: 18px; margin: 0 auto; transform-origin: 50% 0; }
.ed__pages[data-touch="pan"] { touch-action: pan-x pan-y; }
.ed__pages[data-tool="hand"] { cursor: grab; }
.ed__pages[data-tool="text"] { cursor: text; }
.ed__pages[data-tool="pen"], .ed__pages[data-tool="highlighter"], .ed__pages[data-tool="shape"] { cursor: crosshair; }
.ed__page { position: relative; background: #fff; border-radius: 4px; box-shadow: 0 1px 3px rgba(38, 44, 72, .08), 0 6px 22px rgba(38, 44, 72, .08); }
.ed__page canvas { width: 100%; height: 100%; border-radius: inherit; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.ed__pnum { position: absolute; bottom: -16px; left: 50%; translate: -50% 0; font-size: 11px; color: var(--ink-3); }
.ed__add { display: flex; justify-content: center; padding: 26px 0 10px; }
.ed__sel { position: absolute; z-index: 5; left: 50%; translate: -50% 0; top: calc(var(--safe-t) + 124px); display: flex; gap: 4px; padding: 5px; border-radius: 14px; background: var(--ink); box-shadow: var(--shadow-3); }
@media (max-width: 719px) { .ed__sel { top: calc(var(--safe-t) + 66px); } }
.ed__sel button { display: flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 10px; color: var(--bg); font-size: 13px; font-weight: 700; }
.ed__sel .danger { color: #F6B4C2; }
.ed__textbox { position: absolute; z-index: 3; min-width: 120px; min-height: 1.6em; padding: 2px 4px; border: 1.5px dashed var(--peri); border-radius: 6px; background: rgba(255, 255, 255, .7); outline: none; resize: none; overflow: hidden; line-height: 1.45; font-family: var(--font); white-space: pre; }
.pages-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 12px; }
.pthumb { display: grid; gap: 4px; justify-items: center; font-size: 12px; color: var(--ink-3); }
.pthumb canvas { width: 100%; height: auto; border-radius: 8px; border: 2px solid var(--line); background: #fff; }
.pthumb.on canvas { border-color: var(--primary); }

/* Calculator */
.calc-host { position: fixed; z-index: 60; inset-inline-end: 16px; bottom: calc(var(--tabbar) + var(--safe-b) + 16px); width: 320px; }
.ed .calc-host { bottom: calc(var(--safe-b) + 76px); }
@media (min-width: 720px) { .ed .calc-host { top: calc(var(--safe-t) + 130px); bottom: auto; } .calc-host { bottom: 24px; } }
@media (max-width: 719px) { .calc-host { inset-inline: 8px; width: auto; } }
.calc { display: grid; gap: 8px; padding: 10px; border-radius: 24px; background: var(--surface); box-shadow: var(--shadow-3); border: 1px solid var(--line); animation: pop-in .2s var(--ease); }
.calc__head { display: flex; align-items: center; gap: 6px; cursor: move; touch-action: none; }
.calc__head .seg button { padding: 5px 12px; font-size: 13px; }
.calc__grip { width: 6px; height: 22px; border-radius: 3px; background: var(--line-2); margin-inline-start: 4px; }
.calc__screen { padding: 10px 14px; border-radius: 16px; background: var(--surface-2); text-align: right; min-height: 76px; display: grid; align-content: end; }
.calc__expr { font-size: 24px; font-weight: 700; word-break: break-all; line-height: 1.3; }
.calc__res { font-size: 15px; color: var(--ink-3); min-height: 22px; }
.calc__keys { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; direction: ltr; }
.calc__sci { display: grid; grid-template-columns: repeat(6, 1fr); gap: 5px; direction: ltr; }
.calc__sci .k { height: 38px; font-size: 13px; }
.k { height: 50px; border-radius: 15px; background: var(--surface-2); font-size: 19px; font-weight: 700; transition: transform .1s, background .15s; font-family: var(--font); }
.k:active { transform: scale(.92); }
.k.op { background: var(--primary-soft); color: var(--primary); }
.k.fn { background: var(--surface-3); color: var(--ink-2); font-size: 15px; }
.k.eq { background: var(--primary); color: var(--on-primary); }
@media (max-width: 719px) {
  .calc { gap: 6px; padding: 8px; border-radius: 22px; }
  .calc__screen { min-height: 58px; padding: 6px 12px; }
  .calc__expr { font-size: 21px; }
  .k { height: 44px; border-radius: 13px; font-size: 18px; }
  .calc__sci .k { height: 34px; font-size: 12.5px; }
  .calc .btn { min-height: 40px; }
  .ed .calc-host { max-height: calc(100dvh - var(--safe-t) - 196px); overflow-y: auto; border-radius: 22px; }
}
@media (max-width: 719px) {
  .ed__tools { flex-wrap: wrap; justify-content: center; width: calc(100vw - 16px); row-gap: 4px; }
  .ed__tools .tsep { display: none; }
  .ed__scroll { padding-top: 16px; padding-bottom: calc(var(--safe-b) + 150px); }
  .ed .calc-host { bottom: calc(var(--safe-b) + 124px); }
}

/* ═══ Covers ═══ */
.nb-card { justify-items: center; }
.nb-card__meta { width: 100%; align-items: flex-start; }
.cover-nb, .cover-file { position: relative; display: block; width: 100%; max-width: 168px; aspect-ratio: 3 / 4; transition: transform .2s var(--ease), box-shadow .2s; }
.nb-card:hover .cover-nb, .nb-card:hover .cover-file { transform: translateY(-3px) rotate(-.6deg); }
.cover-nb { border-radius: 14px 8px 8px 14px; background: var(--c); box-shadow: 0 2px 4px rgba(38, 44, 72, .12), 0 12px 28px rgba(38, 44, 72, .16); overflow: hidden; }
[dir="rtl"] .cover-nb { border-radius: 8px 14px 14px 8px; }
.cn__spine { position: absolute; inset-block: 0; inset-inline-end: 0; width: 14%; background: rgba(0, 0, 0, .16); }
.cn__band { position: absolute; inset-block: 0; inset-inline-start: 18%; width: 6px; background: rgba(255, 255, 255, .28); }
.cover-file { border-radius: 10px; background: #FFFFFF; border: 1px solid var(--line-2); box-shadow: 0 2px 4px rgba(38, 44, 72, .08), 0 12px 26px rgba(38, 44, 72, .12); overflow: hidden; }
:root[data-tone="dark"] .cover-file { background: #EEF0F8; }
.cf__corner { position: absolute; top: 0; inset-inline-start: 0; width: 26%; aspect-ratio: 1; background: color-mix(in srgb, var(--c) 30%, #fff); border-end-end-radius: 10px; }
.cf__badge { position: absolute; top: 34%; inset-inline: 14%; padding: 8px 0; border-radius: 10px; background: var(--c); color: #fff; text-align: center; font-weight: 700; font-size: 20px; letter-spacing: 2px; }
.cf__lines { position: absolute; inset-inline: 16%; bottom: 14%; display: grid; gap: 7px; }
.cf__lines i { display: block; height: 5px; border-radius: 3px; background: #E1E4F0; }
.cf__lines i:nth-child(2) { width: 80%; }
.cf__lines i:nth-child(3) { width: 60%; }
.cf__pages { position: absolute; bottom: 8px; inset-inline-end: 10px; font-size: 11px; color: #8D92AE; }
.mini { width: 36px; max-width: 36px; border-radius: 4px 7px 7px 4px; }
.cover-file.mini { border-radius: 5px; }
.cover-file.mini .cf__badge { font-size: 7px; letter-spacing: .5px; padding: 2px 0; border-radius: 3px; inset-inline: 10%; }
.cover-file.mini .cf__lines { gap: 3px; } .cover-file.mini .cf__lines i { height: 2px; }
.cover-nb.mini .cn__band { width: 2px; }
#cv .cover-nb, #cv .cover-file { width: 120px; margin: 0 auto; }

/* ═══ Editor toolbar — docked under the top bar, on every device ═══ */
.ed__tools { position: relative; left: auto; translate: none; top: auto; bottom: auto; flex: none; z-index: 3; margin: 0; max-width: none; width: 100%;
  border-radius: 0; border: 0; border-bottom: 1px solid var(--line); box-shadow: none; padding: 6px 10px; justify-content: center; flex-wrap: wrap; gap: 4px 10px; background: var(--surface); }
@media (max-width: 719px) { .ed__tools { width: 100%; top: auto; bottom: auto; } }
.tgroup { gap: 3px; padding-inline: 4px; }
.tgroup + .tgroup { border-inline-start: 1px solid var(--line); padding-inline-start: 10px; }
.tgroup[hidden] + .tgroup { border: 0; }
.tool { position: relative; }
.tool.on { background: var(--primary-soft); color: var(--primary); }
.tool[data-tool="pen"]::after, .tool[data-tool="highlighter"]::after, .tool[data-tool="shape"]::after, .tool[data-tool="text"]::after {
  content: ""; position: absolute; bottom: 4px; left: 50%; translate: -50% 0; width: 16px; height: 3px; border-radius: 2px; background: var(--tc, var(--ink)); }
.ink { width: 30px; height: 30px; border: 0; box-shadow: inset 0 0 0 1px rgba(38, 44, 72, .14); margin: 0 3px; position: relative; }
.ink.on { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--ink); transform: none; }
.ink.more { background: conic-gradient(#E58C8C 0 25%, #E9A86A 0 50%, #6DBA9C 0 75%, #7FB3D5 0); box-shadow: none; }
.ink.more span { position: absolute; inset: 7px; border-radius: 50%; background: var(--surface); }
.size-btn { display: flex; align-items: center; gap: 6px; height: 40px; padding: 0 10px; border-radius: 13px; background: var(--surface-2); color: var(--ink-2); font-size: 12px; font-weight: 700; }
.size-btn i { border-radius: 50%; background: var(--ink); display: block; }
.size-pop { position: fixed; z-index: 97; width: 250px; display: grid; gap: 12px; padding: 14px; border-radius: 18px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-3); animation: pop-in .16s var(--ease); }
.size-pop__preview { height: 56px; display: grid; place-items: center; border-radius: 12px; background: var(--surface-2); }
.size-pop__line { display: block; width: 70%; border-radius: 99px; }
.size-pop input[type="range"] { flex: 1; accent-color: var(--primary); }
.size-pop .chip { height: 30px; flex: 1; justify-content: center; }
.ed__scroll { padding: 18px 8px calc(var(--safe-b) + 90px); }
@media (min-width: 720px) { .ed__scroll { padding: 26px 24px 60px; } }
.ed__sel { top: calc(var(--safe-t) + 130px); }
.ed .calc-host { top: calc(var(--safe-t) + 128px); bottom: auto; inset-inline: auto 16px; width: 320px; max-height: none; overflow: visible; }
@media (max-width: 719px) { .ed .calc-host { inset-inline: 8px; width: auto; top: auto; bottom: calc(var(--safe-b) + 12px); } }

/* ═══ Calculator 2.1 ═══ */
.calc { width: 100%; gap: 8px; padding: 12px; border-radius: 26px; background: var(--surface); }
.calc-host.dragging .calc { box-shadow: 0 30px 80px rgba(38, 44, 72, .35); }
.calc__head { gap: 8px; }
.calc__grip { width: 34px; height: 5px; border-radius: 3px; margin: 0 4px; }
.calc .deg { height: 30px; padding: 0 10px; border-radius: 9px; background: var(--primary-soft); color: var(--primary); font-size: 12px; font-weight: 700; }
.calc__screen { background: #262C48; color: #EEF0F8; border-radius: 18px; min-height: 84px; padding: 12px 16px; }
:root[data-tone="dark"] .calc__screen { background: #0D0F17; }
.calc__expr { font-size: 28px; letter-spacing: .5px; }
.calc__res { color: #B8D8F0; font-size: 15px; }
.calc__sci { grid-template-columns: repeat(4, 1fr); gap: 6px; padding-bottom: 4px; border-bottom: 1px solid var(--line); }
.calc__sci .k { height: 36px; font-size: 13.5px; border-radius: 11px; background: var(--lav-soft); color: var(--ink-2); font-weight: 700; }
.k { height: 52px; border-radius: 16px; background: var(--surface-2); font-size: 21px; font-weight: 400; }
.k.op { background: var(--sky-soft); color: #3F7FA6; font-weight: 700; }
:root[data-tone="dark"] .k.op { color: var(--sky); }
.k.fn { background: var(--surface-3); color: var(--ink-2); }
.k.eq { background: var(--primary); color: var(--on-primary); font-weight: 700; }
@media (max-width: 719px) { .k { height: 46px; font-size: 19px; } .calc__sci .k { height: 32px; } .calc__screen { min-height: 64px; } .calc__expr { font-size: 23px; } }

/* ═══ 2.1 phone fit: compact calculator you can drag beside your writing · a readable title ═══ */
.ed__top .grow { display: none; }
.ed__title { flex: 1; min-width: 0; max-width: none; text-align: start; }
@media (max-width: 719px) {
  .ed__top { gap: 0; padding-inline: 4px; }
  .ed__top .icon-btn { width: 36px; height: 40px; }
  .calc-host, .ed .calc-host { width: 288px; inset-inline: auto 8px; }
  .calc { padding: 9px; gap: 6px; border-radius: 22px; }
  .calc__screen { min-height: 54px; padding: 8px 12px; border-radius: 14px; }
  .calc__expr { font-size: 21px; }
  .calc__res { font-size: 13px; min-height: 18px; }
  .k { height: 40px; font-size: 17px; border-radius: 12px; }
  .calc__keys { gap: 5px; }
  .calc__sci { gap: 4px; }
  .calc__sci .k { height: 29px; font-size: 12px; border-radius: 9px; }
  .calc .btn { min-height: 36px; font-size: 13px; }
  .calc__head .seg button { padding: 4px 10px; font-size: 12.5px; }
}

/* One size for every cover in the list (notebooks and files line up evenly) */
.nb-grid { --cw: 112px; grid-template-columns: repeat(auto-fill, var(--cw)); justify-content: start; gap: 22px 22px; }
.nb-grid .cover-nb, .nb-grid .cover-file { width: var(--cw); max-width: var(--cw); height: auto; aspect-ratio: 3 / 4; }
.nb-grid .nb-card__meta { width: var(--cw); }
@media (max-width: 719px) { .nb-grid { --cw: 96px; gap: 18px 16px; justify-content: space-evenly; } }
@media (max-width: 360px) { .nb-grid { --cw: 84px; } }

/* Calculator — one grid size for every key, calm colours, clear result */
.calc { width: 100%; }
.calc__sci { grid-template-columns: repeat(4, 1fr); gap: 6px; }
.calc__sci .k { height: 40px; font-size: 14px; }
.calc__keys { gap: 7px; }
.k { display: grid; place-items: center; border: 0; color: var(--ink); font-variant-numeric: tabular-nums; cursor: pointer; }
.k:hover { filter: brightness(.97); }
.k[data-k="clear"] { color: var(--danger); }
.k.eq { box-shadow: 0 6px 16px color-mix(in srgb, var(--primary) 30%, transparent); }
.calc__screen { min-height: 84px; }
.calc__expr { font-size: 28px; letter-spacing: .5px; transition: font-size .15s; }
.calc__res { font-size: 16px; font-weight: 700; color: var(--primary); }
.calc .deg { border: 1px solid var(--line); background: var(--surface-2); border-radius: 10px; padding: 4px 10px; font-size: 12px; font-weight: 700; color: var(--ink-2); cursor: pointer; }
@media (max-width: 719px) { .calc__sci .k { height: 36px; font-size: 13px; } .calc__expr { font-size: 24px; } .calc__screen { min-height: 66px; } }

/* ═══ 1.1 — a lighter toolbar; colour and thickness open from the tool itself ═══ */
.ed__tools { padding: 4px 6px; gap: 2px; border-radius: 16px; }
.tool { width: 34px; height: 34px; border-radius: 11px; position: relative; }
.tool .i { width: 18px; height: 18px; }
.tool.has-opts.on::after { content: ""; position: absolute; bottom: 3px; left: 50%; translate: -50% 0; width: 10px; height: 3px; border-radius: 2px; background: var(--tc, currentColor); opacity: .9; }
.tgroup { gap: 2px; }
.ed__top .icon-btn { width: 36px; height: 36px; }
.tool-pop { position: fixed; z-index: 90; display: grid; gap: 10px; width: min(300px, calc(100vw - 16px)); padding: 12px; border-radius: 18px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-3); animation: pop-in .16s var(--ease); }
.tool-pop__row { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.tool-pop__row.colors .ink { width: 26px; height: 26px; }
.tool-pop .ink.more { position: relative; overflow: hidden; background: conic-gradient(#E58C8C, #E9A86A, #FFE58A, #6DBA9C, #7FB3D5, #8E8EC8, #E58C8C); }
.tool-pop .ink.more input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.tp-shape { width: 34px; height: 34px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface-2); color: var(--ink-2); display: grid; place-items: center; cursor: pointer; }
.tp-shape.on { background: var(--primary); color: var(--on-primary); border-color: transparent; }
.tool-pop__size { display: flex; align-items: center; gap: 10px; direction: ltr; }
.tool-pop__size input { flex: 1; accent-color: var(--primary); }
.tool-pop__prev { width: 38px; height: 30px; flex: none; display: grid; place-items: center; border-radius: 8px; background: var(--surface-2); }
.tool-pop__prev i { display: block; width: 24px; border-radius: 4px; }
/* the calculator always fits the screen (iPad included) */
.calc-host { max-height: calc(100dvh - 24px - var(--safe-b)); overflow-y: auto; overscroll-behavior: contain; border-radius: 24px; }
@media (min-width: 720px) { .ed .calc-host { max-height: calc(100dvh - var(--safe-t) - 150px); } }
/* ═══ 1.2 · writing on iPad: no text selection or copy menu while writing · a text box that wraps inside the page ═══ */
.ed, .ed * { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; }
.ed input, .ed textarea, .ed .ed__textbox { -webkit-user-select: text; user-select: text; -webkit-touch-callout: default; }
.ed__textbox { white-space: pre-wrap; overflow-wrap: anywhere; min-width: 0; box-sizing: border-box; padding: 0; border-width: 1px; background: rgba(255, 255, 255, .55); }
.ed__add .btn { min-height: 44px; padding-inline: 22px; }
.tool-pop__seg { display: flex; }
.tool-pop__seg button { flex: 1; }
.danger-text { color: var(--danger); }
/* the calculator shrinks to whatever room the screen has (set from the script) */
.ed__live { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; border-radius: inherit; }
.tsep { width: 1px; height: 22px; background: var(--line); margin-inline: 4px; }
.tool.addp { color: var(--primary); }

/* ═══ 1.3 · calculator: one calm layout whose keys share the height it is given ═══ */
.calc-host { overflow: hidden; border-radius: 26px; max-height: none; }
.calc-host .calc { height: 100%; display: flex; flex-direction: column; gap: 8px; padding: 10px; border-radius: 26px; background: var(--surface); border: 1px solid var(--line); box-shadow: 0 18px 50px rgba(38, 44, 72, .22); }
.calc-host .calc__head { flex: none; gap: 8px; }
.calc-host .calc__head .seg button { padding: 5px 14px; font-size: 13px; }
.calc-host .calc__screen { flex: none; min-height: 0; padding: 10px 16px 8px; border-radius: 18px; background: #2A2F5E; color: #EEF0F8; box-shadow: inset 0 1px 0 rgba(255, 255, 255, .08); }
.calc-host .calc__expr { font-size: clamp(20px, 3.2vh, 28px); line-height: 1.25; }
.calc-host .calc__res { font-size: 14px; color: #B8D8F0; min-height: 18px; }
.calc-host .calc__sci:not([hidden]) { flex: 5 1 0; }
.calc-host .calc__keys { flex: 5 1 0; }
.calc-host .calc__sci, .calc-host .calc__keys { min-height: 0; display: grid; grid-template-columns: repeat(4, 1fr); grid-template-rows: repeat(5, minmax(0, 1fr)); gap: 6px; direction: ltr; }
.calc-host .calc__sci { gap: 5px; padding-bottom: 8px; border-bottom: 1px dashed var(--line); }
.calc-host .k { height: auto !important; min-height: 0; border-radius: 13px; font-size: clamp(14px, 2.4vh, 20px); background: var(--surface-2); color: var(--ink); border: 1px solid transparent; box-shadow: 0 1px 0 rgba(38, 44, 72, .06); transition: transform .08s, background .15s; }
.calc-host .k:active { transform: scale(.95); }
.calc-host .calc__sci .k { font-size: clamp(11px, 1.8vh, 14px); background: var(--surface); border-color: var(--line); color: var(--ink-2); }
.calc-host .k.op { background: var(--primary-soft); color: var(--primary); font-weight: 700; }
.calc-host .k.fn { color: var(--ink-2); }
.calc-host .k[data-k="clear"] { color: var(--danger); }
.calc-host .k.eq { background: #5B5BA8; color: #fff; font-weight: 700; box-shadow: 0 6px 16px rgba(91, 91, 168, .35); }
.calc-host .k[data-k="deg"] { color: var(--primary); font-weight: 700; }
.calc-host .calc [data-insert] { flex: none; min-height: 40px; }
:root[data-tone="dark"] .calc-host .calc__screen { background: #181C34; }
/* phones: the scientific keys sit in two scrollable rows above the numbers, so every key keeps a comfortable size */
@media (max-width: 719px) {
  .calc-host .calc__sci:not([hidden]) { flex: none; grid-template-rows: repeat(2, 40px); grid-template-columns: repeat(10, calc((100% - 15px) / 4)); grid-auto-flow: row; overflow-x: auto; scrollbar-width: none; padding-bottom: 8px; }
  .calc-host .calc__sci .k { font-size: 13px; }
  .calc-host .calc__keys .k { font-size: 19px; }
  .calc-host .calc [data-insert] { min-height: 38px; }
  .calc-host:not(.moved), .ed .calc-host:not(.moved) { inset-inline: 8px !important; width: auto !important; }
  .calc-host .calc__screen { padding: 8px 14px; }
}

/* ═══ 1.5 · phone calculator: a compact panel in the corner, every scientific key in view (5 × 4) ═══ */
@media (max-width: 719px) {
  .calc-host:not(.moved), .ed .calc-host:not(.moved) { inset-inline: auto 8px !important; width: min(330px, calc(100vw - 16px)) !important; }
  .calc-host.moved { width: min(330px, calc(100vw - 16px)) !important; }
  .calc-host .calc { padding: 8px; gap: 6px; }
  .calc-host .calc__sci:not([hidden]) { flex: 4 1 0; grid-template-columns: repeat(5, minmax(0, 1fr)); grid-template-rows: repeat(4, minmax(0, 1fr)); grid-auto-flow: row; overflow: visible; gap: 4px; padding-bottom: 6px; }
  .calc-host .calc__sci .k { font-size: 12.5px; border-radius: 10px; padding: 0; }
  .calc-host .calc__keys { gap: 5px; }
  .calc-host .calc__keys .k { font-size: 18px; border-radius: 12px; }
  .calc-host .calc__screen { padding: 6px 12px; }
  .calc-host .calc__expr { font-size: 22px; }
  .calc-host .calc [data-insert] { min-height: 36px; font-size: 13px; }
}

/* ═══ 1.5 · a clear «+ صفحة» button ═══ */
.tool.addp { width: auto; padding-inline: 10px 12px; gap: 4px; display: inline-flex; align-items: center; background: var(--primary-soft); color: var(--primary); font-size: 13px; font-weight: 700; }
.tool.addp .i { width: 18px; height: 18px; }
@media (max-width: 719px) { .tool.addp span { display: none; } .tool.addp { width: 34px; padding: 0; justify-content: center; } }

/* ═══ 1.10 · opening a file: its first page as the cover and a live progress line ═══ */
.imp { display: flex; align-items: center; gap: 14px; padding: 12px; border-radius: 18px; background: var(--surface-2); border: 1px solid var(--line); }
.imp .grow { display: grid; gap: 8px; min-width: 0; }
.imp b { font-size: 14px; }
.imp__thumb { width: 64px; height: auto; max-height: 90px; object-fit: cover; border-radius: 8px; box-shadow: 0 6px 16px rgba(38, 44, 72, .18); background: #fff; }
.imp__bar { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.imp__bar i { display: block; height: 100%; border-radius: 3px; background: var(--primary); transition: width .3s var(--ease); }

/* 1.11 — the calculator's screen never moves: fixed lines, a long sum slides instead of wrapping */
.calc__screen { min-height: 0 !important; }
.calc__expr, .calc-host .calc__expr { display: block; height: 1.4em; line-height: 1.4em; white-space: nowrap; overflow: hidden; word-break: normal; text-align: right; direction: ltr; transition: none; font-variant-numeric: tabular-nums; }
.calc__expr { box-sizing: content-box; }
.calc__res, .calc-host .calc__res { display: block; height: 1.4em; line-height: 1.4em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; min-height: 0; }

/* 1.11 — our own small colour chooser */
.cpick { display: grid; gap: 6px; padding: 4px 0 8px; }
.cpick__row { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 6px; }
.cpick__c { aspect-ratio: 1; max-width: 30px; width: 100%; justify-self: center; border-radius: 50%; background: var(--c); border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--line); cursor: pointer; transition: transform .12s var(--spring); }
.cpick__c:hover { transform: scale(1.12); }
.cpick__c.on { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--primary); }
.tool-pop .ink.more { border: 0; cursor: pointer; }

/* 1.14 — under each cover: the name and its course on one line each, small and level */
.nb-card__meta { display: flex; align-items: center; gap: 2px; }
.nb-card__txt { flex: 1; min-width: 0; display: grid; gap: 0; }
/* 1.15 — the name once, small, on up to two lines (most of a long course name shows) */
.nb-card__txt b { font-size: 11.5px; font-weight: 700; line-height: 1.45; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow-wrap: anywhere; }
.nb-card__meta .icon-btn.sm { width: 26px; height: 26px; flex: none; }
/* 1.14 — the magic pen's line fades away a moment after lifting */
.ed__live { transition: opacity .55s ease; }
.ed__live.fade { opacity: 0; }
/* 1.15 — the selection's buttons (تعديل · نسخ · حذف) sit at the bottom of the screen, never over what was selected */
.ed__sel, .ed__sel[style] { position: fixed; top: auto !important; bottom: calc(var(--safe-b) + 16px); left: 50%; translate: -50% 0; }
.tool.finger { background: var(--surface-2); color: var(--ink-2); }

