:root {
  --bg: #191919;
  --panel: #333333;
  --card: #333333;
  --card2: #191919;
  --field: #333333;
  --accent: #f59e0b;
  --accent-strong: #d97706;
  --text: #e8eaf0;
  --text-dim: #7a8194;
  --border: #333333;
  --divider: rgba(232, 234, 240, 0.1);
  --warn: #f97316;
  --shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
  --ui-font-latin: "Trebuchet MS", "Segoe UI", Arial, sans-serif;
  --ui-font-zh-cn: "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", "Noto Sans SC", sans-serif;
  --ui-font-zh-tc: "PingFang TC", "Microsoft JhengHei", "Noto Sans CJK TC", "Noto Sans TC", sans-serif;
  --ui-font-ja: "Hiragino Sans", "Yu Gothic", "Meiryo", "Noto Sans CJK JP", "Noto Sans JP", sans-serif;
  --ui-font-ko: "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans CJK KR", "Noto Sans KR", sans-serif;
  --ui-font-family: "Trebuchet MS", "Helvetica Neue", "Segoe UI", Arial, "PingFang TC", "Microsoft JhengHei", "PingFang SC", "Microsoft YaHei", "Hiragino Sans", "Yu Gothic", "Meiryo", "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans CJK", "Noto Sans", sans-serif;
  --mono-font-family: "Noto Sans Mono", "Source Code Pro", Consolas, "Microsoft YaHei", monospace;
  --template-symbol-font-family: "NS Cambria", Cambria, serif;
}

@font-face {
  font-family: "HarmonyOS Sans SC";
  src: url("./font/HarmonyOS_Sans_SC/HarmonyOS_Sans_SC_Regular.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "HarmonyOS Sans SC";
  src: url("./font/HarmonyOS_Sans_SC/HarmonyOS_Sans_SC_Light.woff2") format("woff2");
  font-weight: 300;
  font-display: swap;
}

@font-face {
  font-family: "HarmonyOS Sans SC";
  src: url("./font/HarmonyOS_Sans_SC/HarmonyOS_Sans_SC_Bold.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}

@font-face {
  font-family: "HarmonyOS Sans SC";
  src: url("./font/HarmonyOS_Sans_SC/HarmonyOS_Sans_SC_Black.woff2") format("woff2");
  font-weight: 900;
  font-display: swap;
}

@font-face {
  font-family: "Source Han Sans CN";
  src: url("./font/Source%20Han%20Sans/%E6%80%9D%E6%BA%90%E9%BB%91%E4%BD%93%20CN-Medium.woff2") format("woff2");
  font-weight: 500;
  font-display: swap;
}

@font-face {
  font-family: "Source Han Serif CN";
  src: url("./font/Source%20Han%20Serif/%E6%80%9D%E6%BA%90%E5%AE%8B%E4%BD%93%20CN%20ExtraLight.woff2") format("woff2");
  font-weight: 200;
  font-display: swap;
}

@font-face {
  font-family: "Source Han Serif CN";
  src: url("./font/Source%20Han%20Serif/%E6%80%9D%E6%BA%90%E5%AE%8B%E4%BD%93%20CN.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "Source Han Serif CN";
  src: url("./font/Source%20Han%20Serif/%E6%80%9D%E6%BA%90%E5%AE%8B%E4%BD%93%20CN%20Medium.woff2") format("woff2");
  font-weight: 500;
  font-display: swap;
}

@font-face {
  font-family: "Source Han Serif CN";
  src: url("./font/Source%20Han%20Serif/%E6%80%9D%E6%BA%90%E5%AE%8B%E4%BD%93%20CN%20SemiBold.woff2") format("woff2");
  font-weight: 600;
  font-display: swap;
}

@font-face {
  font-family: "Source Han Serif KR Local";
  src: url("./font/Source%20Han%20Serif/Korean/SourceHanSerifK-Regular.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "Source Han Serif KR Local";
  src: url("./font/Source%20Han%20Serif/Korean/SourceHanSerifK-SemiBold.woff2") format("woff2");
  font-weight: 600;
  font-display: swap;
}

@font-face {
  font-family: "Josefin Sans";
  src: url("./font/josefin-sans_5.2.8/webfonts/josefin-sans-latin-700-normal.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}

@font-face {
  font-family: "Josefin Sans";
  src: url("./font/josefin-sans_5.2.8/webfonts/josefin-sans-latin-400-normal.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "NS Cambria";
  src: url("./font/cambria-math-regular.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "Source Sans 3";
  src: url("./font/source-sans-3_5.2.9/webfonts/source-sans-3-latin-400-normal.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "Source Sans 3";
  src: url("./font/source-sans-3_5.2.9/webfonts/source-sans-3-latin-300-normal.woff2") format("woff2");
  font-weight: 300;
  font-display: swap;
}

@font-face {
  font-family: "Source Sans 3";
  src: url("./font/source-sans-3_5.2.9/webfonts/source-sans-3-latin-600-normal.woff2") format("woff2");
  font-weight: 600;
  font-display: swap;
}

@font-face {
  font-family: "Source Sans 3";
  src: url("./font/source-sans-3_5.2.9/webfonts/source-sans-3-latin-700-normal.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}

[data-theme="light"] {
  --bg: #f0f2f7;
  --panel: #ffffff;
  --card: #e8ecf4;
  --card2: #e2e6ef;
  --field: #f4f6fa;
  --accent: #d97706;
  --accent-strong: #b45309;
  --text: #1c2130;
  --text-dim: #5a6270;
  --border: #c8ced9;
  --divider: rgba(28, 33, 48, 0.1);
  --warn: #c2410c;
  --shadow: 0 8px 20px rgba(20, 28, 45, 0.06);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
  overflow: hidden;
}

body {
  display: flex;
  flex-direction: column;
  color: var(--text);
  background: var(--bg);
  font-family: var(--ui-font-family);
}

button,
input,
select,
textarea {
  font-family: var(--ui-font-family);
}

:lang(en),
:lang(de),
:lang(fr) {
  --ui-font-family: var(--ui-font-latin);
  font-family: var(--ui-font-latin);
}

:lang(zh-CN) {
  --ui-font-family: var(--ui-font-zh-cn);
  font-family: var(--ui-font-zh-cn);
}

:lang(zh-TW),
:lang(zh-HK) {
  --ui-font-family: var(--ui-font-zh-tc);
  font-family: var(--ui-font-zh-tc);
}

:lang(ja) {
  --ui-font-family: var(--ui-font-ja);
  font-family: var(--ui-font-ja);
}

:lang(ko) {
  --ui-font-family: var(--ui-font-ko);
  font-family: var(--ui-font-ko);
}

.page-turn-button {
  position: fixed;
  top: 50%;
  z-index: 20;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  width: 58px;
  height: 116px;
  min-width: 58px;
  padding: 8px 6px;
  border: 0;
  background: #ffffff;
  color: var(--text-dim);
  box-shadow: 0 0 16px rgba(0, 0, 0, 0.08);
  text-decoration: none;
  transform: translateY(-50%);
}

.page-turn-button::after {
  display: none;
}

.page-turn-button:hover {
  border-color: transparent;
  background: transparent;
  color: var(--accent);
}

[data-theme="dark"] .page-turn-button {
  border-color: transparent;
  background: transparent;
  color: var(--text-dim);
}

[data-theme="dark"] .page-turn-button:hover {
  border-color: transparent;
  background: transparent;
  color: var(--accent);
}

.page-turn-button span {
  display: block;
  font-size: 32px;
  font-weight: 700;
  line-height: 1;
}

.page-turn-button small {
  display: block;
  max-width: calc(100% - 4px);
  padding-bottom: 5px;
  border-bottom: 1px solid var(--divider);
  color: currentColor;
  font-size: 11px;
  font-weight: 800;
  line-height: 1.15;
  text-align: center;
  white-space: normal;
  overflow-wrap: normal;
  word-break: keep-all;
}

.page-turn-button:hover small {
  border-bottom-color: var(--accent);
}

.page-turn-next {
  right: 0;
  border-right: 0;
  width: 86px;
  min-width: 86px;
}

.page-turn-template {
  top: calc(50% + 128px);
}

.page-turn-prev {
  left: 0;
  border-left: 0;
}

.card-image-switch {
  top: 64%;
}

.app-header {
  position: relative;
  z-index: 2;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 44px;
  padding: 8px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}

.app-header h1 {
  max-width: calc(100% - 170px);
  min-width: 0;
  overflow: hidden;
  font-size: 15px;
  font-weight: 700;
  line-height: 1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.header-actions {
  position: absolute;
  right: 12px;
  top: 50%;
  display: flex;
  align-items: center;
  gap: 6px;
  transform: translateY(-50%);
}

.header-icon-btn {
  width: 32px;
  height: 32px;
  min-width: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border-radius: 0;
  background: transparent;
  border: 0;
  border-bottom: 1px solid transparent;
  color: var(--text);
}

.header-icon-btn:hover {
  background: transparent;
  border-bottom-color: var(--accent);
  color: var(--accent-strong);
}

.header-language-menu {
  position: relative;
  display: inline-flex;
}

.ui-language-popover {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 30;
  display: grid;
  gap: 2px;
  width: 150px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.ui-language-popover::before {
  content: "";
  position: absolute;
  top: -5px;
  right: 12px;
  width: 8px;
  height: 8px;
  border-top: 1px solid var(--border);
  border-left: 1px solid var(--border);
  background: var(--panel);
  transform: rotate(45deg);
}

.ui-language-popover button {
  position: relative;
  z-index: 1;
  width: 100%;
  padding: 7px 0 6px;
  border: 0;
  border-bottom: 1px solid transparent;
  border-radius: 0;
  background: transparent;
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
  text-align: left;
}

.ui-language-popover button:hover,
.ui-language-popover button.active {
  border-bottom-color: var(--accent);
  background: transparent;
  color: var(--accent);
}

.header-icon-btn img {
  display: block;
  width: 16px;
  height: 16px;
  object-fit: contain;
  filter: none;
}

.header-link {
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
}

.header-link:hover {
  color: var(--accent);
}

[data-theme="dark"] .header-icon-btn img {
  filter: brightness(0) saturate(100%) invert(100%);
}

.recent-panel {
  position: fixed;
  top: 50px;
  right: 12px;
  z-index: 12;
  width: min(340px, calc(100vw - 24px));
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.recent-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.recent-panel-head strong {
  font-size: 13px;
  color: var(--text);
}

.recent-clear {
  padding: 4px 0 5px;
  border: 0;
  border-bottom: 1px solid var(--divider);
  border-radius: 0;
  background: transparent;
  color: var(--text-dim);
  font-size: 11px;
}

.recent-list {
  display: grid;
  gap: 0;
  max-height: 320px;
  overflow-y: auto;
}

.recent-item-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 28px;
  align-items: stretch;
  border-bottom: 1px solid var(--divider);
}

.recent-item {
  display: grid;
  gap: 3px;
  width: 100%;
  padding: 8px 2px 9px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.recent-item:hover {
  background: transparent;
  color: var(--accent);
}

.recent-item strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
}

.recent-item span,
.recent-empty {
  color: var(--text-dim);
  font-size: 11px;
}

.recent-empty {
  padding: 12px 4px;
  text-align: center;
}

.recent-delete {
  align-self: center;
  justify-self: end;
  width: 24px;
  height: 24px;
  min-width: 24px;
  min-height: 24px;
  padding: 0 0 2px;
  border: 0;
  border-bottom: 1px solid transparent;
  border-radius: 0;
  background: transparent;
  color: var(--text-dim);
  font: 700 18px/1 var(--ui-font-family);
}

.recent-delete:hover {
  border-bottom-color: rgba(239, 68, 68, 0.72);
  background: transparent;
  color: #ef4444;
}

.main {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  background: var(--bg);
}

.main-layout {
  display: block;
  width: min(1280px, 100%);
  margin: 0 auto;
}

.main-column {
  min-width: 0;
}

.panel,
.result-section {
  max-width: 1280px;
  margin: 0 auto;
  background: var(--panel);
  border: 1px solid var(--divider);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.main-layout > .main-column > .panel,
.main-layout > .main-column > .result-section {
  max-width: none;
  margin-right: 0;
  margin-left: 0;
}

.panel {
  padding: 12px;
}

.bar-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 10px;
  color: var(--text);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.2;
}

.bar-title::before {
  display: none;
}

.bar-title::after {
  content: "";
  flex: 1 1 auto;
  height: 1px;
  background: var(--divider);
}

.dropzone {
  border: 1px dashed rgba(245, 158, 11, 0.42);
  border-radius: 8px;
  padding: 18px;
  background: transparent;
  transition: border-color 120ms ease, background 120ms ease;
}

.dropzone.dragover {
  border-color: var(--accent);
  background: rgba(245, 158, 11, 0.1);
}

.dropzone-copy {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 44px;
}

.dropzone-title {
  color: var(--text-dim);
  font-size: 13px;
}

.ec-import-row {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--divider);
}

.ec-import-row label {
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.ec-import-row input {
  min-width: 0;
  height: 34px;
  padding: 0 0 4px;
  border: 0;
  border-bottom: 1px solid var(--divider);
  border-radius: 0;
  background: transparent;
  color: var(--text);
  font: 12px/1.2 var(--ui-font-family);
  outline: none;
}

.ec-import-row input:focus {
  border-bottom-color: var(--accent);
}

.ec-import-row button {
  min-height: 34px;
  padding: 0 0 3px;
  font-size: 12px;
}

button {
  border: 0;
  border-bottom: 1px solid var(--divider);
  border-radius: 0;
  padding: 7px 0 6px;
  background: transparent;
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease;
}

button:hover {
  border-bottom-color: var(--accent);
  background: transparent;
  color: var(--accent-strong);
}

button:disabled,
button:disabled:hover {
  cursor: not-allowed;
  border-color: transparent;
  border-bottom-color: var(--divider);
  background: transparent;
  color: var(--text-dim);
  opacity: 0.62;
}

button.secondary {
  background: transparent;
  border-color: transparent;
  border-bottom-color: var(--divider);
  border-radius: 0;
  color: var(--text-dim);
}

button.secondary:disabled,
button.secondary:disabled:hover {
  border-color: transparent;
  border-bottom-color: var(--divider);
  background: transparent;
  color: var(--text-dim);
}

button.secondary:hover {
  border-color: transparent;
  border-bottom-color: var(--accent);
  background: transparent;
  color: var(--accent-strong);
}

.button-link {
  display: inline-flex;
  align-items: center;
  min-height: 31px;
  padding: 7px 12px;
  border: 1px solid var(--divider);
  border-radius: 6px;
  background: transparent;
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
}

.button-link:hover {
  border-color: rgba(245, 158, 11, 0.42);
  color: var(--accent);
}

.actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
}

.local-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.public-tool-panel {
  max-width: 820px;
}

.public-tool-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.public-tool-button {
  display: grid;
  gap: 6px;
  min-height: 118px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card);
  color: var(--text);
  text-align: left;
  text-decoration: none;
}

.public-tool-button:hover {
  border-color: rgba(245, 158, 11, 0.58);
  background: var(--card2);
  color: var(--text);
}

.public-tool-button strong {
  font-size: 18px;
  font-weight: 900;
  line-height: 1.2;
}

.public-tool-button span {
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.45;
}

.equipinfo-main {
  display: grid;
  gap: 12px;
  align-content: start;
}

.equipinfo-panel,
.equipinfo-main > .result-section {
  width: min(1280px, 100%);
}

.equipinfo-source-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
}

.equipinfo-form {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.equipinfo-link-form {
  position: relative;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--divider);
}

.equipinfo-text-form {
  grid-template-columns: minmax(0, 1fr);
}

.equipinfo-form label,
.equipinfo-form-head > label,
.equipinfo-locale-field span {
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.2;
}

.equipinfo-form-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.equipinfo-link-input-wrap {
  position: relative;
  min-width: 0;
}

.equipinfo-link-input-wrap > input,
.equipinfo-locale-field select {
  min-width: 0;
  border: 0;
  border-bottom: 1px solid var(--divider);
  border-radius: 0;
  background: transparent;
  color: var(--text);
  font: 12px/1.35 var(--ui-font-family);
  outline: none;
}

.equipinfo-link-input-wrap > input,
.equipinfo-locale-field select {
  width: 100%;
  height: 36px;
  padding: 0 0 5px;
}

.equipinfo-chara-drop-overlay {
  position: absolute;
  inset: 0;
  border: 1px dashed var(--accent);
  border-radius: 7px;
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 44%, transparent);
  opacity: 0;
  pointer-events: none;
  transition: opacity 120ms ease;
}

.equipinfo-link-form.chara-dragover .equipinfo-chara-drop-overlay,
.equipinfo-text-form.chara-dragover .equipinfo-chara-drop-overlay {
  opacity: 1;
}

.equipinfo-code-input {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  min-height: clamp(180px, 26vh, 270px);
  border: 0;
  border-bottom: 1px solid var(--divider);
  border-radius: 0;
  background: transparent;
  overflow: hidden;
}

.equipinfo-line-numbers {
  min-width: 44px;
  padding: 9px 8px 9px 10px;
  border-right: 1px solid var(--divider);
  background: transparent;
  color: var(--text-dim);
  font: 12px/1.35 var(--mono-font-family);
  text-align: right;
  user-select: none;
  white-space: pre;
  overflow: hidden;
}

.equipinfo-form textarea {
  min-height: clamp(180px, 26vh, 270px);
  padding: 9px 10px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--text);
  font: 12px/1.35 var(--mono-font-family);
  outline: none;
  resize: vertical;
  white-space: pre;
  overflow: auto;
}

.equipinfo-link-input-wrap > input:focus,
.equipinfo-locale-field select:focus,
.equipinfo-code-input:focus-within {
  border-bottom-color: var(--accent);
}

.equipinfo-locale-field {
  display: inline-grid;
  grid-template-columns: auto minmax(86px, 1fr);
  align-items: center;
  gap: 8px;
}

.equipinfo-action-buttons {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.equipinfo-action-buttons button,
.equipinfo-form-head > button {
  min-height: 36px;
  white-space: nowrap;
}

.equipinfo-text-form > .status {
  margin: 0;
}

.equipinfo-warnings {
  display: grid;
  gap: 4px;
  margin-top: 8px;
  color: var(--warn);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.45;
}

.equipinfo-warnings:empty,
.equipinfo-warnings[hidden] {
  display: none;
}

.character-picker-overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(15, 23, 42, 0.38);
}

.character-picker-overlay.hidden {
  display: none;
}

.character-picker {
  width: min(560px, calc(100vw - 40px));
  max-height: min(680px, calc(100vh - 40px));
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.character-picker-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}

.character-picker-head h2 {
  margin: 0 0 4px;
  color: var(--text);
  font-size: 15px;
}

.character-picker-head p {
  margin: 0;
  color: var(--text-dim);
  font-size: 11px;
  word-break: break-all;
}

.character-picker-dir {
  display: grid;
  gap: 5px;
}

.character-picker-dir label {
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 700;
}

.character-picker-dir > div {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.character-picker-dir input {
  min-width: 0;
  min-height: 34px;
  padding: 7px 0;
  border: 0;
  border-bottom: 1px solid var(--divider);
  border-radius: 0;
  background: transparent;
  color: var(--text);
  font: 13px/1.3 var(--ui-font-family);
  outline: none;
}

.character-picker-dir input:focus {
  border-bottom-color: var(--accent);
}

.character-picker-list {
  min-height: 120px;
  overflow-y: auto;
  display: grid;
  gap: 6px;
}

.character-file-button {
  display: grid;
  gap: 3px;
  width: 100%;
  padding: 9px 0 10px;
  border: 0;
  border-bottom: 1px solid var(--divider);
  border-radius: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.character-file-button:hover {
  border-bottom-color: var(--accent);
  background: transparent;
  color: var(--accent-strong);
}

.character-file-button strong {
  overflow: hidden;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.character-file-button span,
.character-picker-empty {
  color: var(--text-dim);
  font-size: 11px;
}

.character-picker-empty {
  margin: 0;
  padding: 14px 4px;
}

.status {
  color: var(--text-dim);
  font-size: 12px;
}

.status.error {
  color: var(--warn);
}

.result-section {
  margin-top: 14px;
  padding: 12px;
}

.hidden {
  display: none;
}

.result-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.result-header.compact {
  justify-content: flex-end;
}

.result-header h2 {
  min-width: 0;
  color: var(--text);
  font-size: 15px;
  font-weight: 700;
  line-height: 1.35;
  word-break: break-all;
}

.result-title {
  min-width: 0;
}

.character-meta {
  margin: 3px 0 0;
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.35;
}

.meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: flex-end;
  margin-left: auto;
}

.meta span {
  padding: 0;
  border-radius: 0;
  background: transparent;
  border: 0;
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 700;
}

.meta .inline-status {
  min-width: 90px;
  background: transparent;
  border-color: transparent;
  color: var(--accent-strong);
}

.meta .inline-status.error {
  color: var(--warn);
}

.meta > button {
  min-height: 30px;
  padding: 0 0 7px;
  font-size: 12px;
  line-height: 1.2;
}

.meta-controls {
  align-items: center;
}

.language-controls {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 32px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.language-button {
  min-width: 0;
  min-height: 30px;
  padding: 0 0 7px;
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  background: transparent;
  color: var(--text-dim);
  font-size: 12px;
  line-height: 1.2;
}

.language-button:hover,
.language-button.active {
  background: transparent;
  border-bottom-color: var(--accent);
  color: var(--accent-strong);
}

.language-button.current {
  box-shadow: none;
}

.language-button:disabled,
.language-button:disabled:hover {
  border-color: transparent;
  border-bottom-color: var(--divider);
  background: transparent;
  color: var(--text-dim);
}

.copy-layout {
  display: grid;
  gap: 10px;
}

.copy-format-controls {
  justify-self: start;
}

.copy-filter-toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-self: start;
  flex: 0 0 auto;
}

.copy-filter-toggle input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.copy-filter-toggle span {
  padding: 0 0 2px;
  border: 0;
  border-bottom: 1px solid transparent;
  border-radius: 0;
  background: transparent;
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.copy-filter-toggle input:checked + span {
  background: transparent;
  border-color: var(--accent);
  color: var(--accent-strong);
}

.custom-template-panel {
  display: grid;
  gap: 8px;
}

.custom-template-panel.hidden {
  display: none;
}

.custom-template-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.custom-template-head label {
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 700;
}

.custom-template-head button {
  padding: 0 0 3px;
  font-size: 12px;
}

.template-reference {
  display: grid;
  gap: 0;
  padding: 0;
  border: 0;
  border-top: 1px solid var(--divider);
  border-radius: 0;
  background: transparent;
}

.template-reference-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 8px 0;
  border-bottom: 1px solid var(--divider);
}

.template-reference-group > span {
  flex: 0 0 74px;
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 800;
}

.token-chip {
  min-height: 24px;
  padding: 3px 0 4px;
  border: 0;
  border-bottom: 1px solid transparent;
  border-radius: 0;
  background: transparent;
  color: var(--text-dim);
  font-family: var(--ui-font-family);
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
}

.token-chip:hover {
  border-color: var(--accent);
  background: transparent;
  color: var(--accent);
}

.template-input,
.copy-output {
  width: 100%;
  padding: 10px 0;
  border: 0;
  border-bottom: 1px solid var(--divider);
  border-radius: 0;
  background: transparent;
  color: var(--text);
  font: 13px/1.7 var(--ui-font-family);
  resize: vertical;
  outline: none;
}

.template-input {
  min-height: 132px;
}

.copy-output {
  min-height: 240px;
}

.template-input:focus,
.copy-output:focus {
  border-bottom-color: var(--accent);
}

.card-editor {
  display: grid;
  grid-template-columns: repeat(2, minmax(360px, 1fr));
  gap: 0 18px;
}

.equipinfo-card-editor {
  grid-template-columns: repeat(2, minmax(320px, 1fr));
  gap: 0 28px;
}

.equipinfo-slot-column {
  display: grid;
  align-content: start;
  min-width: 0;
}

.card-editor,
.template-language-settings {
  border-top: 1px solid var(--divider);
  padding-top: 8px;
}

.editor-row {
  position: relative;
  display: grid;
  grid-template-columns: minmax(240px, 1fr);
  align-items: end;
  min-height: 88px;
  padding: 22px 0 10px;
  border: 0;
  border-bottom: 1px solid var(--divider);
  border-radius: 0;
  background: transparent;
}

.editor-slot-name,
.editor-item,
.editor-search {
  min-width: 0;
}

.editor-error {
  color: var(--warn);
  font-size: 12px;
  line-height: 1.45;
}

.editor-slot-name {
  position: absolute;
  top: 7px;
  left: 0;
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
}

.item-search-input {
  width: 100%;
  min-height: 38px;
  padding: 7px 0;
  border: 0;
  border-bottom: 1px solid var(--divider);
  border-radius: 0;
  background: transparent;
  color: var(--text);
  font: 14px/1.3 var(--ui-font-family);
  outline: none;
}

.item-search-input:focus {
  border-bottom-color: var(--accent);
}

.item-search-input:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.editor-item {
  display: flex;
  gap: 8px;
  align-items: center;
  min-height: 42px;
  width: 100%;
}

.editor-item.editor-search-mode {
  display: block;
}

.editor-empty {
  color: var(--text-dim);
  font-size: 13px;
}

.editor-item-icon {
  width: 42px;
  height: 42px;
  border-radius: 7px;
  object-fit: cover;
  flex: 0 0 auto;
  box-shadow: inset 0 0 0 1px var(--border);
}

.editor-item-body {
  display: grid;
  gap: 5px;
  flex: 1;
  min-width: 0;
}

.editor-item-title {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.editor-item-title strong {
  flex: 1 1 auto;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  color: var(--text);
  font-size: 14px;
  font-weight: 800;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.candidate-switch-button {
  position: relative;
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  min-width: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  border-bottom: 1px solid transparent;
  border-radius: 0;
  background: transparent;
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 800;
  line-height: 1;
}

.candidate-switch-button:hover,
.candidate-switch-button:focus,
.candidate-switch-button.active {
  border-bottom-color: var(--accent);
  background: transparent;
  color: var(--accent);
  outline: none;
}

.candidate-picker-panel {
  position: absolute;
  z-index: 9;
  top: calc(100% + 5px);
  right: 0;
  display: grid;
  gap: 3px;
  width: min(300px, calc(100vw - 42px));
  max-height: 260px;
  padding: 5px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card);
  box-shadow: var(--shadow);
}

.candidate-picker-option {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 36px;
  padding: 4px 0 5px;
  border: 0;
  border-bottom: 1px solid transparent;
  border-radius: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.candidate-picker-option:hover,
.candidate-picker-option:focus,
.candidate-picker-option.active {
  border-bottom-color: var(--accent);
  background: transparent;
  color: var(--accent-strong);
  outline: none;
}

.candidate-picker-option img {
  width: 28px;
  height: 28px;
  border-radius: 5px;
  object-fit: cover;
  box-shadow: inset 0 0 0 1px var(--border);
}

.candidate-picker-option span {
  min-width: 0;
  overflow: hidden;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.inline-delete-button {
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  min-width: 24px;
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  border-bottom: 1px solid transparent;
  border-radius: 0;
  background: transparent;
  color: var(--text-dim);
  font-size: 16px;
  line-height: 1;
}

.inline-delete-button:hover {
  border-bottom-color: var(--accent);
  background: transparent;
  color: var(--accent);
}

.editor-search {
  position: relative;
  width: 100%;
}

.editor-dye-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  align-items: center;
  min-height: 26px;
  color: var(--text-dim);
  font-size: 11px;
}

.editor-dye-select {
  position: relative;
  display: inline-flex;
  flex: 0 1 140px;
  min-width: 0;
  max-width: 100%;
}

.dye-picker-button {
  width: 140px;
  max-width: 100%;
  min-height: 25px;
  padding: 3px 16px 4px 22px;
  border: 0;
  border-bottom: 1px solid var(--divider);
  border-radius: 0;
  background:
    radial-gradient(circle at 11px center, var(--dye-color, #000000) 0 5px, transparent 6px),
    transparent;
  color: var(--text);
  font-size: 11px;
  font-weight: 700;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  outline: none;
}

.dye-picker-button::after {
  content: "";
  position: absolute;
  right: 7px;
  top: 50%;
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid var(--text-dim);
  transform: translateY(-35%);
  pointer-events: none;
}

.equipinfo-dye-chip {
  display: block;
  cursor: default;
}

.equipinfo-dye-chip::after {
  display: none;
}

.equipinfo-dye-chip.empty-dye {
  background:
    radial-gradient(circle at 11px center, transparent 0 4px, var(--text-dim) 4px 5px, transparent 6px),
    transparent;
  color: var(--text-dim);
}

.equipinfo-edit-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}

.dye-picker-button:hover,
.dye-picker-button:focus {
  border-bottom-color: var(--accent);
  background:
    radial-gradient(circle at 11px center, var(--dye-color, #000000) 0 5px, transparent 6px),
    transparent;
  color: var(--text);
}

.dye-picker-panel {
  position: absolute;
  z-index: 8;
  top: calc(100% + 4px);
  left: 0;
  display: grid;
  gap: 2px;
  width: 220px;
  max-height: 220px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card);
  box-shadow: var(--shadow);
}

.dye-picker-search {
  width: 100%;
  height: 28px;
  padding: 0 0 4px;
  border: 0;
  border-bottom: 1px solid var(--divider);
  border-radius: 0;
  background: transparent;
  color: var(--text);
  font: 12px/1.2 var(--ui-font-family);
  outline: none;
}

.dye-picker-search:focus {
  border-bottom-color: var(--accent);
}

.dye-picker-results {
  display: grid;
  gap: 2px;
  max-height: 180px;
  overflow-y: auto;
}

.dye-picker-group-title {
  padding: 6px 7px 3px;
  color: var(--text-dim);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  pointer-events: none;
  user-select: none;
}

.dye-picker-option {
  display: flex;
  align-items: center;
  gap: 7px;
  width: 100%;
  padding: 5px 0 6px;
  border: 0;
  border-bottom: 1px solid transparent;
  border-radius: 0;
  background: transparent;
  color: var(--text);
  font-size: 11px;
  font-weight: 700;
  text-align: left;
}

.dye-picker-option:hover {
  border-bottom-color: var(--accent);
  background: transparent;
  color: var(--accent-strong);
}

.dye-picker-swatch {
  width: 11px;
  height: 11px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: var(--dye-color, #000000);
  border: 1px solid rgba(17, 24, 39, 0.28);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.28);
}

.dye-picker-empty {
  padding: 12px 6px;
  color: var(--text-dim);
  font-size: 11px;
  text-align: center;
}

.search-results {
  position: absolute;
  z-index: 5;
  display: grid;
  gap: 4px;
  max-height: 260px;
  width: 100%;
  margin-top: 6px;
  overflow-y: auto;
  border-radius: 8px;
  background: var(--card);
  box-shadow: var(--shadow);
}

.search-result {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 6px 0 7px;
  border: 0;
  border-bottom: 1px solid var(--divider);
  border-radius: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.search-result:hover {
  border-bottom-color: var(--accent);
  background: transparent;
  color: var(--accent-strong);
}

.search-result img {
  width: 30px;
  height: 30px;
  border-radius: 6px;
  object-fit: cover;
}

.search-result span {
  overflow: hidden;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.search-empty {
  padding: 8px;
  color: var(--text-dim);
  font-size: 12px;
}

.template-language-order-controls {
  display: inline-grid;
  grid-template-columns: repeat(3, 24px);
  gap: 4px;
  align-self: center;
}

.template-language-order-controls button {
  width: 24px;
  height: 28px;
  min-width: 24px;
  padding: 0;
  border-radius: 0;
  font-size: 13px;
  line-height: 1;
}

.template-language-order-controls button:disabled {
  cursor: default;
  opacity: 0.35;
}

.png-setting-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.png-setting-field > span {
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: 0.04em;
}

.png-setting-input-row {
  display: flex;
  gap: 6px;
  align-items: center;
}

.png-setting-input-row .template-text-input {
  flex: 1;
  min-width: 0;
}

/* Toast notification */
.toast-notification {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 999;
  padding: 12px 28px;
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.22);
  opacity: 0;
  transition: opacity 0.25s;
  pointer-events: none;
}

.toast-notification.toast-visible {
  opacity: 1;
}

.toast-notification.toast-error {
  color: #ef4444;
}

/* Author SNS popup */
.author-sns-popup {
  position: fixed;
  z-index: 90;
  display: flex;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid var(--divider);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
}

.author-sns-popup.hidden {
  display: none;
}

.author-sns-link {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  color: var(--text-dim);
  transition: color 0.15s, background 0.15s;
}

.author-sns-link:hover {
  color: var(--accent);
  background: rgba(245, 158, 11, 0.12);
}

.author-sns-icon {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.author-sns-icon svg {
  width: 18px;
  height: 18px;
}

.png-setting-color {
  width: 32px;
  min-width: 32px;
  height: 32px;
  justify-self: start;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--field);
  cursor: pointer;
}

.png-setting-color::-webkit-color-swatch-wrapper {
  padding: 0;
}

.png-setting-color::-webkit-color-swatch {
  border: 1px solid var(--border);
  border-radius: 4px;
}

.template-download-button {
  flex: 0 0 auto;
  width: auto;
  min-width: 0;
  height: 32px;
  min-height: 32px;
  padding: 0 0 3px;
  font-size: 12px;
}

.segmented-control {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  padding: 0;
  border: 0;
  border-bottom: 1px solid var(--divider);
  border-radius: 0;
  background: transparent;
}

.segmented-button {
  min-width: 0;
  padding: 0 0 7px;
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  background: transparent;
  color: var(--text-dim);
  font-size: 12px;
  line-height: 1;
}

.segmented-button:hover,
.segmented-button.active {
  background: transparent;
  border-bottom-color: var(--accent);
  color: var(--accent-strong);
}

.segmented-button:disabled,
.segmented-button:disabled:hover {
  border-color: transparent;
  border-bottom-color: var(--divider);
  background: transparent;
  color: var(--text-dim);
}

.template-workspace-main {
  --template-workspace-height: calc(100dvh - 72px - 28px);
  min-height: 0;
  overflow: hidden;
}

.template-workspace-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 420px);
  gap: 14px;
  width: min(1540px, 100%);
  height: min(100%, var(--template-workspace-height));
  margin: 0 auto;
}

.template-preview-panel,
.template-config-panel {
  min-width: 0;
  min-height: 0;
}

.template-preview-panel {
  display: grid;
  grid-template-rows: minmax(0, 1fr);
}

.template-status-visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.template-canvas-shell {
  position: relative;
  min-width: 0;
  min-height: 360px;
  height: 100%;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card2);
  box-shadow: var(--shadow);
  transition: border-color 120ms ease, box-shadow 120ms ease, background-color 120ms ease;
}

.template-canvas-shell.dragover {
  border-color: var(--accent);
  background-color: rgba(245, 158, 11, 0.12);
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.18), var(--shadow);
}

.template-canvas {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  background: transparent;
  image-rendering: auto;
}

.template-canvas-upload-layer {
  position: absolute;
  z-index: 2;
  display: grid;
  place-content: center;
  gap: 6px;
  min-width: 0;
  padding: 8px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--text);
  text-align: center;
  transition: background 120ms ease, border-color 120ms ease, opacity 120ms ease;
}

.template-canvas-upload-layer:hover,
.template-canvas-upload-layer.dragover {
  border-color: transparent;
  background: rgba(245, 158, 11, 0.08);
}

.template-canvas-upload-layer span {
  justify-self: center;
  padding-bottom: 5px;
  border-bottom: 1px solid var(--accent);
  color: var(--accent);
  font-size: 18px;
  font-weight: 900;
  line-height: 1.15;
  overflow-wrap: anywhere;
  pointer-events: none;
}

.template-canvas-upload-layer:hover span,
.template-canvas-upload-layer.dragover span {
  border-bottom-color: var(--accent-strong);
  color: var(--accent-strong);
}

.template-canvas-upload-layer small {
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 700;
  pointer-events: none;
}

.template-canvas-upload-layer[data-template-image-slot$="avatar"] {
  padding: 2px;
}

.template-canvas-upload-layer[data-template-image-slot$="avatar"] span {
  max-width: 100%;
  padding-bottom: 2px;
  font-size: 13px;
  line-height: 1.05;
}

.template-canvas-upload-layer.has-image {
  background: transparent;
  border-color: transparent;
  opacity: 0;
}

.template-canvas-upload-layer.has-image:hover,
.template-canvas-upload-layer.has-image.dragover {
  background: rgba(245, 158, 11, 0.08);
  border-color: transparent;
  opacity: 1;
}

.template-loading-overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  background: rgba(15, 17, 23, 0.28);
  opacity: 1;
  pointer-events: auto;
  transition: opacity 160ms ease;
}

.template-loading-overlay.hidden {
  display: none;
}

.template-loading-overlay.is-hiding {
  opacity: 0;
}

.template-loading-card {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 10px 16px;
  border: 1px solid rgba(245, 158, 11, 0.22);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  color: #1c2130;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.18);
  font: 700 13px/1.2 var(--ui-font-family);
}

[data-theme="dark"] .template-loading-card {
  background: rgba(51, 51, 51, 0.95);
  color: var(--text);
}

.template-loading-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(217, 119, 6, 0.28);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: template-loading-spin 760ms linear infinite;
}

.template-loading-text {
  white-space: nowrap;
}

@keyframes template-loading-spin {
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .template-loading-overlay {
    transition: none;
  }

  .template-loading-spinner {
    animation: none;
  }
}

.template-config-panel {
  display: grid;
  align-content: start;
  gap: 10px;
  height: 100%;
  max-height: var(--template-workspace-height);
  overflow-y: auto;
}

.template-config-section {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--divider);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.template-section-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.template-section-title-row .bar-title {
  min-width: 0;
}

.template-section-title-row button {
  min-height: 28px;
  padding: 0 0 3px;
  font-size: 12px;
  white-space: nowrap;
}

.template-meta-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
  align-items: start;
  min-width: 0;
  padding: 0 0 11px;
  border: 0;
  border-bottom: 1px solid var(--divider);
  border-radius: 0;
  background: transparent;
}

.template-meta-author {
  font-family: var(--ui-font-family);
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.2;
}

.template-meta-author {
  grid-column: 1 / -1;
  min-width: 0;
  overflow-wrap: anywhere;
  white-space: normal;
}

.template-author-link {
  color: var(--text);
  font-weight: 800;
  text-decoration: none;
}

.template-author-link:not(.is-disabled):hover {
  color: var(--accent-strong);
}

.template-author-link.is-disabled {
  color: var(--text);
  cursor: default;
}

.template-meta-actions {
  grid-column: 1 / -1;
  align-self: start;
  justify-self: end;
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-width: 0;
}

.template-meta-actions button {
  width: auto;
  min-width: 0;
  min-height: 26px;
  height: 26px;
  padding: 0 0 3px;
  font-size: 11px;
  text-align: center;
  white-space: nowrap;
}

.template-config-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}

.template-config-toolbar .language-controls {
  min-width: 0;
  flex: 0 1 auto;
  flex-wrap: wrap;
  gap: 8px 12px;
}

.template-config-toolbar .secondary {
  flex: 0 0 auto;
  min-height: 26px;
  padding: 0 0 3px;
  font-size: 12px;
}

.template-language-settings {
  display: grid;
  gap: 0;
}

.template-bilingual-row {
  display: grid;
  grid-template-columns: minmax(52px, max-content) minmax(64px, 1fr) 12px minmax(64px, 1fr);
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--divider);
}

.template-bilingual-row > strong {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}

.template-language-select {
  width: 100%;
  min-width: 0;
  min-height: 30px;
  padding: 4px 26px 4px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--field);
  color: var(--text);
  font: inherit;
  font-size: 12px;
}

.template-language-separator {
  color: var(--text-dim);
  text-align: center;
}

.template-language-settings:empty {
  display: none;
}

.template-language-row {
  display: grid;
  grid-template-columns: minmax(76px, max-content) minmax(42px, max-content) minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  border: 0;
  border-bottom: 1px solid var(--divider);
  border-radius: 0;
  background: transparent;
}

.template-language-row.current {
  border-color: rgba(245, 158, 11, 0.7);
}

.template-language-note {
  min-width: 0;
  overflow: hidden;
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.template-editor {
  grid-template-columns: 1fr;
}

.template-editor .editor-row {
  min-height: 76px;
}

.template-text-input {
  width: 100%;
  height: 32px;
  padding: 0 0 5px;
  border: 0;
  border-bottom: 1px solid var(--divider);
  border-radius: 0;
  background: transparent;
  color: var(--text);
  font: 12px/1.2 var(--ui-font-family);
  outline: none;
}

.template-text-input:focus {
  border-bottom-color: var(--accent);
}

.template-ec-subtitle-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(42px, max-content) minmax(0, 1fr);
  gap: 6px;
  align-items: center;
}

.template-ec-subtitle-symbol-input {
  width: 48px;
  padding-inline: 0;
  text-align: center;
  font-family: var(--template-symbol-font-family);
  font-size: 15px;
}

.template-selector-languages {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: center;
  min-width: 0;
  padding-top: 1px;
  overflow: hidden;
}

.template-language-code {
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 800;
  line-height: 1.2;
  white-space: nowrap;
}

.template-selector-card .template-selector-languages {
  align-self: end;
  flex-wrap: nowrap;
  overflow: hidden;
}

.template-selector-overlay {
  position: fixed;
  inset: 0;
  z-index: 82;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(15, 23, 42, 0.52);
}

.template-selector-overlay.hidden {
  display: none;
}

.template-selector-dialog {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 12px;
  width: min(780px, 100%);
  max-height: min(82vh, 760px);
  padding: 16px;
  border: 1px solid var(--divider);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 22px 58px rgba(15, 23, 42, 0.26);
}

.template-selector-dialog-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  min-width: 0;
}

.template-selector-dialog-head h2 {
  margin: 0;
  color: var(--text);
  font-size: 16px;
  line-height: 1.25;
}

.template-selector-dialog-head p {
  margin: 3px 0 0;
  color: var(--text-dim);
  font-size: 12px;
  line-height: 1.35;
}

.template-selector-filter-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  padding: 0;
  border-bottom: 1px solid var(--divider);
}

.template-selector-filter-button {
  min-width: 0;
  min-height: 0;
  padding: 0 0 7px;
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  background: transparent;
  color: var(--text-dim);
  font: 700 12px/1.2 var(--ui-font-family);
  cursor: pointer;
}

.template-selector-filter-button:hover,
.template-selector-filter-button.active {
  border-bottom-color: var(--accent);
  background: transparent;
  color: var(--accent-strong);
}

.template-selector-filter-button:focus-visible {
  outline: 2px solid rgba(245, 158, 11, 0.42);
  outline-offset: 2px;
}

.template-selector-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, 220px);
  grid-auto-rows: max-content;
  align-content: start;
  justify-content: start;
  gap: 10px;
  min-height: 0;
  overflow-y: auto;
  padding-right: 2px;
}

.template-selector-card {
  display: grid;
  grid-template-rows: 180px auto;
  gap: 8px;
  width: 220px;
  min-width: 0;
  padding: 8px;
  border: 1px solid var(--divider);
  border-radius: 7px;
  background: var(--field);
  color: var(--text);
  font: 12px/1.35 var(--ui-font-family);
  text-align: left;
  cursor: pointer;
}

.template-selector-card:hover,
.template-selector-card.active {
  border-color: rgba(245, 158, 11, 0.82);
  background: rgba(245, 158, 11, 0.08);
}

.template-selector-card:focus-visible {
  outline: 2px solid rgba(245, 158, 11, 0.45);
  outline-offset: 2px;
}

.template-selector-preview {
  display: block;
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--divider);
  border-radius: 6px;
  background: #ffffff;
}

.template-selector-preview img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.template-selector-card-body {
  display: grid;
  gap: 7px;
  min-width: 0;
}

.template-selector-author {
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.template-selector-author .template-author-link {
  font-size: 13px;
}

.template-config-section .png-setting-field.hidden {
  display: none;
}

.template-dye-frame-field {
  margin-top: 8px;
}

.template-dye-frame-controls {
  width: max-content;
}

.template-dye-frame-controls .segmented-button {
  min-width: 0;
}

.template-story-text-color-controls {
  width: max-content;
}

.template-story-text-color-controls .segmented-button {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
}

.template-text-color-swatch {
  width: 12px;
  height: 12px;
  flex: 0 0 12px;
  border: 1px solid var(--divider-strong);
}

.template-text-color-swatch.is-white {
  background: #ffffff;
}

.template-text-color-swatch.is-black {
  background: #111111;
}

.template-story-swatch-field {
  margin-top: 8px;
}

.template-story-swatch-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.template-story-swatch-row {
  display: grid;
  grid-template-columns: 18px 32px minmax(0, 1fr);
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.template-story-swatch-index {
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 800;
  text-align: center;
}

.template-story-swatch-picker {
  justify-self: start;
}

.template-story-swatch-input {
  min-width: 0;
  padding-inline: 0;
  font-family: var(--mono-font-family);
}

.template-crop-overlay {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(15, 23, 42, 0.56);
}

.template-crop-overlay.hidden {
  display: none;
}

.template-crop-dialog {
  width: min(980px, 100%);
  max-height: min(92vh, 760px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.36);
}

.template-crop-head,
.template-crop-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.template-crop-head h2 {
  margin: 0 0 4px;
  font-size: 18px;
}

.template-crop-head p {
  margin: 0;
  color: var(--text-dim);
  font-size: 12px;
}

.template-crop-stage {
  min-height: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #191919;
}

.template-crop-stage .cropper-container {
  max-width: 100%;
}

.template-crop-image {
  display: block;
  max-width: 100%;
  max-height: min(62vh, 620px);
  background: #191919;
}

.template-crop-stage .cropper-bg {
  background-image: none;
}

.template-crop-stage .cropper-container,
.template-crop-stage .cropper-canvas,
.template-crop-stage .cropper-crop-box,
.template-crop-stage .cropper-view-box {
  background: transparent;
}

.template-crop-stage .cropper-view-box {
  outline: 1px solid rgba(245, 158, 11, 0.82);
  outline-color: rgba(245, 158, 11, 0.82);
  box-shadow: none;
}

.template-crop-zoom {
  display: grid;
  grid-template-columns: auto minmax(140px, 1fr) 76px auto;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}

.template-crop-zoom input[type="range"] {
  width: 100%;
}

.template-crop-zoom input[type="number"] {
  width: 76px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel-strong);
  color: var(--text);
}

.template-import-overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(15, 23, 42, 0.5);
}

.template-import-overlay.hidden {
  display: none;
}

.template-import-dialog {
  display: grid;
  gap: 14px;
  width: min(440px, 100%);
  padding: 16px;
  border: 1px solid var(--divider);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 22px 58px rgba(15, 23, 42, 0.24);
}

.template-import-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.template-import-head h2 {
  margin: 0;
  color: var(--text);
  font-size: 16px;
  line-height: 1.25;
}

.template-import-form {
  display: grid;
  gap: 8px;
}

.template-import-form label {
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 800;
}

.template-import-form input {
  min-width: 0;
  min-height: 36px;
  padding: 7px 0;
  border: 0;
  border-bottom: 1px solid var(--divider);
  border-radius: 0;
  background: transparent;
  color: var(--text);
  font: 13px/1.4 var(--ui-font-family);
}

.template-import-form input:focus {
  outline: none;
  border-bottom-color: var(--accent);
  box-shadow: none;
}

.template-import-form p {
  margin: 0;
  color: var(--text-dim);
  font-size: 12px;
  line-height: 1.35;
}

.template-import-form p.error {
  color: #b91c1c;
  font-weight: 800;
}

.template-import-actions {
  display: flex;
  justify-content: flex-end;
  padding-top: 4px;
}

@media (max-width: 1120px) {
  .main-layout {
    grid-template-columns: 1fr;
  }

  .template-workspace-main {
    overflow-y: auto;
  }

  .template-workspace-layout {
    grid-template-columns: 1fr;
    height: auto;
  }

  .template-preview-panel {
    min-height: var(--template-workspace-height);
  }

  .template-config-panel {
    height: auto;
    max-height: none;
  }
}

@media (max-width: 720px) {
  .app-header {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
    padding-right: 112px;
  }

  .app-header h1 {
    max-width: 100%;
  }

  .page-turn-button {
    width: 50px;
    height: 104px;
    min-width: 50px;
  }

  .page-turn-next {
    width: 76px;
    min-width: 76px;
  }

  .page-turn-button span {
    font-size: 26px;
  }

  .page-turn-button small {
    font-size: 10px;
  }

  .main {
    padding: 10px;
  }

  .dropzone-copy,
  .actions,
  .result-header {
    flex-direction: column;
    align-items: stretch;
  }

  .local-tools {
    display: grid;
    grid-template-columns: 1fr;
  }

  .ec-import-row {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .ec-import-row button {
    width: 100%;
  }

  .equipinfo-source-grid,
  .equipinfo-locale-field {
    display: grid;
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .equipinfo-form-head,
  .equipinfo-action-buttons {
    flex-wrap: wrap;
  }

  .equipinfo-form-head {
    align-items: flex-start;
  }

  .public-tool-grid {
    grid-template-columns: 1fr;
  }

  .result-header.compact {
    align-items: stretch;
  }

  .custom-template-head {
    flex-wrap: wrap;
  }

  .template-section-title-row,
  .template-selector-dialog-head,
  .template-import-head {
    flex-direction: column;
    align-items: stretch;
  }

  .template-meta-panel {
    grid-template-columns: minmax(0, 1fr);
  }

  .template-meta-author,
  .template-meta-actions {
    grid-column: 1 / -1;
  }

  .template-meta-actions {
    justify-self: start;
    width: auto;
  }

  .template-meta-actions button {
    width: auto;
  }

  .template-selector-dialog {
    max-height: 90vh;
    padding: 14px;
  }

  .template-selector-list {
    grid-template-columns: 1fr;
  }

  .template-selector-card {
    width: 100%;
    height: auto;
    min-height: 0;
  }

  .template-language-row {
    grid-template-columns: 1fr;
  }

  .template-bilingual-row {
    grid-template-columns: minmax(48px, max-content) minmax(58px, 1fr) 10px minmax(58px, 1fr);
    gap: 6px;
    padding-right: 80px;
  }

  .template-crop-head,
  .template-crop-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .template-download-button,
  .template-section-title-row button,
  .template-import-actions button {
    width: 100%;
  }

  .copy-format-controls {
    justify-self: start;
  }

  .segmented-button {
    flex: 0 0 auto;
  }

  .template-reference-group > span {
    flex-basis: 100%;
  }

  .editor-row {
    grid-template-columns: 1fr;
  }

  .card-editor {
    grid-template-columns: 1fr;
  }

  .equipinfo-card-editor {
    grid-template-columns: 1fr;
  }

}
