.quarters { --nav-size: min(124px, calc(var(--stage-width) * .26), calc(var(--app-height) * .16)); background: #62462f; }
/* The cabin fills the fixed app stage independently of the ledger. */
.quarters::before { content: ""; position: absolute; z-index: -2; inset: 0; background: #62462f url("assets/profile/profile-cabin-faceted.webp?v=2714b7cdecff") center / cover no-repeat; pointer-events: none; }
.quarters .rail { position: absolute; padding-inline: 16px; }
.log-main { height: 100%; display: flex; flex-direction: column; align-items: stretch; justify-content: center; padding: 8px 14px calc(var(--nav-size) + 14px); }
.log-header { position: relative; flex: 1 1 0; min-height: 84px; max-height: 176px; width: auto; max-width: 92%; align-self: center; margin-inline: auto; aspect-ratio: 1585 / 992; z-index: 2; }
.log-crest { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 5px 3px #24180c77); pointer-events: none; }
.log-portrait { position: absolute; left: 42.8%; top: 6.8%; width: 14.4%; height: 22%; overflow: hidden; clip-path: polygon(24% 0, 76% 0, 100% 24%, 100% 76%, 76% 100%, 24% 100%, 0 76%, 0 24%); }
.log-portrait { background: #758d80; }
.log-portrait img { width: 100%; height: 100%; object-fit: cover; transform: scale(2.2); transform-origin: 60% 17%; }
/* 793x1983 source: keep the corner geometry and absorb only the plain center.
   Top/bottom transparent margins (170/208 source px) sit outside the panel. */
.log-ledger {
  --art-corner: clamp(42px, calc(var(--stage-width) * .12), 58px);
  --art-source: url("assets/profile/profile-ledger.webp?v=b9553dad6b29");
  --art-slices: 350 180 350 180;
  --art-border-width: calc(var(--art-corner) * 350 / 180) var(--art-corner);
  --art-inset: calc(var(--art-corner) * -170 / 180) 0 calc(var(--art-corner) * -208 / 180);
  flex: none; margin-top: -8px; padding: 16px 22px 20px;
}
.log-ledger::before { filter: drop-shadow(0 7px 4px #2d1c1388); }
.log-section { position: relative; margin-bottom: 8px; }
/* Ribbons and the Back button are nine-slice plaques: the icon plate and the end cap keep
   their shape while the middle band stretches to the label, so a long translation makes the
   plaque longer instead of the text smaller (data-fit only steps in once the band has hit
   the ledger's width). --rh is the height of the blue band; the art is taller (the icon
   plate and the drop shadow reach above and below the band: settings band rows 173-554 of
   727, privacy 165-545 of 724), so the element takes the art's full height and negative
   margins pull the band back to where the old fixed background sat. */
.log-ribbon { --rh: min(42px, calc(var(--stage-width) * .095)); position: relative; z-index: 1; display: flex; align-items: center; box-sizing: border-box; width: max-content; min-width: 34%; max-width: calc(100% + 7px); border-style: solid; border-color: transparent; border-image-repeat: stretch; background: none; }
.section-body { padding: 8px 7px 0; }
/* The ribbons, rows and buttons are text-free plaques; their labels are live text in the
   page language, set in Lilita One with a pressed shadow to sit on the modeled faces. */
/* Settings art: band face rows 236-518, plate to row 575; the next row starts 4px under the plate. */
.log-ribbon.settings { height: calc(var(--rh) * 727 / 381); margin: calc(var(--rh) * -173 / 381) 0 calc(var(--rh) * -152 / 381 + 2px) -7px; border-width: 0 calc(var(--rh) * 190 / 381) 0 calc(var(--rh) * 600 / 381); border-image: url("assets/profile/ribbon-settings-blank.webp?v=b4d84d1bd121") 0 190 0 600 fill / 0 calc(var(--rh) * 190 / 381) 0 calc(var(--rh) * 600 / 381) stretch; }
/* Privacy art: band face rows 226-519, plate to row 576. */
.log-ribbon.privacy { height: calc(var(--rh) * 724 / 380); margin: calc(var(--rh) * -165 / 380) 0 calc(var(--rh) * -148 / 380 + 2px) -7px; border-width: 0 calc(var(--rh) * 200 / 380) 0 calc(var(--rh) * 600 / 380); border-image: url("assets/profile/ribbon-privacy-blank.webp?v=eddcc65f8fb4") 0 200 0 600 fill / 0 calc(var(--rh) * 200 / 380) 0 calc(var(--rh) * 600 / 380) stretch; }
.ribbon-text { display: block; margin: 0; padding: 0 4px 0 calc(var(--rh) * 40 / 381); transform: translateY(calc(var(--rh) * 13.5 / 381)); color: #f7e7c6; font-size: clamp(13px, calc(var(--rh) * .5), 21px); line-height: 1; letter-spacing: .02em; text-transform: uppercase; white-space: nowrap; overflow: hidden; text-shadow: 0 2px 0 #6b3f17, 0 3px 2px #2a180a66; }
:root:lang(ja) .ribbon-text, :root:lang(ko) .ribbon-text, :root:lang(zh-Hans) .ribbon-text, :root:lang(zh-Hant) .ribbon-text { letter-spacing: 0; font-size: clamp(12px, calc(var(--rh) * .46), 19px); }
.log-ribbon.privacy .ribbon-text { transform: translateY(calc(var(--rh) * 10.5 / 380)); }
.quarters .usage-head { position: relative; justify-content: space-between; gap: 0; padding: 0 6%; min-height: 44px; background: url("assets/profile/row-blank.webp?v=362a1c1b54f1") center / 100% auto no-repeat; }
.quarters .usage-head > h3 { position: relative; margin: 0 0 0 2.5%; color: #4b2b14; font-size: clamp(14px, calc(var(--stage-width) * .048), 20px); line-height: 1; text-shadow: 0 1px #ffe0a4; white-space: nowrap; overflow: hidden; }
.quarters .usage-head + .usage-head { margin-top: 6px; }
#language-select { position: relative; z-index: 1; max-width: 58%; min-height: 32px; margin: 6px 2.5% 6px 8px; padding: 2px 8px; color: var(--cream); background: #285a88; border: 3px outset #a98452; border-radius: 5px; box-shadow: 0 2px 0 #573921; font: inherit; font-size: clamp(13px, calc(var(--stage-width) * .04), 16px); cursor: pointer; }
#language-select:focus-visible { outline: 3px solid #fff0b6; outline-offset: 1px; }
#language-select option { color: var(--ink); background: #efdab1; }
.quarters .switch { width: 62px; height: 44px; }
.quarters .switch .track { top: 6px; width: 62px; height: 32px; border-radius: 20px; border: 1px solid #7c694c; background: linear-gradient(#95876e, #72654e); box-shadow: inset 0 2px 3px #342a1a77, 0 1px 0 #fff1ce; }
.quarters .switch .track::before { top: 2px; left: 2px; width: 26px; height: 26px; border: 0; border-radius: 50%; background: linear-gradient(135deg, #fff2d9, #e4bf84); box-shadow: 1px 3px 2px #39281988, inset 1px 1px 0 #fff9e6, inset -1px -2px 0 #b68a52; }
.quarters .switch input:checked + .track { background: linear-gradient(120deg, #3167a6, #204978); border-color: #183e64; }
.quarters .switch input:checked + .track::before { transform: translateX(30px); }
.log-note { margin: 7px 5% 2px; color: #765b3d; font-size: clamp(14px, calc(var(--stage-width) * .036), 16px); line-height: 1.4; }
.privacy-section { border: 0; margin-bottom: 0; padding-bottom: 0; }
.privacy-link { position: relative; display: block; min-height: 44px; cursor: pointer; list-style: none; text-decoration: none; background-position: center; background-size: 100% auto; background-repeat: no-repeat; }
.privacy-link { background-image: url("assets/profile/link-button-blank.webp?v=cc400f26370c"); transition: transform .15s ease; }
.privacy-link.terms-link { margin-top: 6px; }
.link-text { position: absolute; left: 21.5%; right: 16%; top: 0; bottom: 0; display: flex; align-items: center; color: #4b2b14; font-size: clamp(14px, calc(var(--stage-width) * .05), 21px); line-height: 1; text-shadow: 0 1px #ffe0a4; white-space: nowrap; overflow: hidden; }
.privacy-link:active { transform: translateY(2px); }
.quarters a:focus-visible { outline: 3px solid #285a88; outline-offset: 2px; }
/* The blue plaques take the cream ring: the ledger's blue ring would vanish on them. */
.back-to-games:focus-visible, #language-select:focus-visible { outline-color: #fff0b6; }
/* Pointer devices get a lift on the modeled controls; touch keeps idle motion and press feedback. */
@media (hover: hover) {
  .privacy-link:hover, .back-to-games:hover { transform: translateY(-1px); filter: brightness(1.05); }
  .setting-help:hover span, .log-page:not(:disabled):hover, .log-dialog-close:hover, #language-select:hover { filter: brightness(1.12); }
  .privacy-link, .back-to-games, .setting-help span, .log-page, .log-dialog-close, #language-select { transition: transform .15s ease, filter .15s ease; }
}
.back-to-games { --bh: calc(var(--stage-width) * .54 * 727 / 2164 * var(--zoom, 1)); position: relative; z-index: 2; display: flex; align-items: center; justify-content: center; box-sizing: border-box; flex: none; width: max-content; min-width: calc(54% * var(--zoom, 1)); max-width: calc(94% * var(--zoom, 1)); height: var(--bh); margin: calc(-22px * var(--zoom, 1)) auto 0; border-style: solid; border-color: transparent; border-width: 0 calc(var(--bh) * 300 / 727) 0 calc(var(--bh) * 480 / 727); border-image: url("assets/profile/back-button-blank.webp?v=4971d81bc61e") 0 300 0 480 fill / 0 calc(var(--bh) * 300 / 727) 0 calc(var(--bh) * 480 / 727) stretch; text-decoration: none; transition: transform .15s ease; }
.back-text { display: block; margin: 0; padding: 0 6px 3px 2px; color: #f7e7c6; font-size: calc(clamp(14px, calc(var(--bh) / var(--zoom, 1) * .34), 25px) * var(--zoom, 1)); line-height: 1; letter-spacing: .02em; text-transform: uppercase; white-space: nowrap; overflow: hidden; text-shadow: 0 2px 0 #6b3f17, 0 3px 2px #2a180a66; }
:root:lang(ja) .back-text, :root:lang(ko) .back-text, :root:lang(zh-Hans) .back-text, :root:lang(zh-Hant) .back-text { letter-spacing: 0; }
/* CJK glyphs come from the platform font behind Lilita One; a heavy weight keeps them as
   chunky as the Latin lettering on the same plaques. */
:root:is(:lang(ja), :lang(ko), :lang(zh-Hans), :lang(zh-Hant)) :is(.ribbon-text, .back-text, .link-text, .usage-head > h3) { font-weight: 800; font-synthesis: weight; }
.back-to-games:active { transform: translateY(3px); }
/* A short portrait viewport (a desktop window, an older phone) would squeeze the
   Harbor Log crest to its minimum. Instead the ledger and Back button scale down
   continuously with the height: full size from 840px up, .78 at 640px and below
   (tan(atan2()) turns the length ratio into the plain number zoom wants).
   The Back button takes the same factor as a variable folded into its own sizes
   rather than `zoom`: WebKit resolves the viewport units behind --stage-width
   differently inside a zoomed subtree and paints the border-image out of step with
   the border box, so on iPhone the label sat on the arrow (fine in Chrome). */
.log-ledger { zoom: clamp(.78, tan(atan2(calc(var(--app-height) - 240px), 600px)), 1); }
.back-to-games { --zoom: clamp(.78, tan(atan2(calc(var(--app-height) - 240px), 600px)), 1); }
@media (max-width: 359px) {
  .log-main { padding-inline: 9px; }
  .log-ledger { padding-inline: 16px; padding-top: 22px; }
  .section-body { padding-inline: 4px; }
  .log-ribbon { min-width: 36%; }
  .quarters .switch { transform: scale(.9); transform-origin: right center; }
}

/* Whole row labels open detail without changing the switch or the viewport layout. */
.setting-help { position: absolute; inset: 0 auto 0 0; width: calc(94% - 62px); border: 0; padding: 0 2px; display: flex; align-items: center; justify-content: flex-end; color: var(--cream); background: transparent; cursor: pointer; }
.setting-help span { display: grid; place-items: center; width: 23px; height: 23px; border: 2px solid #d4ad70; border-radius: 50%; background: #285a88; box-shadow: 0 2px 0 #654323; font: 18px Georgia, serif; }
.setting-help:active span { transform: translateY(2px); box-shadow: none; }
.setting-help:focus-visible { outline: 3px solid #285a88; outline-offset: 1px; }
/* Top-layer dialogs still inherit the app stage budget, including landscape. */
.log-dialog { inset: var(--safe-top) var(--safe-right) var(--safe-bottom) var(--safe-left); margin: auto; height: min(460px, calc(var(--app-height) - 32px)); width: min(448px, calc(var(--stage-width) - 32px)); max-width: none; max-height: calc(var(--app-height) - 32px); padding: 22px; overflow: hidden; color: var(--ink); background: #efdab1; border: 8px ridge #ad8354; border-radius: 8px; box-shadow: 0 10px 0 #573921, 0 18px 40px #07151e99; }
.log-dialog::backdrop { background: #10242bbd; }
.log-dialog[open] { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; gap: 12px; }
.log-dialog-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.log-dialog h2 { font-size: clamp(16px, calc(var(--stage-width) * .055), 22px); line-height: 1.1; }
.log-page-status { flex: none; min-width: 3.5em; text-align: right; white-space: nowrap; font-size: 14px; }
.log-detail-text { min-height: 0; height: 100%; overflow: hidden; margin: 0; font-size: 15px; line-height: 1.45; }
.log-dialog-actions { display: flex; align-items: center; justify-content: center; gap: 8px; }
.log-page { flex: none; width: 44px; height: 44px; color: var(--cream); background: #285a88; border: 3px outset #a98452; border-radius: 5px; cursor: pointer; }
.log-page:disabled { opacity: .45; cursor: default; }
.log-dialog-close { display: block; min-width: 0; min-height: 44px; margin: 0; padding: 8px 12px; white-space: normal; font-size: clamp(13px, calc(var(--stage-width) * .04), 16px); color: var(--cream); background: #285a88; border: 3px outset #a98452; border-radius: 5px; box-shadow: 0 3px 0 #573921; cursor: pointer; }
.log-dialog-close:active { transform: translateY(2px); box-shadow: none; }
/* A wide, shallow viewport gets a two-column settings composition. */
@media (max-height: 520px) and (min-aspect-ratio: 1/1) {
  .quarters { --scene-width: min(100vw, 720px); }
  .log-main { display: grid; grid-template-columns: minmax(0, .65fr) minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; gap: 8px 16px; padding: 12px 20px calc(var(--nav-size) + 20px); }
  .log-header { grid-column: 1; grid-row: 1; flex: none; width: 100%; max-width: 100%; min-height: 0; max-height: none; align-self: center; }
  .log-ledger { grid-column: 2; grid-row: 1 / 3; margin: 0; padding: 12px 16px; align-self: center; }
  .back-to-games { grid-column: 1; grid-row: 2; --bh: calc(var(--stage-width) * .9 * 727 / 2164 * var(--zoom, 1)); min-width: calc(90% * var(--zoom, 1)); max-width: calc(100% * var(--zoom, 1)); margin: 0 auto; }
  .log-ribbon { --rh: 30px; min-width: min(34%, 100px); }
  .log-ribbon.settings { margin-bottom: calc(var(--rh) * -152 / 381 + 2px); }
  .log-ribbon.privacy { margin-bottom: calc(var(--rh) * -148 / 380 + 2px); }
  .log-section { margin-bottom: 4px; }
  .section-body { padding: 4px 0 0; }
  .quarters .usage-head + .usage-head, .privacy-link.terms-link { margin-top: 0; }
  .log-dialog { padding: 14px 20px; }
  .log-dialog h2 { font-size: 21px; }

}

@media (max-height: 540px) and (max-aspect-ratio: 1/1) {
  .log-header { min-height: 44px; }
  .log-ledger { padding-top: 16px; padding-bottom: 20px; }
  .log-ribbon { --rh: 26px; min-width: min(34%, 90px); }
  .log-section { margin-bottom: 8px; }
  .section-body { padding-top: 8px; padding-bottom: 0; }
  .quarters .usage-head + .usage-head { margin-top: 4px; }
  .privacy-link.terms-link { margin-top: 2px; }
}
@media (max-height: 440px) and (max-aspect-ratio: 1/1) {
  .log-header { flex: none; height: 0; min-height: 0; }
  .log-crest, .log-portrait, .back-to-games { display: none; }
}
@media (max-height: 360px) and (min-aspect-ratio: 1/1) {
  .log-ledger { padding-block: 8px; }
  .log-ribbon { --rh: 24px; min-width: min(34%, 84px); }
  .log-ribbon.settings { margin-bottom: calc(var(--rh) * -152 / 381); }
  .log-ribbon.privacy { margin-bottom: calc(var(--rh) * -148 / 380); }
  .log-section { margin-bottom: 0; }
  .section-body { padding-block: 0; }
}

.compact-profile-tabs { display: none; }
/* When even compact rows exceed the height budget, use two app pages. */
@media (max-height: 300px) {
  .quarters .rail, .log-crest, .log-portrait, .back-to-games { display: none; }
  .log-header { flex: none; width: 0; height: 0; min-height: 0; }
  .log-main { display: flex; justify-content: center; padding: 4px 12px; }
  .log-ledger { width: min(100%, 420px); margin: 0 auto; padding: 6px 14px; }
  .log-ledger .log-section { margin: 0; }
  .log-ledger .log-ribbon, .log-ledger .log-ribbon.settings, .log-ledger .log-ribbon.privacy { --rh: 0px; height: 0; margin: 0; border: 0; overflow: hidden; }
  .log-ledger .section-body { padding: 0; }
  .quarters .usage-head + .usage-head, .privacy-link.terms-link { margin-top: 0; }
  .compact-profile-tabs { display: flex; justify-content: space-between; gap: 4px; margin-bottom: 4px; }
  .compact-profile-tabs button, .compact-profile-tabs a { display: grid; place-items: center; min-height: 44px; padding: 4px 10px; color: var(--cream); background: #285a88; border: 2px outset #a98452; border-radius: 4px; font: inherit; text-decoration: none; cursor: pointer; }
  .compact-profile-tabs button[aria-pressed="true"] { color: var(--ink); background: #efdab1; }
  .log-ledger[data-section="settings"] .privacy-section, .log-ledger[data-section="privacy"] .log-section:not(.privacy-section) { display: none; }
  .log-dialog { padding: 8px 12px; border-width: 4px; }
  .log-dialog[open] { gap: 6px; }
  .log-dialog h2 { font-size: 18px; }
  .log-dialog-close { font-size: 14px; }
}
