/* ===== 古纸风格主题 ===== */
:root {
  --paper-light: #f5e6c8;
  --paper-mid: #e8d4a8;
  --paper-dark: #c9a96e;
  --paper-edge: #a08050;
  --ink: #3d2b1f;
  --ink-light: #6b4c35;
  --ink-faded: #9a7b5a;
  --accent: #8b4513;
  --accent-hover: #a0522d;
  --danger: #8b2500;
  --danger-hover: #a03010;
  --shadow: rgba(61, 43, 31, 0.25);
  --selected-row: rgba(139, 69, 19, 0.15);
  --font-serif: "Noto Serif SC", "Georgia", "SimSun", serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  height: 100%;
}

body {
  font-family: var(--font-serif);
  color: var(--ink);
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background-color: #2a1f14;
  background-image:
    radial-gradient(ellipse at 20% 50%, rgba(80, 60, 30, 0.4) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 20%, rgba(60, 45, 20, 0.3) 0%, transparent 50%);
}

/* ===== 页头 ===== */
.app-header {
  flex-shrink: 0;
  text-align: center;
  padding: 18px 20px 14px;
  background: linear-gradient(180deg, #3d2b1f 0%, #2a1f14 100%);
  border-bottom: 3px double var(--paper-dark);
  position: relative;
}

.app-header-inner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  position: relative;
}

.app-header-titles {
  flex: 1;
  text-align: center;
  min-width: 0;
}

.btn-quit {
  flex-shrink: 0;
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  background: linear-gradient(180deg, #a84838 0%, #7a2418 100%);
  color: var(--paper-light);
  border: 1px solid #5a1810;
  padding: 8px 14px;
  font-size: 0.85rem;
  letter-spacing: 0.06em;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
}

.btn-quit:hover {
  background: linear-gradient(180deg, #c06048 0%, #8a2c1c 100%);
}

.app-header::after {
  content: "";
  position: absolute;
  bottom: -6px;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, transparent, var(--paper-dark), transparent);
}

.app-header h1 {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--paper-light);
  letter-spacing: 0.15em;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.subtitle {
  font-size: 0.85rem;
  color: var(--paper-dark);
  margin-top: 4px;
  letter-spacing: 0.08em;
}

/* ===== 主布局 ===== */
.app-main {
  flex: 1;
  min-height: 0;
  display: flex;
  gap: 16px;
  padding: 16px;
  width: 100%;
}

/* ===== 面板通用 ===== */
.panel {
  background-color: var(--paper-light);
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='400' height='400'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='4' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='400' height='400' filter='url(%23n)' opacity='0.08'/%3E%3C/svg%3E"),
    linear-gradient(135deg, var(--paper-light) 0%, var(--paper-mid) 50%, #dcc99a 100%);
  border: 2px solid var(--paper-edge);
  border-radius: 4px;
  box-shadow:
    0 4px 16px var(--shadow),
    inset 0 0 30px rgba(160, 128, 80, 0.15);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.panel-table {
  flex: 0.618 1 0;
  min-width: 0;
  min-height: 0;
}

.app-main-single {
  padding: 16px;
}

.app-main-single .panel-standalone {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
}

.window-body {
  height: 100%;
}

.app-header-compact {
  padding: 12px 16px 10px;
}

.app-header-compact h1 {
  font-size: 1.25rem;
  letter-spacing: 0.1em;
}

.app-header-compact .subtitle {
  font-size: 0.78rem;
  margin-top: 2px;
}

.panel-side {
  flex: 0.382 1 0;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: transparent;
  border: none;
  box-shadow: none;
  overflow: hidden;
}

.panel-side > .panel {
  flex: 1;
  min-height: 0;
}

.panel-z {
  flex: 0 0 38%;
  max-height: 42%;
}

.panel-z.panel-standalone {
  flex: 1 1 auto;
  max-height: none;
}

.panel-images {
  flex: 1 1 auto;
  min-height: 0;
}

/* ===== 云端双栏只读 ===== */
.cloud-web-main {
  gap: 12px;
  padding: 12px 16px 16px;
}

.cloud-web-left {
  flex: 0.38 1 0;
  min-width: 260px;
}

.cloud-web-right {
  flex: 0.62 1 0;
}

.cloud-web-header .app-header-inner {
  align-items: center;
}

.cloud-web .btn-delete-img,
.cloud-web .btn-upload {
  display: none !important;
}

@media (max-width: 900px) {
  .cloud-web-main {
    flex-direction: column;
  }

  .cloud-web-left,
  .cloud-web-right {
    flex: 1 1 auto;
    min-height: 40vh;
  }
}

.layer-controls {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.layer-badge {
  display: inline-block;
  box-sizing: border-box;
  width: 11.5rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.35);
  border: 1px solid var(--paper-edge);
  border-radius: 3px;
  padding: 4px 10px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: default;
  user-select: none;
  text-align: left;
}

.btn-layer {
  min-width: 2rem;
  padding: 4px 8px;
  font-size: 0.85rem;
  line-height: 1.2;
}

.layer-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.z-compare-scroll {
  flex: 1 1 auto;
  min-height: 0;
  position: relative;
}

#compare-table {
  width: max-content;
  min-width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
  display: none;
}

#compare-table .col-header {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--paper-mid);
  font-weight: 600;
  padding: 8px 10px;
  border: 1px solid rgba(160, 128, 80, 0.5);
  text-align: center;
  box-sizing: border-box;
}

#compare-table .compare-time-col {
  text-align: center;
}

#compare-table td.data-col.col-align-left,
#compare-table .cell-input.col-align-left {
  text-align: left;
}

#compare-table .compare-time-input:not(.col-align-left) {
  text-align: center;
}

#compare-table .compare-readonly {
  cursor: pointer;
  user-select: text;
  caret-color: transparent;
  outline: none;
}

#compare-table .compare-time-input.compare-readonly {
  cursor: default;
}

#compare-table td.data-col {
  border: 1px solid rgba(160, 128, 80, 0.5);
  padding: 0;
  vertical-align: top;
  box-sizing: border-box;
  overflow: hidden;
  background-color: #f3e6c4;
}

#compare-table td.compare-merged-cell {
  vertical-align: middle;
  background-color: #efe0b8;
  box-shadow: inset 0 0 0 1px rgba(139, 69, 19, 0.35);
}

#compare-table .compare-active-layer {
  background: rgba(139, 69, 19, 0.08);
}

#compare-table td.compare-merged-cell.compare-active-layer {
  background: #e8d4a0;
}

#compare-table tr.compare-highlight-row td {
  box-shadow: inset 0 0 0 1px rgba(139, 69, 19, 0.45);
}

#compare-table td.compare-scroll-flash,
#compare-table tr.compare-scroll-flash td {
  animation: compare-scroll-flash 0.7s ease;
}

@keyframes compare-scroll-flash {
  0% {
    background-color: #dfc492;
  }
  100% {
    background-color: transparent;
  }
}

.compare-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 180px;
  color: var(--ink-faded);
  gap: 6px;
  padding: 24px;
  text-align: center;
}

.compare-empty .empty-sub {
  font-size: 0.78rem;
  opacity: 0.85;
}

.layer-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  border: 1px solid rgba(160, 128, 80, 0.45);
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.2);
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}

.layer-item:hover {
  background: rgba(255, 255, 255, 0.35);
}

.layer-item.active {
  background: var(--selected-row);
  border-color: var(--accent);
  outline: 1px solid var(--accent);
}

.layer-item-index {
  font-size: 0.72rem;
  color: var(--ink-faded);
  min-width: 1.2em;
}

.layer-item-input {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  font-family: var(--font-serif);
  font-size: 0.85rem;
  color: var(--ink);
  outline: none;
  padding: 2px 4px;
}

.layer-item-input:focus {
  background: rgba(255, 255, 255, 0.35);
  border-radius: 2px;
}

.hint-compact {
  font-size: 0.72rem;
  padding: 4px 10px 8px;
}

.col-header-fixed {
  display: block;
  width: 100%;
  padding: 8px 10px;
  font-weight: 600;
  text-align: center;
}

#history-table thead th.col-header-fixed-cell {
  cursor: default;
}

#history-table thead th.col-header-fixed-cell .col-resizer {
  cursor: col-resize;
}

.panel-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 12px;
  background: linear-gradient(180deg, rgba(201, 169, 110, 0.4) 0%, rgba(201, 169, 110, 0.15) 100%);
  border-bottom: 1px solid var(--paper-dark);
  flex-shrink: 0;
}

.toolbar-right {
  margin-left: auto;
}

.toolbar-divider {
  width: 1px;
  height: 22px;
  background: rgba(160, 128, 80, 0.55);
  margin: 0 2px;
  flex-shrink: 0;
}

/* ===== Unicode 图标插入面板 ===== */
.icon-insert-wrap {
  position: relative;
  display: inline-flex;
}

.icon-picker {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 40;
  width: min(420px, 80vw);
  max-height: 360px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: #f7f0e4;
  border: 1px solid var(--paper-edge);
  box-shadow: 0 10px 28px rgba(40, 28, 12, 0.28);
  padding: 8px;
}

.icon-picker[hidden] {
  display: none !important;
}

.icon-picker-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 8px;
}

.icon-tab {
  font-family: var(--font-serif);
  font-size: 0.78rem;
  padding: 4px 10px;
  border: 1px solid var(--paper-edge);
  background: rgba(255, 255, 255, 0.45);
  color: var(--ink);
  cursor: pointer;
}

.icon-tab.active {
  background: linear-gradient(180deg, #c9a96e 0%, #a08050 100%);
  color: var(--paper-light);
  border-color: #8a6a38;
}

.icon-picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(44px, 1fr));
  gap: 4px;
  overflow-y: auto;
  max-height: 260px;
  padding-right: 2px;
}

.icon-btn {
  display: grid;
  place-items: center;
  min-height: 40px;
  border: 1px solid rgba(160, 128, 80, 0.35);
  background: rgba(255, 255, 255, 0.55);
  cursor: pointer;
  font-size: 1.25rem;
  line-height: 1;
  padding: 4px;
  transition: background 0.12s, transform 0.12s;
}

.icon-btn:hover {
  background: rgba(201, 169, 110, 0.35);
  transform: translateY(-1px);
}

.icon-picker-hint {
  margin: 8px 0 0;
  font-size: 0.72rem;
  color: var(--ink-light);
}

.row-label {
  font-size: 0.9rem;
  color: var(--ink-light);
  font-weight: 600;
}

/* ===== 按钮 ===== */
.btn {
  font-family: var(--font-serif);
  font-size: 0.82rem;
  padding: 5px 12px;
  border: 1px solid var(--paper-edge);
  border-radius: 3px;
  cursor: pointer;
  transition: all 0.15s;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-primary {
  background: linear-gradient(180deg, #c9a96e 0%, #a08050 100%);
  color: var(--paper-light);
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.3);
}

.btn-primary:not(:disabled):hover {
  background: linear-gradient(180deg, var(--accent-hover) 0%, var(--accent) 100%);
}

.btn-danger {
  background: linear-gradient(180deg, #c06040 0%, var(--danger) 100%);
  color: var(--paper-light);
}

.btn-danger:not(:disabled):hover {
  background: linear-gradient(180deg, var(--danger-hover) 0%, #701800 100%);
}

.btn-upload {
  display: inline-block;
  cursor: pointer;
}

.btn-upload.disabled {
  opacity: 0.4;
  pointer-events: none;
}

/* ===== 搜索替换 ===== */
.search-label {
  font-size: 0.8rem;
  color: var(--ink-light);
  white-space: nowrap;
}

.search-input {
  font-family: var(--font-serif);
  font-size: 0.82rem;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.35);
  border: 1px solid var(--paper-edge);
  border-radius: 3px;
  padding: 4px 8px;
  width: 110px;
  outline: none;
}

.search-input:focus {
  background: rgba(255, 255, 255, 0.55);
  border-color: var(--accent);
}

.search-status {
  font-size: 0.78rem;
  color: var(--ink-faded);
  white-space: nowrap;
}

/* 查找命中：高亮匹配文字本身（临时 mark，不落库） */
.col-header-input.search-hit {
  background: rgba(255, 90, 90, 0.28);
}

.col-header-input.search-hit-current {
  background: rgba(220, 40, 40, 0.42);
}

.cell-input mark.search-mark,
.cell-input mark.cell-mark mark.search-mark {
  background: rgba(255, 90, 90, 0.42) !important;
  color: inherit;
  border-radius: 2px;
  padding: 0 1px;
  box-shadow: inset 0 0 0 1px rgba(198, 40, 40, 0.55);
}

.cell-input mark.search-mark.search-mark-current,
.cell-input mark.cell-mark mark.search-mark.search-mark-current {
  background: rgba(220, 40, 40, 0.58) !important;
  box-shadow: inset 0 0 0 1.5px #b71c1c;
}

/* ===== 表格 ===== */
.table-scroll {
  flex: 1;
  overflow: auto;
  padding: 8px;
}

#history-table {
  table-layout: fixed;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.88rem;
}

#history-table thead th {
  background: linear-gradient(180deg, #c9a96e 0%, #b09060 100%);
  color: var(--ink);
  font-weight: 600;
  padding: 0;
  border: 1px solid var(--paper-edge);
  position: sticky;
  top: 0;
  z-index: 2;
  text-align: center;
  vertical-align: middle;
}

#history-table thead th.col-header {
  position: sticky;
  overflow: hidden;
  min-width: 0;
  cursor: pointer;
}

/* 冻结第一列（时间）表头：左右滚动时始终可见 */
#history-table thead th.time-col {
  left: 0;
  z-index: 5;
  background: linear-gradient(180deg, #c9a96e 0%, #b09060 100%);
  box-shadow: 3px 0 6px rgba(61, 43, 31, 0.18);
}

#history-table thead th.col-header.align-target-col {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

#history-table tbody td.align-target-cell {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

#history-table tbody td.selection-cell {
  background: rgba(139, 69, 19, 0.12);
  box-shadow: inset 0 0 0 1px rgba(160, 100, 50, 0.55);
}

#history-table tbody td.merged-cell {
  background: rgba(255, 255, 255, 0.08);
}

.align-target-label {
  font-size: 0.78rem;
  color: var(--ink-faded);
  white-space: nowrap;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.col-header-input {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  background: transparent;
  border: none;
  font-family: var(--font-serif);
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--ink);
  padding: 8px 10px;
  text-align: center;
  outline: none;
}

.col-header-input:focus {
  background: rgba(255, 255, 255, 0.2);
}

.col-resizer {
  position: absolute;
  right: -3px;
  top: 0;
  width: 7px;
  height: 100%;
  cursor: col-resize;
  z-index: 4;
  user-select: none;
}

.col-resizer:hover,
body.col-resizing .col-resizer {
  background: rgba(139, 69, 19, 0.45);
}

body.col-resizing {
  cursor: col-resize;
  user-select: none;
}

body.col-resizing * {
  cursor: col-resize !important;
}

#history-table tbody td {
  border: 1px solid rgba(160, 128, 80, 0.5);
  padding: 0;
  vertical-align: top;
  text-align: center;
  overflow: hidden;
  min-width: 0;
  height: 1px;
  cursor: pointer;
  transition: background 0.12s;
  user-select: none;
}

#history-table tbody td:hover:not(.selection-cell):not(.align-target-cell):not(.time-range-highlight) {
  background: rgba(139, 69, 19, 0.08);
}

#history-table tbody td.data-col {
  position: relative;
  overflow: hidden;
}

/* 必须盖过 data-col 的 position:relative，否则时间列无法横向冻结 */
#history-table tbody td.data-col.time-col {
  position: sticky;
  left: 0;
  z-index: 3;
  background-color: #f0ddb8;
  background-image: linear-gradient(180deg, #f3e2c0 0%, #edd6a8 100%);
  box-shadow: 3px 0 6px rgba(61, 43, 31, 0.14);
  vertical-align: middle;
}

#history-table tbody td.data-col.time-col.selection-cell {
  background: #e8d0a0;
  background-image: none;
  box-shadow:
    inset 0 0 0 1px rgba(160, 100, 50, 0.55),
    3px 0 6px rgba(61, 43, 31, 0.14);
}

#history-table tbody td.data-col.time-col:hover:not(.selection-cell):not(.align-target-cell):not(.time-range-highlight) {
  background: #e6d0a0;
  background-image: none;
}

/* 选中地区格时，对应时间列行范围高亮 */
#history-table tbody td.data-col.time-col.time-range-highlight {
  background: #dfc492;
  background-image: none;
  box-shadow:
    inset 0 0 0 1px rgba(139, 69, 19, 0.35),
    3px 0 6px rgba(61, 43, 31, 0.14);
}

#history-table tbody td.data-col.time-col.time-range-highlight .cell-input {
  font-weight: inherit;
  color: inherit;
}

/* 时间列：行高被其他列撑高时，文字上下居中 */
#compare-table td.compare-time-col {
  vertical-align: middle;
}

.cell-input {
  display: block;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 36px;
  box-sizing: border-box;
  background: transparent;
  border: none;
  font-family: var(--font-serif);
  font-size: 0.88rem;
  color: var(--ink);
  padding: 6px 10px;
  resize: none;
  outline: none;
  line-height: 1.5;
  overflow: hidden;
  word-break: break-word;
  overflow-wrap: break-word;
  text-align: center;
  user-select: text;
  white-space: pre-wrap;
  cursor: default;
}

.cell-input[contenteditable="true"],
.cell-input.cell-editing {
  cursor: text;
}

.cell-input:focus {
  background: rgba(255, 255, 255, 0.18);
  box-shadow: inset 0 0 0 1px rgba(139, 105, 20, 0.35);
}

.cell-input.cell-editing:focus {
  background: rgba(255, 255, 255, 0.35);
  box-shadow: inset 0 0 0 2px var(--accent);
}

#btn-edit-cell.btn-editing-active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

#history-table .cell-input.time-col-input,
#compare-table .compare-time-input {
  height: auto;
}

/* 列对齐：左对齐 */
#history-table th.col-align-left,
#history-table td.col-align-left {
  text-align: left;
}

.col-header-input.col-align-left,
.cell-input.col-align-left {
  text-align: left;
}

/* 加粗 / 高亮（选中文字） */
.cell-input b,
.cell-input strong {
  font-weight: 700;
}

.cell-input mark.cell-mark {
  color: inherit;
  border-radius: 2px;
  padding: 0 1px;
  background: rgba(255, 214, 102, 0.72);
}

.cell-input mark.cell-mark-yellow { background: rgba(255, 214, 102, 0.78); }
.cell-input mark.cell-mark-orange { background: rgba(255, 170, 90, 0.78); }
.cell-input mark.cell-mark-green { background: rgba(140, 210, 140, 0.75); }
.cell-input mark.cell-mark-blue { background: rgba(140, 190, 235, 0.78); }
.cell-input mark.cell-mark-purple { background: rgba(190, 160, 225, 0.78); }
.cell-input mark.cell-mark-pink { background: rgba(245, 160, 180, 0.78); }
.cell-input mark.cell-mark-gray { background: rgba(190, 185, 175, 0.88); }
/* 旧数据 cell-mark-red 按粉色显示，红色专供查找命中 */
.cell-input mark.cell-mark-red { background: rgba(245, 160, 180, 0.78); }

/* 高亮色板 */
.highlight-wrap {
  position: relative;
  display: inline-flex;
}

.highlight-picker {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 41;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  width: max-content;
  max-width: min(280px, 80vw);
  padding: 8px;
  background: #f7f0e4;
  border: 1px solid var(--paper-edge);
  box-shadow: 0 10px 28px rgba(40, 28, 12, 0.28);
}

.highlight-picker[hidden] {
  display: none !important;
}

.highlight-swatch {
  width: 28px;
  height: 28px;
  border: 1px solid rgba(80, 60, 30, 0.35);
  border-radius: 3px;
  cursor: pointer;
  padding: 0;
}

.highlight-swatch:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(40, 28, 12, 0.2);
}

.highlight-swatch.active {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.highlight-clear {
  font-family: var(--font-serif);
  font-size: 0.75rem;
  padding: 0 8px;
  height: 28px;
  border: 1px solid var(--paper-edge);
  background: rgba(255, 255, 255, 0.55);
  color: var(--ink);
  cursor: pointer;
}

.btn.is-active {
  box-shadow: inset 0 0 0 2px var(--accent);
  background: rgba(180, 140, 60, 0.25);
}

.hint {
  font-size: 0.75rem;
  color: var(--ink-faded);
  padding: 6px 12px 8px;
  border-top: 1px solid rgba(160, 128, 80, 0.3);
  flex-shrink: 0;
  font-style: italic;
}

/* ===== 图片区域 ===== */
.image-gallery {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: auto;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
  overscroll-behavior: contain;
}

.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--ink-faded);
  text-align: center;
  padding: 40px 20px;
}

.image-gallery > .empty-state {
  align-self: stretch;
  width: 100%;
}

.empty-icon {
  font-size: 3rem;
  margin-bottom: 12px;
  opacity: 0.6;
}

.empty-sub {
  font-size: 0.8rem;
  margin-top: 4px;
  font-style: italic;
}

.image-card {
  position: relative;
  flex: 0 0 auto;
  width: max-content;
  max-width: none;
  margin-inline: auto;
  border: 2px solid var(--paper-edge);
  border-radius: 3px;
  overflow: visible;
  background: rgba(255, 255, 255, 0.3);
  box-shadow: 0 2px 8px var(--shadow);
}

.image-card img {
  display: block;
  width: auto;
  height: auto;
  max-width: none;
  max-height: none;
  background: rgba(255, 255, 255, 0.5);
}

.image-card .btn-delete-img {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid var(--danger);
  background: rgba(139, 37, 0, 0.85);
  color: white;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.15s;
  line-height: 1;
}

.image-card:hover .btn-delete-img {
  opacity: 1;
}

.image-card .btn-delete-img:hover {
  background: var(--danger-hover);
}

/* ===== 滚动条 ===== */
.table-scroll::-webkit-scrollbar,
.image-gallery::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.table-scroll::-webkit-scrollbar-track,
.image-gallery::-webkit-scrollbar-track {
  background: rgba(160, 128, 80, 0.15);
}

.table-scroll::-webkit-scrollbar-thumb,
.image-gallery::-webkit-scrollbar-thumb {
  background: var(--paper-dark);
  border-radius: 4px;
}

/* ===== 响应式 ===== */
@media (max-width: 768px) {
  body {
    overflow: auto;
  }

  .app-main {
    flex-direction: column;
    flex: none;
    min-height: calc(100vh - 90px);
  }

  .panel-table,
  .panel-images {
    flex: 1 1 auto;
    min-height: 280px;
  }

  .image-card img {
    max-width: none;
    max-height: none;
  }
}

/* ---------- 世界地图窗口 ---------- */
.map-window .panel-world-map {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.map-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.map-toolbar-actions a.btn.disabled {
  pointer-events: none;
  opacity: 0.45;
}

.world-map-frame-wrap {
  flex: 1 1 auto;
  min-height: 0;
  position: relative;
  border: 1px solid rgba(160, 128, 80, 0.45);
  background: #ebe1c8;
  overflow: hidden;
}

.world-map-frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  background: #d8c9a4;
}

.world-map-empty {
  position: absolute;
  inset: 0;
  z-index: 1;
  background: #f3e6c4;
}

.map-toolbar-main {
  flex-wrap: wrap;
  gap: 8px;
}

.map-provider-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  color: var(--ink-faded, #6b5a3e);
}

.map-provider-select {
  max-width: 220px;
  padding: 4px 8px;
  border: 1px solid rgba(160, 128, 80, 0.55);
  background: #f7efd8;
  color: inherit;
  font: inherit;
}

.map-playback-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  border-top: 1px solid rgba(160, 128, 80, 0.25);
  padding-top: 8px;
}

.map-playback-bar .btn {
  min-width: 2.2rem;
  padding: 4px 10px;
}

.map-year-slider {
  flex: 1 1 160px;
  min-width: 120px;
  accent-color: #8b4513;
}

.map-year-now {
  min-width: 7.5em;
  font-size: 0.88rem;
  font-variant-numeric: tabular-nums;
  color: var(--ink, #3a2f1c);
}

.world-map-image-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    linear-gradient(180deg, rgba(243, 230, 196, 0.35), rgba(232, 214, 168, 0.55)),
    #d9c9a3;
  overflow: auto;
}

.world-map-image {
  display: block;
  width: 100%;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  aspect-ratio: 2 / 1;
  object-fit: contain;
  object-position: center;
  image-rendering: auto;
  box-shadow: 0 0 0 1px rgba(120, 100, 70, 0.35);
  background: #a4c9e0;
}

.map-status {
  font-size: 0.78rem;
  color: var(--ink-faded, #6b5a3e);
  white-space: nowrap;
}

.world-map-body {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  gap: 10px;
  align-items: stretch;
}

.world-map-body .world-map-image-wrap {
  flex: 1 1 auto;
  min-width: 0;
}

.map-legend {
  flex: 0 0 220px;
  max-width: 260px;
  min-width: 180px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  border: 1px solid rgba(160, 128, 80, 0.45);
  background: #f7efd8;
  padding: 8px 10px;
  box-sizing: border-box;
}

.map-legend-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 0.92rem;
}

.map-legend-count {
  font-size: 0.75rem;
  color: var(--ink-faded, #6b5a3e);
}

.map-legend-subhead {
  margin: 8px 0 4px;
  font-size: 0.78rem;
  color: var(--ink-faded, #6b5a3e);
}

.map-legend-list {
  overflow: auto;
  min-height: 0;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-right: 2px;
}

.map-legend-base {
  flex: 0 0 auto;
  max-height: none;
  overflow: visible;
  padding-bottom: 4px;
  border-bottom: 1px dashed rgba(160, 128, 80, 0.35);
}

.map-legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  line-height: 1.25;
}

.map-legend-swatch {
  flex: 0 0 14px;
  width: 14px;
  height: 14px;
  border: 1px solid rgba(60, 45, 25, 0.45);
  box-sizing: border-box;
}

.map-legend-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 900px) {
  .world-map-body {
    flex-direction: column;
  }
  .map-legend {
    flex: 0 0 auto;
    max-width: none;
    width: 100%;
    max-height: 180px;
  }
}
