.officer-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr));
    gap: 16px;
    margin-top: 24px;
}

.officer-category-tabs { display: flex; flex-wrap: wrap; gap: 8px; }
.officer-category-tabs button {
    padding: 9px 12px;
    border: 1px solid #8a6a32;
    border-radius: 7px;
    background: #272016;
    color: #d8c997;
    font: 700 15px/1.3 Georgia, serif;
    cursor: pointer;
}
.officer-category-tabs button[aria-selected="true"] { background: #544329; color: #ffe9a1; border-color: #d5ad59; }
.officer-category-tabs button:disabled { opacity: .4; cursor: default; }
.officer-category-tabs button:focus-visible { outline: 2px solid #e8c36b; outline-offset: 2px; }
.officer-category-panel[hidden] { display: none; }

.officer-card {
    min-width: 0;
    padding: 20px;
    border: 1px solid #8a6a32;
    border-radius: 12px;
    background: rgba(70, 57, 40, .48);
}

.guide-officers [data-officer-group] > .guide-block-title {
    margin: 0 0 12px;
    color: #e8c36b;
    font: 700 var(--guide-heading-large)/1.3 Arial, Helvetica, sans-serif;
}

.officer-card-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 12px;
    margin-bottom: 16px;
}

.guide-officers .officer-card h3 {
    margin: 0;
    color: #e8c36b;
    font-size: var(--guide-heading-small, 22px);
    line-height: 1.25;
}

.officer-portrait,
.officer-portrait-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 128px;
    height: 128px;
    flex: 0 0 128px;
    padding: 0;
    overflow: hidden;
    border: 1px solid #a38245;
    border-radius: 8px;
    background: #211c16;
}

.officer-portrait { cursor: zoom-in; }
button.officer-portrait { position: relative; }
button.officer-portrait::after {
    content: '🔍 Подробнее';
    position: absolute;
    inset: auto 0 0;
    padding: 5px 4px;
    background: #17120ee6;
    color: #fff0b6;
    font: 700 12px/1.2 Georgia, serif;
    text-align: left;
    pointer-events: none;
    user-select: none;
    -webkit-user-select: none;
}
.guide-officers:lang(en) button.officer-portrait::after { content: "🔍 Details"; }
.officer-portrait img { display: block; width: 128px; height: 128px; margin: 0; }
.officer-portrait:focus-visible { outline: 2px solid #f3ce70; outline-offset: 4px; }
.officer-portrait-static { cursor: default; }
.officer-portrait-wrap { position: relative; }
.officer-character {
    position: absolute !important;
    right: -10px;
    bottom: -6px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    padding: 0;
    border: 0 !important;
    border-radius: 50%;
    background: #272016;
    color: #e8c36b;
    font: 700 24px Georgia, serif;
}
.officer-character img { display: block; width: 36px; height: 36px; margin: 0; }
.officer-character:focus-visible { outline: 2px solid #e8c36b; }
.officer-character:focus-visible .tooltip-text { display: block !important; }
.officer-no-screen { display: block; margin-top: 6px; font-size: 14px; color: #baa98b; }
.officer-guide { display: block; margin-top: 6px; }
.guide-officers .officer-card p { margin: 10px 0 0; }
.officer-stats { margin-top: 16px; padding-top: 6px; border-top: 1px solid rgba(164, 130, 67, .4); }
.officer-stats strong { color: #dcc48d; }
.guide-officers [hidden] { display: none !important; }

@media (max-width: 600px) {
    .officer-grid { gap: 10px; margin-top: 16px; }
    .officer-card { padding: 14px; }
}

/* Game textures are exported from Paper.dds and sith_icons_old_blue.dds.
   Labels and values remain editable HTML. */
.officer-sheet {
    box-sizing: border-box;
    width: min(1020px, calc(100% - 32px));
    max-width: none;
    max-height: calc(100dvh - 32px);
    margin: auto;
    padding: 0;
    overflow: auto;
    overscroll-behavior: contain;
    border: 3px double #b3995a;
    border-radius: 5px;
    background: #221a10;
    color: #f5e4a5;
    font: 15px/1.25 Georgia, 'Times New Roman', serif;
    box-shadow: 0 16px 80px #000b;
}
.officer-sheet::backdrop { background: #000c; }
.officer-sheet-layout {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 0;
    height: min(680px, calc(100dvh - 60px));
    background: linear-gradient(#100c08a6, #100c08a6), url('/static/guides/img/guide-banner.jpg') center / cover;
}
.officer-sheet-layout > section {
    position: relative;
    isolation: isolate;
    min-width: 0;
    min-height: 0;
    overflow: auto;
    border: 1px solid #a88c50;
    box-shadow: inset 0 0 14px #21150580;
}
.officer-sheet-layout > section::before,
.officer-sheet-layout > section::after {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
}
.officer-sheet-layout > section::before {
    z-index: -2;
    background: url('/static/guides/other/officers/ui/paper.webp') center / cover;
    opacity: .65;
}
.officer-sheet-layout > section::after {
    z-index: -1;
    background: linear-gradient(#0d09052e, #0d09050d 28%, #0d09056b),
        radial-gradient(ellipse at 50% 35%, transparent 35%, #160f084d);
}
.officer-sheet-layout > .officer-sheet-left { display: flex; flex-direction: column; overflow: hidden; }
#officer-sheet-panel { flex: 1; min-height: 0; overflow: auto; overscroll-behavior: contain; }
#officer-sheet-panel[aria-labelledby="officer-tab-parameters"] { display: flex; flex-direction: column; }
#officer-sheet-panel[aria-labelledby="officer-tab-parameters"] > .officer-sheet-heading { flex-shrink: 0; }
#officer-sheet-panel[aria-labelledby="officer-tab-parameters"] > .officer-sheet-rows {
    flex: 1;
    display: flex;
    flex-direction: column;
}
#officer-sheet-panel[aria-labelledby="officer-tab-parameters"] > .officer-sheet-rows > div { flex: 1; }
#officer-sheet-panel[aria-labelledby="officer-tab-personal"] .officer-sheet-rows > div,
#officer-sheet-panel[aria-labelledby="officer-tab-ship"] .officer-sheet-rows > div {
    min-height: 36px;
    padding-block: 4px;
}
.officer-sheet-center { display: flex; flex-direction: column; }
.officer-sheet-center > * { flex-shrink: 0; }
.officer-sheet-layout > .officer-sheet-right {
    display: grid;
    grid-template-rows: auto minmax(min-content, 1fr) auto minmax(min-content, 1fr) auto minmax(min-content, 1fr);
}
.officer-sheet-right > div { display: flex; overflow: clip; }
.officer-sheet-right .officer-sheet-rows { flex: 1; display: flex; flex-direction: column; }
.officer-sheet-right .officer-sheet-rows > div { flex: 1; padding-block: 0; }
.officer-sheet-tabs { flex-shrink: 0; }
.officer-sheet .officer-sheet-heading {
    margin: 0;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 32px;
    min-height: 32px;
    padding: 0 4px;
    border-block: 1px solid #ad975d;
    background: #160f09 url('/static/guides/other/officers/ui/heading.webp') center / 100% 100%;
    color: #edda82;
    font: 30px/.9 'MyCustomFont', Georgia, serif;
    text-align: center;
    text-shadow: 1px 2px #000;
}
.officer-sheet #officer-sheet-name { min-height: 40px; display: grid; place-items: center; padding-right: 24px; }
.officer-sheet-portrait-wrap { position: relative; align-self: start; width: 100%; }
.officer-sheet-portrait { display: block; width: 100%; height: auto; aspect-ratio: 1; object-fit: cover; margin: 0; border-block: 3px double #cfb575; }
.officer-sheet-character {
    position: absolute; top: 12px; right: 12px;
    width: clamp(42px, 20%, 76px); aspect-ratio: 1;
    padding: 0; border: 0; background: transparent; cursor: pointer;
    filter: drop-shadow(0 2px 2px #000a);
}
.officer-sheet-character img { display: block; width: 100%; height: 100%; margin: 0; }
.officer-sheet-character-random { box-sizing: border-box; display: grid; place-items: center; width: 100%; height: 100%; border: 2px solid #b79c61; border-radius: 50%; background: #272016; color: #ffe9a1; font: bold 38px/1 Georgia, serif; text-shadow: 0 2px 3px #000; }
.officer-sheet-character-tip {
    position: absolute; z-index: 1; top: 94px; right: 8px;
    max-width: calc(100% - 16px); padding: 6px 10px;
    border: 1px solid #b79c61; border-radius: 4px;
    background: #21180eee; color: #fff0b6;
    font: 15px/1.3 Arial, Helvetica, sans-serif;
}
.officer-sheet-loyalty { padding: 4px; background: linear-gradient(90deg, #34531c, #4d901d, #34531c); color: #ffffa0; text-align: center; text-shadow: 1px 1px #102004; border-bottom: 2px solid #887546; }
.officer-sheet-rows { margin: 0; }
.officer-sheet-rows > div { box-sizing: border-box; display: flex; align-items: center; justify-content: space-between; gap: 5px; min-height: 25px; padding: 1px 7px 1px 5px; border-bottom: 1px solid #675a3a99; box-shadow: 0 1px #e6d9aa44; }
.officer-sheet-rows dt { display: flex; align-items: center; gap: 5px; min-width: 0; font-weight: 600; }
.officer-sheet-rows dd { flex-shrink: 1; min-width: 0; max-width: 48%; overflow-wrap: anywhere; margin: 0; text-align: right; color: #fff1b4; font: 15px/1.15 Georgia, serif; }
.officer-sheet-rows dd:has(.officer-sheet-ink:empty) { display: none; }
.officer-sheet-ink {
    color: #ecd697;
    background: linear-gradient(to bottom, #fff4c9 12%, #eedda8 52%, #c8af6a 100%);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 1px 0 #21170c) drop-shadow(0 2px 1px #21170c80);
}
.officer-sheet-rows dd.officer-sheet-number { font-size: 22px; line-height: 1; }
.officer-sheet-max .officer-sheet-ink {
    background-image: linear-gradient(to bottom, #fff5aa 8%, #ffdb58 48%, #c68b18 100%);
    filter: drop-shadow(0 1px 0 #342207) drop-shadow(0 0 2px #dca53566);
}
.officer-sheet-symbol { display: inline-grid; place-items: center; width: 24px; height: 24px; flex: 0 0 24px; color: #e9c567; font: 28px/1 Georgia, serif; text-shadow: 1px 2px 2px #211b10; }
.officer-sheet-symbol img { display: block; width: 30px; height: 30px; }
.officer-sheet-symbol.officer-sheet-game-icon {
    width: 24px;
    height: 24px;
    margin: 0;
    background-image: url('/static/guides/other/officers/ui/icons.webp?v=8');
    background-size: 192px auto;
    background-position: calc(var(--officer-icon-x) * .6) calc(var(--officer-icon-y) * .6);
    background-repeat: no-repeat;
    transform: scale(1.4);
    transform-origin: center;
}
.officer-sheet-rows dt { font-family: Arial, Helvetica, sans-serif; }
#officer-sheet-special .officer-sheet-symbol { font-weight: bold; }
.officer-sheet-tabs { display: grid; grid-template-columns: 1.6fr 1fr 1fr; }
.officer-sheet-tabs button {
    min-height: 40px; padding: 4px 3px; border: 1px solid #82744e;
    background: linear-gradient(#625d4e, #302f2b); color: #e5d593;
    font: 17px Georgia, serif; text-shadow: 1px 1px #000; cursor: pointer;
}
.officer-sheet-tabs button[aria-selected="true"] { background: linear-gradient(#b4a582, #6e5e41); color: #fff0ac; box-shadow: inset 0 0 8px #ead99c55; }
.officer-sheet-tabs button:focus-visible, .officer-sheet button:focus-visible { outline: 2px solid #fff0ac; outline-offset: -3px; }
.officer-sheet .officer-sheet-note { margin: 0; padding: 10px 8px; color: #fff0bf; font: 500 14px/1.4 Georgia, serif; text-shadow: 0 1px 2px #211508; }
.officer-sheet-close { position: absolute; top: 8px; right: 9px; z-index: 1; width: 30px; height: 30px; padding: 0; border: 1px solid #cdb97b; border-radius: 50%; background: #24180d; color: #f4dea0; font: 26px/1 Georgia, serif; cursor: pointer; }
.officer-sheet-bottom-close { display: block; align-self: center; margin: auto auto 8px; padding: 4px 26px; border: 1px solid #ad975d; border-radius: 3px; background: #21180e; color: #f4dea0; font: 15px/1.2 Georgia, serif; cursor: pointer; }
@media (max-width: 800px) {
    .officer-sheet { width: calc(100% - 16px); max-height: calc(100dvh - 16px); touch-action: pan-y pinch-zoom; }
    .officer-sheet-layout { grid-template-columns: 1fr 1fr; height: auto; }
    .officer-sheet-layout > section { overflow: visible; }
    .officer-sheet-layout > .officer-sheet-left { height: auto; overflow: visible; }
    #officer-sheet-panel { overflow: visible; overscroll-behavior: auto; }
    .officer-sheet-center { grid-column: 1 / -1; grid-row: 1; display: grid; grid-template-columns: 128px minmax(0, 1fr); }
    .officer-sheet #officer-sheet-name { grid-column: 1 / -1; }
    .officer-sheet-portrait-wrap { grid-row: 2 / 5; align-self: start; }
    .officer-sheet-character { top: 6px; right: 6px; }
    .officer-sheet-character-tip { top: 54px; }
    .officer-sheet-center .officer-sheet-note { grid-column: 1 / -1; }
    #officer-sheet-skills .officer-sheet-rows > div:last-child { position: relative; min-height: 38px; }
    #officer-sheet-skills .officer-sheet-bottom-close {
        position: absolute;
        left: 50%;
        top: 50%;
        transform: translate(-50%, -50%);
        margin: 0;
        padding: 4px 12px;
        max-width: 34%;
        z-index: 1;
    }
    .officer-sheet-rows > div { padding-inline: 5px; }
}
@media (max-width: 540px) {
    .officer-sheet-layout { display: flex; flex-direction: column; }
    .officer-sheet-center { order: -1; }
    .officer-sheet-center { display: block; }
    .officer-sheet-portrait-wrap { width: 160px; margin-inline: auto; }
    .officer-sheet-portrait { border: 3px double #cfb575; }
    .officer-sheet-rows > div { min-height: 30px; padding-inline: 8px; }
}

/* Ability icons occupy the central 32 px of a 40 px atlas tile.
   Crop that padding instead of enlarging the sprite with a transform. */
#officer-sheet-panel:is([aria-labelledby="officer-tab-personal"], [aria-labelledby="officer-tab-ship"]) .officer-sheet-rows > div {
    padding: 2px 7px 2px 2px;
    min-height: 37px;
}
#officer-sheet-panel:is([aria-labelledby="officer-tab-personal"], [aria-labelledby="officer-tab-ship"]) .officer-sheet-game-icon {
    width: 32px;
    height: 32px;
    flex-basis: 32px;
    background-size: 320px auto;
    background-position: calc(var(--officer-icon-x) - 4px) calc(var(--officer-icon-y) - 4px);
    transform: none;
}
