/* === UkSeas Nautical Planner Studio (Print & PDF Output Panel) === */

.studio-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 10500;
  background: rgba(10, 18, 30, 0.82);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  box-sizing: border-box;
}

.studio-modal-window {
  background: var(--bg-surface, #0f172a);
  border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.12));
  border-radius: 12px;
  width: 100%;
  max-width: 1180px;
  height: 90vh;
  height: 90dvh;
  max-height: 860px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 25px 60px -15px rgba(0, 0, 0, 0.65);
  overflow: hidden;
  color: var(--text-main, #f8fafc);
}

[data-theme="light"] .studio-modal-window {
  background: #ffffff;
  border-color: #cbd5e1;
  color: #0f172a;
}

/* Studio Header */
.studio-modal-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.1));
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-surface-elevated, rgba(30, 41, 59, 0.5));
}

.studio-title-block h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-main, #f8fafc);
}

.studio-title-block p {
  margin: 2px 0 0 0;
  font-size: 11.5px;
  color: var(--text-muted, #94a3b8);
}

.studio-header-site-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(14, 165, 233, 0.14);
  border: 1px solid rgba(14, 165, 233, 0.35);
  color: #38bdf8;
  padding: 3px 8px;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 600;
}

.studio-close-btn {
  background: transparent;
  border: none;
  color: var(--text-muted, #94a3b8);
  font-size: 24px;
  cursor: pointer;
  line-height: 1;
  padding: 2px 8px;
  border-radius: 4px;
  transition: all 0.15s ease;
}

.studio-close-btn:hover {
  color: #ef4444;
  background: rgba(239, 68, 68, 0.1);
}

/* Mobile Tabs Switcher */
.studio-mobile-tabs {
  display: none;
  padding: 6px 12px;
  background: var(--bg-card, rgba(15, 23, 42, 0.6));
  border-bottom: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.08));
  gap: 8px;
}

[data-theme="light"] .studio-mobile-tabs {
  background: #f8fafc;
  border-bottom-color: rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .studio-tab-btn {
  color: #475569;
}

[data-theme="light"] .studio-tab-btn.active {
  background: #ffffff;
  border-color: #0284c7;
  color: #0284c7;
}

.studio-tab-btn {
  flex: 1;
  padding: 7px 12px;
  border-radius: 6px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted, #94a3b8);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.studio-tab-btn.active {
  background: var(--bg-surface, #1e293b);
  border-color: rgba(56, 189, 248, 0.4);
  color: #38bdf8;
}

/* Dual Pane Body */
.studio-modal-body {
  flex: 1;
  display: flex;
  min-height: 0;
  overflow: hidden;
}

/* Left Pane: Controls */
.studio-controls-pane {
  width: 350px;
  min-width: 320px;
  border-right: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.1));
  padding: 12px 18px;
  overflow-y: auto;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
}

.studio-section-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 0;
  border-top: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.08));
}

details.studio-section-card {
  display: block;
}
details.studio-section-card summary::-webkit-details-marker {
  display: none;
}
details.studio-section-card summary {
  list-style: none;
  cursor: pointer;
}
details.studio-section-card[open] summary {
  margin-bottom: 8px;
}

.studio-section-card:first-child {
  padding-top: 2px;
  border-top: none;
}

.studio-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #38bdf8;
  margin: 0;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.studio-option-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.studio-radio-label,
.studio-check-label {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 12px;
  color: var(--text-main, #f8fafc);
  cursor: pointer;
  user-select: none;
}

.studio-radio-label input,
.studio-check-label input {
  margin-top: 2px;
  cursor: pointer;
}

.studio-radio-desc {
  font-size: 10.5px;
  color: var(--text-muted, #94a3b8);
  margin-top: 1px;
}

.studio-input-field {
  width: 100%;
  box-sizing: border-box;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.15));
  color: var(--text-main, #f8fafc);
  padding: 6px 10px;
  border-radius: 5px;
  font-size: 12px;
  outline: none;
  transition: border-color 0.15s ease;
}

[data-theme="light"] .studio-input-field {
  background: #f8fafc;
  border-color: #cbd5e1;
  color: #0f172a;
}

.studio-input-field:focus {
  border-color: #38bdf8;
}

/* Live Preview Mode Toolbar */
.studio-preview-toolbar {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto 12px auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 14px;
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(56, 189, 248, 0.25);
  border-radius: 6px;
  backdrop-filter: blur(8px);
  color: #f8fafc;
  font-size: 11.5px;
  font-weight: 600;
  box-sizing: border-box;
  flex-shrink: 0;
}

[data-theme="light"] .studio-preview-toolbar {
  background: #ffffff;
  border-color: #cbd5e1;
  color: #0f172a;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.studio-preview-badge {
  display: flex;
  align-items: center;
  gap: 8px;
}

.studio-preview-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.7);
  flex-shrink: 0;
}

.studio-preview-nav {
  display: flex;
  align-items: center;
  gap: 8px;
}

.studio-page-nav-btn {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #f8fafc;
  width: 24px;
  height: 24px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 16px;
  font-weight: bold;
  line-height: 1;
  padding: 0;
  transition: all 0.15s ease;
}

[data-theme="light"] .studio-page-nav-btn {
  background: #f1f5f9;
  border-color: #cbd5e1;
  color: #0f172a;
}

.studio-page-nav-btn:hover:not(:disabled) {
  background: #38bdf8;
  color: #0f172a;
  border-color: #38bdf8;
}

.studio-page-nav-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.studio-page-nav-label {
  font-size: 11px;
  font-weight: 700;
  color: #38bdf8;
  letter-spacing: 0.2px;
}

[data-theme="light"] .studio-page-nav-label {
  color: #0369a1;
}

/* Right Pane: Live Vector Preview Mode */
.studio-preview-pane {
  flex: 1;
  background: rgba(10, 15, 28, 0.6);
  padding: 16px 20px 24px 20px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  box-sizing: border-box;
}

[data-theme="light"] .studio-preview-pane {
  background: #f1f5f9;
}

/* Paper Sheet Layout in Preview */
.studio-paper-sheet {
  position: relative;
  background: #ffffff;
  color: #0f172a;
  border-radius: 4px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.45);
  display: flex;
  flex-direction: column;
  padding: 10px 14px 12px 14px;
  box-sizing: border-box;
  font-family: system-ui, -apple-system, sans-serif;
  margin: 0 auto;
  height: auto;
  min-height: fit-content;
  transition: width 0.2s ease, min-height 0.2s ease, aspect-ratio 0.2s ease;
}

/* Aspect Ratios: ISO 216 1 : 1.4142 standard */
.studio-paper-sheet.orient-landscape {
  aspect-ratio: 1.4142 / 1;
}

.studio-paper-sheet.orient-portrait {
  aspect-ratio: 1 / 1.4142;
}

/* Proportional Sizing according to Target Paper Size */
.studio-paper-sheet.size-a4.orient-landscape {
  width: 860px;
  min-height: 608px;
}

.studio-paper-sheet.size-a4.orient-portrait {
  width: 608px;
  min-height: 860px;
}

.studio-paper-sheet.size-a3.orient-landscape {
  width: 1080px;
  min-height: 764px;
}

.studio-paper-sheet.size-a3.orient-portrait {
  width: 764px;
  min-height: 1080px;
}

.studio-paper-sheet.size-a2.orient-landscape {
  width: 1240px;
  min-height: 877px;
}

.studio-paper-sheet.size-a2.orient-portrait {
  width: 877px;
  min-height: 1240px;
}

/* Linear Mode (Day 1 at Row 1): 31 days calibrated - Sheet neatly encloses all 31 rows */
.studio-paper-sheet.sheet-linear {
  width: 880px;
  max-width: 100%;
}

/* Day-of-Week Aligned Mode: 37 days (Allows extra vertical space) - Sheet neatly encloses all 37 rows */
.studio-paper-sheet.sheet-day-aligned {
  width: 980px;
  max-width: 100%;
}

/* Trip Manifest (Active Screen / Custom Horizon) */
.studio-paper-sheet.sheet-trip {
  width: 860px;
  max-width: 100%;
}

.studio-paper-sheet.sheet-trip.trip-days-7,
.studio-paper-sheet.sheet-trip.trip-days-14 {
  min-height: auto !important;
  height: auto !important;
}

.studio-paper-sheet.sheet-portrait {
  width: 660px;
  max-width: 100%;
}

.studio-paper-sheet.sheet-portrait.trip-days-7,
.studio-paper-sheet.sheet-portrait.trip-days-14 {
  min-height: auto !important;
  height: auto !important;
}

.studio-paper-sheet.sheet-landscape {
  max-width: 100%;
}

/* Month Grid Layout (7 columns x 5/6 weeks) */
.studio-paper-sheet.sheet-month-grid {
  width: 900px;
  max-width: 100%;
  min-height: 580px;
}

.studio-paper-sheet.sheet-month-grid.sheet-landscape {
  width: 1060px;
}

.studio-paper-sheet.sheet-month-grid .preview-cell {
  min-height: 75px;
}

.studio-paper-sheet.sheet-month-grid.month-dense-multi .preview-cell {
  min-height: 0;
}

.preview-sheet-header {
  background: #0f2942;
  color: #ffffff;
  padding: 6px 12px;
  border-radius: 3px;
  margin-bottom: 6px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  flex: 0 0 auto;
}

.preview-header-left {
  flex: 1 1 auto;
  min-width: 0;
}

.preview-header-right {
  flex: 0 0 auto;
  text-align: right;
  white-space: nowrap;
}

.preview-header-notice {
  font-size: 8px;
  font-weight: 600;
  color: #94a3b8;
  letter-spacing: 0.1px;
}

.preview-sheet-title {
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.2px;
}

.preview-sheet-subtitle {
  font-size: 7.5px;
  color: #cbd5e1;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.preview-grid-wrapper {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  display: flex;
}

.preview-calendar-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 6px;
}

.preview-th {
  background: #173a5e;
  color: #ffffff;
  padding: 2px 1px;
  font-size: 6.5px;
  font-weight: 700;
  text-align: center;
  border: 0.5px solid #0f2942;
  height: 16px;
  box-sizing: border-box;
}

.preview-cell {
  border: 0.5px solid #cbd5e1;
  padding: 0 1.5px;
  vertical-align: middle;
  background: #ffffff;
  line-height: 1.1;
  box-sizing: border-box;
}

/* Linear Mode (31 days) Row Heights */
.sheet-linear .preview-cell {
  height: 15.5px;
  min-height: 15.5px;
}

/* Day-of-Week Aligned Mode (37 days) Row Heights */
.sheet-day-aligned .preview-cell {
  height: 15px;
  min-height: 15px;
}

/* Trip Manifest Row Heights & Styling */
.sheet-trip .preview-calendar-table {
  height: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.sheet-trip .preview-cell {
  vertical-align: middle;
}

.sheet-trip.trip-days-7 .preview-calendar-table,
.sheet-trip.trip-days-14 .preview-calendar-table {
  height: auto !important;
}

.sheet-trip.trip-days-7 .preview-grid-wrapper,
.sheet-trip.trip-days-14 .preview-grid-wrapper {
  flex: 0 0 auto !important;
  height: auto !important;
}

.sheet-trip.trip-days-7 .preview-cell,
.sheet-trip.trip-days-14 .preview-cell {
  height: auto !important;
  min-height: 24px !important;
  padding: 2px 5px;
}

.sheet-trip.trip-days-30 .preview-cell,
.sheet-trip.trip-days-1month .preview-cell {
  height: 16px;
  min-height: 13.5px;
}

.studio-paper-sheet.orient-portrait.trip-days-30,
.studio-paper-sheet.orient-portrait.trip-days-1month {
  padding: 8px 12px 8px 12px;
}

.sheet-trip.orient-portrait.trip-days-30 .preview-sheet-header,
.sheet-trip.orient-portrait.trip-days-1month .preview-sheet-header {
  padding: 4px 10px;
  margin-bottom: 4px;
}

.sheet-trip.trip-days-30 .preview-sheet-footer,
.sheet-trip.trip-days-1month .preview-sheet-footer {
  margin-top: 2px;
  flex: 0 0 auto;
}

.sheet-trip.trip-days-14 .preview-slack-pill {
  padding: 2.5px 7px;
}

.sheet-trip.trip-days-30 .preview-slack-pill,
.sheet-trip.trip-days-1month .preview-slack-pill {
  padding: 1px 4px;
  line-height: 1.15;
}

.sheet-trip.orient-portrait.trip-days-30 .preview-slack-pill,
.sheet-trip.orient-portrait.trip-days-1month .preview-slack-pill {
  padding: 1px 4px;
  font-size: 8px;
  line-height: 1.15;
}

.sheet-trip.orient-portrait.trip-days-30 .pill-trip-3col .preview-seg,
.sheet-trip.orient-portrait.trip-days-1month .pill-trip-3col .preview-seg {
  padding: 0.5px 2px;
  line-height: 1.05;
}

.sheet-trip.orient-portrait.trip-days-30 .pill-trip-3col .preview-seg span.seg-time,
.sheet-trip.orient-portrait.trip-days-1month .pill-trip-3col .preview-seg span.seg-time {
  font-size: 7.2px;
}

.sheet-trip.orient-portrait.trip-days-30 .pill-trip-3col .preview-seg span.seg-speed,
.sheet-trip.orient-portrait.trip-days-1month .pill-trip-3col .preview-seg span.seg-speed {
  font-size: 6.2px;
}

.sheet-trip.trip-days-7:not(.sites-dense):not(.sites-medium) .pill-trip-3col .preview-seg {
  padding: 2.5px 3px;
}

.sheet-trip.trip-days-7:not(.sites-dense):not(.sites-medium) .preview-seg span.seg-time {
  font-size: 11.5px;
  font-weight: 700;
}

.sheet-trip.trip-days-7:not(.sites-dense):not(.sites-medium) .preview-seg span.seg-speed {
  font-size: 9.5px;
  font-weight: 600;
}

.sheet-trip.trip-days-7.sites-medium .preview-seg span.seg-time,
.sheet-trip.trip-days-7 .pill-trip-compact .preview-seg span.seg-time {
  font-size: 9px !important;
  font-weight: 700 !important;
  letter-spacing: -0.2px !important;
}

.sheet-trip.trip-days-7.sites-medium .preview-seg span.seg-speed,
.sheet-trip.trip-days-7 .pill-trip-compact .preview-seg span.seg-speed {
  font-size: 8px !important;
  font-weight: 600 !important;
}

.sheet-trip .pill-trip-compact .preview-seg {
  padding: 2px 1.5px !important;
}

.sheet-trip.sites-dense .preview-seg span.seg-time,
.sheet-trip .pill-trip-dense .preview-seg span.seg-time {
  font-size: 7.8px !important;
  font-weight: 700 !important;
  letter-spacing: -0.25px !important;
  line-height: 1.1 !important;
}

.sheet-trip.sites-dense .preview-seg span.seg-speed,
.sheet-trip .pill-trip-dense .preview-seg span.seg-speed {
  font-size: 6.8px !important;
  font-weight: 600 !important;
  letter-spacing: -0.2px !important;
  line-height: 1.1 !important;
}

.sheet-trip.sites-dense .preview-seg,
.sheet-trip .pill-trip-dense .preview-seg {
  padding: 1.5px 1px !important;
}

.sheet-trip.trip-days-14 .pill-trip-3col .preview-seg {
  padding: 1.5px 3.5px;
}

.sheet-trip.trip-days-30 .pill-trip-3col .preview-seg,
.sheet-trip.trip-days-1month .pill-trip-3col .preview-seg {
  padding: 0.5px 2px;
  line-height: 1.05;
}

/* Month Grid (5/6 weeks) Row Heights & Centering */
.sheet-month-grid .preview-calendar-table {
  height: 100%;
  table-layout: fixed;
}

.sheet-month-grid .preview-cell {
  height: 75px;
  min-height: 75px;
  padding: 3px 5px;
  vertical-align: top;
}

/* Month Grid Multi-Wreck Stacking */
.month-wreck-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  align-items: center;
  padding: 4px 10px;
  background: rgba(15, 23, 42, 0.05);
  border: 1px solid rgba(15, 23, 42, 0.12);
  border-radius: 4px;
  margin-top: 4px;
  font-size: 9px;
  color: #0f172a;
}

.month-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-weight: 700;
  color: #0f172a;
}

.month-legend-badge {
  font-size: 7.5px;
  font-weight: 800;
  color: #ffffff;
  background: #0284c7;
  border-radius: 3px;
  padding: 1px 5px;
  line-height: 1.1;
  min-width: 12px;
  text-align: center;
}

.month-wreck-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  margin-top: 1.5px;
  gap: 2.5px;
}

.month-wreck-badge {
  font-size: 7px;
  font-weight: 800;
  color: #38bdf8;
  background: rgba(56, 189, 248, 0.12);
  border: 0.5px solid rgba(56, 189, 248, 0.35);
  border-radius: 2px;
  padding: 0.5px 2.5px;
  line-height: 1.1;
  flex-shrink: 0;
}

.month-wreck-data {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  flex: 1;
  min-width: 0;
}

/* Month Grid Dense Multi-Wreck Rules (5+ wrecks) */
.sheet-month-grid.month-dense-multi .preview-cell {
  padding: 1.5px 2px;
}
.sheet-month-grid.month-dense-multi .month-wreck-row {
  margin-top: 0;
  gap: 2px;
}
.sheet-month-grid.month-dense-multi .month-wreck-badge {
  font-size: var(--mg-badge-fs, 6px);
  padding: 0 1.5px;
  min-width: 10px;
  line-height: 1.1;
}
.sheet-month-grid.month-dense-multi .preview-slack-pill {
  padding: var(--mg-pill-pad, 0.5px 2px);
  font-size: var(--mg-pill-fs, 6.5px);
  line-height: 1.1;
}
.sheet-month-grid.month-dense-multi .pill-month-3col .preview-seg {
  padding: 0.5px 1.5px;
  font-size: var(--mg-seg-fs, 5.5px);
  line-height: 1.05;
}

/* Paper Size scaling classes for demo preview */
.studio-paper-sheet.paper-a3 {
  width: 1100px;
  max-width: 100%;
}

.studio-paper-sheet.paper-a2 {
  width: 1280px;
  max-width: 100%;
}

.preview-cell.preview-weekend,
tr.preview-weekend > .preview-cell {
  background: #f1f5f9;
}

.preview-cell.preview-holiday,
tr.preview-holiday > .preview-cell {
  background: #fef3c7;
}

.preview-cell.preview-empty {
  background: #f8fafc;
  border-color: #e2e8f0;
}

/* Adaptive Trip Manifest Typography */
.pill-trip-lg {
  font-size: 13px;
  font-weight: 700;
  padding: 5px 12px;
  border-radius: 4px;
  line-height: 1.2;
  display: inline-flex;
}

.pill-trip-md {
  font-size: 10.5px;
  font-weight: 700;
  padding: 3px 7px;
  border-radius: 3px;
  line-height: 1.2;
  display: inline-flex;
}

.pill-trip-sm {
  font-size: 9.5px;
  font-weight: 700;
  padding: 2px 5px;
  border-radius: 3px;
  line-height: 1.2;
  display: inline-flex;
}

.pill-trip-xs {
  font-size: 8.5px;
  font-weight: 700;
  padding: 1.5px 3.5px;
  border-radius: 2px;
  line-height: 1.15;
  display: inline-flex;
}

.pill-trip-3col {
  display: flex;
  width: 100%;
  max-width: 100%;
  border-radius: 3px;
  overflow: hidden;
  gap: 1.5px;
}

.pill-trip-3col.pill-trip-compact {
  max-width: 100%;
  gap: 1px;
}

.pill-trip-3col.pill-trip-dense {
  max-width: 100%;
  gap: 0.5px;
}

.pill-trip-3col .preview-seg {
  padding: 3px 5px;
  border-radius: 2px;
  overflow: visible;
  text-align: center;
  white-space: nowrap;
}

.pill-trip-3col.pill-trip-compact .preview-seg {
  padding: 2px 3px;
  border-radius: 1.5px;
}

.pill-trip-3col.pill-trip-dense .preview-seg {
  padding: 1px 1.5px;
  border-radius: 1px;
}

/* Medium Month Grid Typography */
.pill-month-md {
  font-size: var(--mg-single-pill-fs, 11px);
  font-weight: 700;
  padding: var(--mg-single-pill-pad, 3px 8px);
  border-radius: 3px;
  line-height: 1.2;
  display: inline-flex;
  margin: var(--mg-single-pill-margin, 1.5px 0);
}

.pill-month-3col {
  display: flex;
  width: 100%;
  border-radius: 3px;
  overflow: hidden;
  gap: 1px;
  margin: var(--mg-single-pill-margin, 1.5px 0);
}

.pill-month-3col .preview-seg {
  padding: var(--mg-single-seg-pad, 2px 4px);
  font-size: var(--mg-single-seg-fs, inherit);
  border-radius: 2px;
}

.preview-cell-3zone {
  display: flex;
  align-items: center;
  width: 100%;
  height: 100%;
  gap: 2px;
  box-sizing: border-box;
}

.preview-zone-date {
  flex: 0 0 16px;
  font-size: 5.5px;
  font-weight: 600;
  color: #0f172a;
  white-space: nowrap;
  line-height: 1;
}

.preview-cell.preview-weekend .preview-zone-date {
  font-weight: 700;
  color: #0f2942;
}

.preview-zone-date small {
  font-size: 4.8px;
  color: #64748b;
  margin-left: 1px;
}

.preview-zone-data {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
  justify-content: center;
}

.preview-zone-badges {
  flex: 0 0 13px;
  width: 13px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 1px;
}

.preview-slack-pill {
  font-size: 5px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  width: 100%;
  box-sizing: border-box;
  padding: 0.5px 2px;
  border-radius: 1.5px;
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
}

.preview-slack-pill .slk-t {
  display: inline-block;
  text-align: center;
  width: 100%;
}

.preview-cell-3zone .preview-zone-data .preview-slack-pill {
  width: 100%;
  justify-content: center;
  text-align: center;
}

.preview-cell-3zone .preview-zone-data .preview-slack-pill .slk-t {
  text-align: center;
  width: 100%;
}

.preview-pill-3col {
  display: flex;
  width: 100%;
  border-radius: 1.5px;
  overflow: hidden;
  gap: 0.5px;
}

.preview-seg {
  flex: 1 1 0%;
  min-width: 0;
  text-align: center;
  font-size: 4.5px;
  padding: 0.5px 1px;
  white-space: nowrap;
  overflow: hidden;
  line-height: 1.1;
}

.preview-moon {
  font-size: 5.5px;
  line-height: 1;
}

.preview-tide-badge {
  font-size: 5px;
  font-weight: 700;
  color: #ffffff;
  padding: 0 1.5px;
  border-radius: 1px;
  line-height: 1;
}

.badge-neap {
  background: #10b981;
}

.badge-spring {
  background: #ef4444;
}

.preview-sheet-footer {
  margin-top: 4px;
  font-size: 5.5px;
  color: #64748b;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 0 0 auto;
}

/* Studio Modal Footer (Action Buttons) */
.studio-modal-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.1));
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-surface-elevated, rgba(30, 41, 59, 0.5));
}

.studio-footer-left {
  font-size: 11px;
  color: var(--text-muted, #94a3b8);
}

.studio-footer-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn-studio-action {
  padding: 7px 15px;
  border-radius: 6px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s ease;
  user-select: none;
}

.btn-studio-secondary {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.15));
  color: var(--text-main, #f8fafc);
}

.btn-studio-secondary:hover {
  background: rgba(255, 255, 255, 0.14);
}

.btn-studio-primary {
  background: #0284c7;
  border: 1px solid #0369a1;
  color: #ffffff;
}

.btn-studio-primary:hover {
  background: #0ea5e9;
}

.studio-mobile-preview-prompt {
  display: none;
}

/* Mobile Responsive Breakpoints */
@media (max-width: 1040px) {
  .studio-modal-window {
    height: 98vh;
    height: 98dvh;
    max-height: none;
    border-radius: 8px;
  }

  .studio-mobile-tabs {
    display: flex;
  }

  .studio-modal-body {
    flex-direction: column;
  }

  .studio-controls-pane {
    width: 100%;
    min-width: 0;
    border-right: none;
    flex: 1;
    padding: 14px;
  }

  .studio-mobile-preview-prompt {
    display: block;
    margin-top: 8px;
  }

  .studio-preview-pane {
    display: none;
    padding: 12px;
    flex: 1;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    align-items: flex-start;
    justify-content: flex-start;
  }

  .studio-paper-sheet {
    min-width: 680px;
    width: 680px;
    max-width: none;
    height: auto;
    margin: 0 auto;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
  }

  .studio-modal-footer {
    padding: 10px 14px;
    flex-direction: column;
    gap: 8px;
  }

  .studio-footer-actions {
    width: 100%;
  }

  .studio-footer-actions .btn-studio-action {
    flex: 1;
    justify-content: center;
  }
}

/* === PRINT ISOLATION RULES (Browser Print Sheet) === */
@media print {
  @page {
    size: landscape;
    margin: 6mm;
  }

  /* Isolate Studio Modal: hide ALL other body siblings unconditionally */
  body.studio-printing > *:not(#modal-planner-studio) {
    display: none !important;
  }

  html.studio-printing,
  body.studio-printing {
    background: #ffffff !important;
    color: #000000 !important;
    margin: 0 !important;
    padding: 0 !important;
    width: 100% !important;
    height: 100% !important;
    max-height: 100% !important;
    overflow: hidden !important;
  }

  body.studio-printing * {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  body.studio-printing #modal-planner-studio {
    display: block !important;
    position: static !important;
    inset: auto !important;
    background: transparent !important;
    backdrop-filter: none !important;
    padding: 0 !important;
    margin: 0 !important;
    width: 100% !important;
    height: 100% !important;
    max-height: 100% !important;
    overflow: hidden !important;
    border: none !important;
    box-shadow: none !important;
    z-index: auto !important;
    page-break-before: avoid !important;
    page-break-after: avoid !important;
    page-break-inside: avoid !important;
    break-before: avoid !important;
    break-after: avoid !important;
    break-inside: avoid !important;
  }

  body.studio-printing .studio-modal-window {
    background: #ffffff !important;
    border: none !important;
    box-shadow: none !important;
    width: 100% !important;
    max-width: 100% !important;
    height: 100% !important;
    max-height: 100% !important;
    border-radius: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    page-break-after: avoid !important;
    break-after: avoid !important;
  }

  body.studio-printing .studio-modal-header,
  body.studio-printing .studio-mobile-tabs,
  body.studio-printing .studio-controls-pane,
  body.studio-printing .studio-modal-footer,
  body.studio-printing .studio-mobile-preview-prompt {
    display: none !important;
  }

  body.studio-printing .studio-modal-body {
    display: flex !important;
    flex-direction: column !important;
    justify-content: flex-start !important;
    align-items: flex-start !important;
    flex: 1 1 auto !important;
    overflow: hidden !important;
    width: 100% !important;
    height: 100% !important;
    max-height: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    page-break-after: avoid !important;
    break-after: avoid !important;
  }

  body.studio-printing .studio-preview-pane {
    background: transparent !important;
    padding: 0 !important;
    margin: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: flex-start !important;
    align-items: flex-start !important;
    flex: 1 1 auto !important;
    overflow: hidden !important;
    width: 100% !important;
    height: 100% !important;
    max-height: 100% !important;
    page-break-after: avoid !important;
    break-after: avoid !important;
  }

  body.studio-printing .studio-sheet-content {
    display: flex !important;
    flex-direction: column !important;
    justify-content: flex-start !important;
    align-items: flex-start !important;
    flex: 1 1 auto !important;
    width: 100% !important;
    height: 100% !important;
    max-height: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
    page-break-after: avoid !important;
    break-after: avoid !important;
  }

  body.studio-printing .studio-paper-sheet {
    box-shadow: none !important;
    border: none !important;
    border-radius: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    min-height: 0 !important;
    height: auto !important;
    max-height: 100% !important;
    aspect-ratio: auto !important;
    padding: 0 !important;
    margin: 0 auto !important;
    align-self: flex-start !important;
    justify-content: flex-start !important;
    overflow: hidden !important;
    page-break-before: avoid !important;
    page-break-inside: avoid !important;
    page-break-after: avoid !important;
    break-before: avoid !important;
    break-inside: avoid !important;
    break-after: avoid !important;
    display: flex !important;
    flex-direction: column !important;
  }

  body.studio-printing .preview-grid-wrapper {
    flex: 1 1 0% !important;
    overflow: hidden !important;
    display: flex !important;
    height: 100% !important;
    max-height: 100% !important;
    min-height: 0 !important;
  }

  body.studio-printing .preview-calendar-table {
    width: 100% !important;
    height: 100% !important;
    border-collapse: collapse !important;
    table-layout: fixed !important;
  }

  /* --- 1-Month Calendar Grid Print Rules (Single Page Fit) --- */
  body.studio-printing .sheet-month-grid {
    height: 100% !important;
    max-height: 100% !important;
    min-height: 0 !important;
    width: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  body.studio-printing .sheet-month-grid .preview-cell {
    min-height: 0 !important;
    height: auto !important;
    padding: 1.5px 3px !important;
    box-sizing: border-box !important;
  }

  body.studio-printing .sheet-month-grid tr {
    min-height: 0 !important;
  }

  body.studio-printing .sheet-month-grid .preview-slack-pill {
    padding: 1px 3px !important;
    font-size: 7.5px !important;
  }

  body.studio-printing .sheet-month-grid .pill-month-3col .preview-seg {
    padding: 0.5px 1.5px !important;
    font-size: 6px !important;
  }

  body.studio-printing .sheet-month-grid .month-wreck-row {
    margin-top: 0.5px !important;
    gap: 2px !important;
  }

  body.studio-printing .sheet-month-grid .month-wreck-badge {
    font-size: 6.5px !important;
    padding: 0 2px !important;
  }

  /* Micro-scale print rules for dense multi-wreck month grid (ensures 10 wrecks across 5/6 weeks fit on single A4 sheet) */
  body.studio-printing .sheet-month-grid.month-dense-multi .preview-cell {
    padding: 0.5px 1.5px !important;
  }
  body.studio-printing .sheet-month-grid.month-dense-multi .preview-slack-pill {
    padding: 0.5px 1.5px !important;
    font-size: 5.8px !important;
    line-height: 1 !important;
  }
  body.studio-printing .sheet-month-grid.month-dense-multi .pill-month-3col .preview-seg {
    padding: 0 1px !important;
    font-size: 5.2px !important;
    line-height: 1 !important;
  }
  body.studio-printing .sheet-month-grid.month-dense-multi .month-wreck-row {
    margin-top: 0 !important;
    gap: 1px !important;
  }
  body.studio-printing .sheet-month-grid.month-dense-multi .month-wreck-badge {
    font-size: 5.2px !important;
    padding: 0 1px !important;
    line-height: 1 !important;
    min-width: 8px !important;
  }
  body.studio-printing .sheet-month-grid.month-dense-multi .preview-th {
    height: 13px !important;
    font-size: 7px !important;
    padding: 1px 0 !important;
  }
  body.studio-printing .sheet-month-grid.month-dense-multi .preview-sheet-header {
    padding: 3px 8px !important;
    margin-bottom: 2px !important;
  }
  body.studio-printing .sheet-month-grid.month-dense-multi .month-wreck-legend {
    padding: 1.5px 4px !important;
    gap: 3px 8px !important;
    font-size: 6.5px !important;
  }

  /* --- Trip Manifest Print Row & Cell Rules: fit 100% of single page without overflow --- */
  body.studio-printing .sheet-trip {
    height: 100% !important;
    max-height: 100% !important;
    min-height: 0 !important;
    width: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  body.studio-printing .sheet-trip .preview-cell {
    min-height: 0 !important;
    height: auto !important;
  }

  body.studio-printing .sheet-trip tr {
    min-height: 0 !important;
  }

  /* Compact Mode (7 Days & 14 Days): sits neatly on top of page without forced vertical stretching */
  body.studio-printing .sheet-trip.trip-days-7,
  body.studio-printing .sheet-trip.trip-days-14 {
    height: auto !important;
    max-height: none !important;
  }

  body.studio-printing .sheet-trip.trip-days-7 .preview-grid-wrapper,
  body.studio-printing .sheet-trip.trip-days-14 .preview-grid-wrapper {
    flex: 0 0 auto !important;
    height: auto !important;
    max-height: none !important;
  }

  /* 7-Day Trip Manifest Print Calibration: Balanced uniform row heights & bold deck legibility without browser gap distortion */
  body.studio-printing .sheet-trip.trip-days-7 .preview-calendar-table {
    height: auto !important;
    min-height: 0 !important;
    border-collapse: collapse !important;
  }

  body.studio-printing .sheet-trip.trip-days-7 thead tr {
    height: 12mm !important;
  }

  body.studio-printing .sheet-trip.trip-days-7 tbody tr {
    height: 18mm !important;
    page-break-inside: avoid !important;
    break-inside: avoid !important;
  }

  body.studio-printing .sheet-trip.trip-days-7 .preview-cell {
    height: 18mm !important;
    min-height: 18mm !important;
    padding: 2px 2px !important;
    vertical-align: middle !important;
    box-sizing: border-box !important;
  }

  body.studio-printing .sheet-trip.trip-days-7 .pill-trip-3col {
    height: 100% !important;
    min-height: 32px !important;
    align-items: stretch !important;
  }

  body.studio-printing .sheet-trip.trip-days-7 .preview-seg {
    padding: 2px 2px !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: center !important;
  }

  /* 7-Day Trip Manifest Print Typography - Spacious (<= 4 sites) */
  body.studio-printing .sheet-trip.trip-days-7:not(.sites-dense):not(.sites-medium) .preview-seg span.seg-time,
  body.studio-printing .sheet-trip.trip-days-7:not(.sites-dense):not(.sites-medium) .preview-seg span:first-child {
    font-size: 11.5pt !important;
    font-weight: 700 !important;
    line-height: 1.15 !important;
  }

  body.studio-printing .sheet-trip.trip-days-7:not(.sites-dense):not(.sites-medium) .preview-seg span.seg-speed,
  body.studio-printing .sheet-trip.trip-days-7:not(.sites-dense):not(.sites-medium) .preview-seg span:last-child {
    font-size: 9.5pt !important;
    font-weight: 600 !important;
    line-height: 1.15 !important;
  }

  /* 7-Day Trip Manifest Print Typography - Medium (5-7 sites) */
  body.studio-printing .sheet-trip.trip-days-7.sites-medium .preview-seg span.seg-time,
  body.studio-printing .sheet-trip.trip-days-7.sites-medium .preview-seg span:first-child {
    font-size: 9.5pt !important;
    font-weight: 700 !important;
    line-height: 1.15 !important;
  }

  body.studio-printing .sheet-trip.trip-days-7.sites-medium .preview-seg span.seg-speed,
  body.studio-printing .sheet-trip.trip-days-7.sites-medium .preview-seg span:last-child {
    font-size: 8pt !important;
    font-weight: 600 !important;
    line-height: 1.15 !important;
  }

  /* 7-Day Trip Manifest Print Typography - Dense (8+ sites, e.g. 10 wrecks) */
  body.studio-printing .sheet-trip.sites-dense .preview-seg span.seg-time,
  body.studio-printing .sheet-trip.sites-dense .preview-seg span:first-child,
  body.studio-printing .sheet-trip .pill-trip-dense .preview-seg span.seg-time {
    font-size: 6.8pt !important;
    font-weight: 700 !important;
    line-height: 1.1 !important;
    letter-spacing: -0.3px !important;
  }

  body.studio-printing .sheet-trip.sites-dense .preview-seg span.seg-speed,
  body.studio-printing .sheet-trip.sites-dense .preview-seg span:last-child,
  body.studio-printing .sheet-trip .pill-trip-dense .preview-seg span.seg-speed {
    font-size: 5.8pt !important;
    font-weight: 600 !important;
    line-height: 1.1 !important;
    letter-spacing: -0.2px !important;
  }

  body.studio-printing .sheet-trip.sites-dense .preview-seg,
  body.studio-printing .sheet-trip .pill-trip-dense .preview-seg {
    padding: 1px 1px !important;
  }

  body.studio-printing .sheet-trip.trip-days-7 .preview-slack-pill {
    padding: 4px 8px !important;
    font-size: 12pt !important;
    font-weight: 700 !important;
  }

  /* 14-Day Trip Manifest Print Calibration */
  body.studio-printing .sheet-trip.trip-days-14 .preview-calendar-table {
    height: auto !important;
    min-height: 0 !important;
    border-collapse: collapse !important;
  }

  body.studio-printing .sheet-trip.trip-days-14 thead tr {
    height: 8mm !important;
  }

  body.studio-printing .sheet-trip.trip-days-14 tbody tr {
    height: 8.5mm !important;
    page-break-inside: avoid !important;
    break-inside: avoid !important;
  }

  body.studio-printing .sheet-trip.trip-days-14 .preview-cell {
    height: 100% !important;
    min-height: 25px !important;
    padding: 2px 3px !important;
    vertical-align: middle !important;
  }

  body.studio-printing .sheet-trip.trip-days-14 .pill-trip-3col {
    height: 100% !important;
    min-height: 22px !important;
    align-items: stretch !important;
  }

  body.studio-printing .sheet-trip.trip-days-14 .preview-seg span.seg-time,
  body.studio-printing .sheet-trip.trip-days-14 .preview-seg span:first-child {
    font-size: 9.5pt !important;
    font-weight: 700 !important;
    line-height: 1.15 !important;
  }

  body.studio-printing .sheet-trip.trip-days-14 .preview-seg span.seg-speed,
  body.studio-printing .sheet-trip.trip-days-14 .preview-seg span:last-child {
    font-size: 8pt !important;
    font-weight: 600 !important;
    line-height: 1.15 !important;
  }

  body.studio-printing .sheet-trip.trip-days-14 .preview-slack-pill {
    padding: 2.5px 6px !important;
    font-size: 10pt !important;
  }

  body.studio-printing .sheet-trip.trip-days-30 .pill-trip-3col .preview-seg,
  body.studio-printing .sheet-trip.trip-days-1month .pill-trip-3col .preview-seg {
    padding: 0.5px 1.5px !important;
    font-size: 5.5px !important;
  }

  body.studio-printing .sheet-trip.trip-days-30 .preview-cell,
  body.studio-printing .sheet-trip.trip-days-1month .preview-cell {
    height: calc((100% - 20px) / 31) !important;
    min-height: 0 !important;
    padding: 0.5px 2px !important;
  }

  body.studio-printing .sheet-trip.trip-days-30 .preview-slack-pill,
  body.studio-printing .sheet-trip.trip-days-1month .preview-slack-pill {
    padding: 1px 4px !important;
    font-size: 8pt !important;
  }

  /* --- Linear / Annual Calendars --- */
  body.studio-printing .sheet-linear .preview-cell {
    height: calc((100% - 16px) / 31) !important;
    min-height: 0 !important;
    padding: 0 1px !important;
    font-size: 5.5px !important;
  }

  body.studio-printing .sheet-day-aligned .preview-cell {
    height: calc((100% - 16px) / 37) !important;
    min-height: 0 !important;
    padding: 0 1px !important;
    font-size: 5px !important;
  }

  /* Data-group page break protection: ensure individual days and wreck records stay intact */
  body.studio-printing tr,
  body.studio-printing .preview-row,
  body.studio-printing .preview-cell,
  body.studio-printing .month-wreck-row,
  body.studio-printing .preview-slack-pill {
    page-break-inside: avoid !important;
    break-inside: avoid !important;
  }

  body.studio-printing .preview-sheet-footer {
    width: 100% !important;
    text-align: center !important;
    margin-top: 4mm !important;
    font-size: 6.5pt !important;
    color: #64748b !important;
    display: block !important;
  }
}

/* =========================================================================
   MULTI-SITE ANNUAL MATRIX STYLES
   ========================================================================= */
.format-annual_matrix .preview-calendar-table {
  table-layout: fixed;
  width: 100%;
  border-collapse: collapse;
}

.matrix-legend-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 5px 8px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  padding: 4px 8px;
  margin-bottom: 5px;
  font-size: 6px;
  align-items: center;
}

.matrix-legend-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 6px;
  flex: 1 1 auto;
}

.matrix-legend-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 3px;
  padding: 1px 4px;
  white-space: nowrap;
  font-size: 5.5px;
}

.matrix-chip-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 11px;
  height: 11px;
  background: #0284c7;
  color: #ffffff;
  font-weight: 800;
  font-size: 5px;
  border-radius: 2px;
}

.matrix-chip-name {
  font-weight: 700;
  color: #0f172a;
}

.matrix-chip-meta {
  color: #64748b;
  font-size: 5px;
}

.matrix-legend-scale {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 5.5px;
  color: #334155;
  margin-left: auto;
  white-space: nowrap;
}

.matrix-subth-row {
  display: flex;
  height: 9px;
  background: #1e3a5f;
  border-top: 1px solid rgba(255, 255, 255, 0.2);
  align-items: center;
}

.matrix-subth-gutter {
  flex: 0 0 24px;
  width: 24px;
  min-width: 24px;
  max-width: 24px;
}

.matrix-subth-sites {
  flex: 1 1 auto;
  display: flex;
  height: 100%;
}

.matrix-subth-site {
  flex: 1 1 0;
  text-align: center;
  color: #93c5fd;
  font-size: 4.8px;
  font-weight: 700;
  line-height: 9px;
}

.preview-matrix-cell {
  padding: 0;
  height: 100%;
  box-sizing: border-box;
}

.matrix-cell-content {
  display: flex;
  height: 100%;
  width: 100%;
  align-items: stretch;
}

.matrix-date-gutter {
  flex: 0 0 24px;
  width: 24px;
  min-width: 24px;
  max-width: 24px;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  gap: 0.5px;
  padding: 0 1px;
  font-size: 4.8px;
  white-space: nowrap;
  line-height: 1;
  border-right: 1px solid #f1f5f9;
  overflow: hidden;
}

.matrix-date-gutter .m-day {
  font-weight: 700;
  color: #0f172a;
}

.matrix-date-gutter .m-dow {
  font-size: 4.2px;
  color: #64748b;
  margin-left: 0.5px;
}

.matrix-stripes-container {
  flex: 1 1 auto;
  display: flex;
  gap: 0.4px;
  height: 100%;
  padding: 0.5px 0.5px;
  box-sizing: border-box;
  align-items: stretch;
}

.matrix-stripe {
  flex: 1 1 0;
  min-width: 1px;
  height: 100%;
  border-radius: 0.4px;
  transition: transform 0.1s ease;
  cursor: pointer;
}

.matrix-stripe:hover {
  transform: scaleY(1.3);
  z-index: 10;
  box-shadow: 0 0 2px rgba(0,0,0,0.4);
}

/* Planner Studio Annual Help Popup */
#studio-annual-help-popup.hidden {
  display: none !important;
}

.studio-help-circle-btn:hover {
  background: var(--accent, #38bdf8) !important;
  color: #0f172a !important;
}
