.drawer[data-panel=ship] {
  --ship-bg: #24211d;
  --ship-inset: #1a1917;
  --ship-line: #ae936455;
  --ship-brass: #bd9b61;
  --ship-muted: #c1b7a2;
  inset: auto var(--safe-right) calc(var(--dock-clearance) + 10px) auto;
  width: min(410px,52%);
  max-height: calc(100% - var(--hud-offset) - var(--dock-clearance) - 18px);
  border-color: #887452;
  border-radius: 7px;
  background: var(--ship-bg);
  box-shadow: 0 10px 27px #120e0bc4;
}
.drawer[data-panel=ship] .drawer-head {
  min-height: 42px;
  gap: 7px;
  padding: 4px 8px;
  border-bottom-color: #8a7550;
  background: linear-gradient(#393128,#28231d);
  box-shadow: inset 0 1px #ffe2ad25;
}
.drawer[data-panel=ship] .drawer-icon {
  background: #28241e;
  color: var(--bright-gold);
}
.drawer[data-panel=ship] h2 { font-size: 17px; color: var(--bright-gold); }
.drawer[data-panel=ship] .drawer-body { padding: 8px; scrollbar-color: #8a7550 #211d18; }
.ship-control { gap: 8px; min-width: 0; }
.ship-control-top, .ship-control-heading, .ship-control-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.ship-control-heading, .ship-control-top { justify-content: space-between; }
.ship-control [data-ship-action=back] svg { rotate: 180deg; }
.ship-control .small-button:not(.accent) {
  border-color: var(--ship-line);
  color: var(--bright-gold);
  background: #312a21;
}
.ship-control .small-button:not(.accent):hover, .ship-control .small-button[aria-pressed=true] {
  border-color: var(--ship-brass);
  background: #4a3927;
}
.ship-fleet-picker {
  display: flex;
  justify-content: safe flex-end;
  flex: 1;
  gap: 4px;
  min-width: 0;
  overflow: auto;
  padding: 3px;
  scrollbar-width: thin;
}
.ship-fleet-picker button {
  display: grid;
  grid-template-columns: 25px auto;
  align-items: center;
  gap: 3px;
  min-height: 36px;
  padding: 2px 5px;
  border: 1px solid var(--ship-line);
  border-radius: 4px;
  background: #201d19;
  color: var(--ship-muted);
  font-size: 11px;
}
.ship-fleet-picker img { width: 25px; height: 25px; object-fit: contain; }
.ship-fleet-picker button:hover, .ship-fleet-picker [aria-pressed=true] {
  border-color: var(--ship-brass);
  background: #4a3927;
  color: var(--ink);
}
.ship-control-identity {
  display: grid;
  grid-template-columns: minmax(90px,43%) minmax(0,1fr);
  align-items: center;
  gap: 10px;
  min-width: 0;
  min-height: 112px;
  padding: 4px 12px 4px 5px;
  border: 1px solid var(--ship-line);
  border-radius: 5px;
  background: radial-gradient(ellipse at 23% 36%,#526462 1%,#293837 44%,#26221e 80%);
  box-shadow: inset 0 0 0 3px #ae936410;
}
.ship-control-identity img {
  place-self: center;
  width: 100%;
  height: 105px;
  object-fit: contain;
  filter: drop-shadow(0 5px 4px #100f0dc9);
}
.ship-control-identity div { display: grid; justify-items: start; gap: 4px; min-width: 0; }
.ship-control-identity h3, .ship-control-heading h3 {
  margin: 0;
  font: 700 15px/1.2 var(--serif);
  color: var(--bright-gold);
  overflow-wrap: anywhere;
}
.ship-control-identity h3 { font-size: 20px; color: var(--ink); }
.ship-control-identity small, .ship-control-heading > span {
  color: var(--ship-muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}
.ship-control-heading > span { max-width: 57%; text-align: right; }
.ship-control-heading h3 { display: flex; align-items: center; gap: 6px; }
.ship-control-heading svg { color: var(--ship-brass); }
.ship-control .trade-badge {
  border: 1px solid #ae936447;
  border-radius: 3px;
  padding: 2px 6px;
  color: #efdbb5;
  background: #29241e;
}
.ship-control .trade-badge:is([data-state=sailing],[data-state=handling],[data-state=unloading],[data-state=loading]) {
  color: #daefdf;
  background: #354b42;
}
.ship-control .trade-badge[data-state=storageFull] { color: #ffd2ba; background: #54392a; }

.ship-control-content, .ship-control-card, .ship-transfer { display: grid; gap: 8px; min-width: 0; }
.ship-control-card { padding: 9px 10px; border: 1px solid var(--ship-line); border-radius: 5px; background: #2b2620; }
.ship-control-card progress { width: 100%; height: 5px; margin: 0; accent-color: var(--ship-brass); }
.ship-control-card progress::-webkit-progress-bar { background: #191713; }
.ship-control-card progress::-webkit-progress-value { background: var(--ship-brass); }
.ship-control-card progress::-moz-progress-bar { background: var(--ship-brass); }
.ship-control-card .ship-control-empty { margin: 0; color: var(--ship-muted); }
.ship-cargo, .ship-control-market ul, [data-ship-log] { list-style: none; margin: 0; padding: 0; }
.ship-cargo { display: grid; grid-template-columns: repeat(auto-fill,minmax(70px,1fr)); gap: 5px; }
.ship-cargo li { min-width: 0; }
.ship-cargo :is(button,li > div) {
  position: relative;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 2px;
  width: 100%;
  min-height: 62px;
  padding: 5px 3px;
  border: 1px solid var(--ship-line);
  border-radius: 4px;
  background: radial-gradient(ellipse at 50% 30%,#494033,#211d18 82%);
  box-shadow: inset 0 0 0 2px #08060350;
  text-align: center;
}
.ship-cargo button:hover { background: #493b2b; border-color: var(--ship-brass); }
.ship-good-art { width: 27px; height: 27px; filter: drop-shadow(0 2px 3px #090705b0); }
.ship-control-market .ship-good-art { width: 18px; height: 18px; }
.ship-cargo strong {
  position: absolute;
  inset: 3px 4px auto auto;
  min-width: 15px;
  padding-inline: 2px;
  border-radius: 3px;
  background: #241f19;
  color: var(--bright-gold);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}
.ship-cargo small { width: 100%; color: #e9dac0; font-size: 10px; line-height: 1.15; overflow-wrap: anywhere; }
.ship-cargo .ship-slot-add { border-style: dashed; background: #211d18; box-shadow: none; color: var(--bright-gold); }
.ship-cargo .ship-slot-add svg { width: 21px; height: 21px; }
.ship-cargo .ship-empty-hold { grid-column: 1 / -1; color: var(--ship-muted); font-size: 12px; }

.ship-deck-tabs { display: flex; min-width: 0; border: 1px solid var(--ship-line); border-radius: 5px 5px 0 0; background: #211d19; }
.ship-deck-tabs button {
  display: flex;
  flex: 1;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-width: 0;
  min-height: 37px;
  padding: 5px;
  border: 0;
  border-inline-end: 1px solid var(--ship-line);
  background: transparent;
  color: var(--ship-muted);
  font: 700 12px/1.15 var(--ui);
}
.ship-deck-tabs button:last-child { border-inline-end: 0; }
.ship-deck-tabs svg { color: var(--ship-brass); }
.ship-deck-tabs [aria-pressed=true] { background: linear-gradient(#4e402d,#352b21); box-shadow: inset 0 2px var(--ship-brass); color: var(--ink); }
.ship-deck-tabs button:hover { color: var(--ink); }
.ship-deck-panel { margin-top: -8px; border-top: 0; border-radius: 0 0 5px 5px; }
.ship-control-form, .ship-track { display: grid; grid-template-columns: minmax(0,1fr); gap: 7px; min-width: 0; }
.ship-control-form > small, .ship-track small { color: var(--ship-muted); }
.ship-control-form > small[data-state="error"], .ship-control-form > small[data-state="unavailable"] { color: #ffcdb3; }
.ship-manual-course {
  min-width: 0;
  border: 1px solid var(--ship-line);
  border-radius: 4px;
  background: #241f19;
}
.ship-manual-course summary {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 5px 8px;
  color: var(--bright-gold);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
.ship-manual-course summary::after {
  content: '';
  width: 6px;
  height: 6px;
  margin-inline-start: auto;
  border: solid var(--ship-brass);
  border-width: 0 1px 1px 0;
  rotate: 45deg;
}
.ship-manual-course[open] summary::after { rotate: 225deg; }
.ship-manual-course form { padding: 7px 8px; border-top: 1px solid var(--ship-line); }
.ship-control :is(select,input:not([type=checkbox])) { border-color: var(--ship-line); background: var(--ship-inset); }
.ship-control-fields { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 7px; min-width: 0; }
.ship-control-fields:has([data-ship-price-row][hidden]) { grid-template-columns: minmax(0,1fr); }
.ship-control-tabs { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 5px; }
.ship-control-tabs button {
  min-height: 36px;
  padding: 5px;
  border: 1px solid var(--ship-line);
  border-radius: 4px;
  background: var(--ship-inset);
  color: var(--ship-muted);
  font: 700 12px/1.2 var(--ui);
}
.ship-control-tabs [aria-pressed=true] { border-color: var(--ship-brass); background: #493b2b; color: var(--ink); }
.ship-track {
  padding: 8px 9px;
  border: 1px solid var(--ship-line);
  border-radius: 4px;
  background: #201e18;
}
.ship-track-ports { display: grid; grid-template-columns: minmax(0,1fr) auto minmax(0,1fr); align-items: center; gap: 6px; overflow-wrap: anywhere; }
.ship-track-ports strong { color: var(--bright-gold); text-align: end; }
.ship-track-ports svg { color: var(--ship-brass); }
.ship-control-market summary { color: var(--bright-gold); font-weight: 650; cursor: pointer; }
.ship-control-market ul, [data-ship-log] { display: grid; gap: 5px; }
.ship-control-market ul:not(:empty) { padding-block: 6px; }
.ship-control-market li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 5px;
  padding: 6px 8px;
  border: 1px solid var(--ship-line);
  border-radius: 4px;
  background: var(--ship-inset);
}
.ship-control-market li strong { display: flex; align-items: center; gap: 5px; font-size: 13px; }
.ship-control-market li small, [data-ship-log] { color: var(--ship-muted); font-size: 12px; }
[data-ship-log] li { padding: 6px 0; border-bottom: 1px solid var(--ship-line); }
[data-ship-log] li:last-child { border-bottom: 0; }
.ship-control [data-ship-action=release] { justify-self: start; }
.ship-map-actions:not(:has(> :not([hidden]))), .ship-map-touch { display: none; }
@media (pointer: coarse) {
  .ship-map-mouse { display: none; }
  .ship-map-touch { display: inline; }
}
@media (max-width: 660px) {
  .drawer[data-panel=ship] { inset: auto 0 var(--dock-clearance); width: 100%; max-height: min(82%,calc(100% - var(--hud-offset) - var(--dock-clearance) - 8px)); border-radius: 8px 8px 0 0; }
  .ship-control .small-button, .ship-control-tabs button, .ship-deck-tabs button, .ship-manual-course summary { min-height: 44px; }
}
[data-ship-customs]:not([hidden]) { display: grid; justify-items: start; gap: 3px; }
