
:root {
  --bg: #eef1f4;
  --panel: #ffffff;
  --line: #d0d5dd;
  --line-soft: #eaecf0;
  --ink: #1f2937;
  --muted: #475467;
  --action: #0ba1a1;
  --action-dark: #107275;
  --theme-link: #d76b4a;
  --theme-title: #078e8e;
  --theme-text: #333333;
  --theme-menu-bg: #f6f6f6;
  --theme-menu-text: #000000;
  --theme-panel-bg: #ffffff;
  --theme-box-bg: #ffffff;
}

@font-face {
  font-family: "Material Symbols Outlined";
  font-style: normal;
  font-weight: 100 700;
  src: url("../vendor/material-symbols/MaterialSymbolsOutlined.woff2") format("woff2");
}

.material-symbols-outlined {
  font-family: "Material Symbols Outlined";
  font-weight: normal;
  font-style: normal;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  display: inline-block;
  white-space: nowrap;
  word-wrap: normal;
  direction: ltr;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "liga";
}

.trial-notice {
  margin: 12px 12px 0;
  border: 1px solid #e6ca75;
  background: #f7efd2;
  color: #7a5b0b;
  border-radius: 6px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.trial-notice p {
  margin: 0;
  flex: 1;
}

.trial-notice button {
  border: 0;
  background: transparent;
  color: #8b7a57;
  font-size: 1.6rem;
  line-height: 1;
  padding: 0 4px;
}

.trial-notice.hidden {
  display: none;
}

.busy-overlay {
  position: absolute;
  inset: 48px 0 0 0;
  z-index: 40;
  display: grid;
  place-items: center;
  background: rgb(15 23 42 / 0.18);
  backdrop-filter: blur(1px);
  border-radius: 0 0 8px 8px;
}

.busy-card {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 210px;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid #c9d3e1;
  background: #fff;
  color: #253041;
  box-shadow: 0 10px 24px rgb(16 24 40 / 0.14);
  font-weight: 700;
}

.busy-spinner {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 3px solid #d3dde9;
  border-top-color: var(--action);
  animation: busy-spin .8s linear infinite;
}

@keyframes busy-spin {
  to {
    transform: rotate(360deg);
  }
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  height: 100%;
  font-family: "Catamaran", "Noto Sans", "DejaVu Sans", sans-serif;
  color: var(--ink);
  background: var(--bg);
}

body {
  min-height: 100dvh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(420px, 520px) 1fr;
  gap: 12px;
  flex: 1 1 auto;
  min-height: 0;
  padding: 12px;
  overflow: hidden;
}

.editor-panel,
.preview-panel {
  background: var(--theme-panel-bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 1px 2px rgb(16 24 40 / 0.06);
}

.editor-panel {
  overflow: auto;
  padding: 12px;
  background: #f8fafc;
}

.preview-panel {
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: 0;
  position: relative;
  height: 100%;
}

.panel-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.lang-select-wrap {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.88rem;
  color: #475467;
}

.lang-select-wrap select {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: #1d2939;
  min-width: 118px;
  padding: 4px 8px;
}

.preview-header {
  padding: 8px 12px;
  border-bottom: 1px solid var(--line-soft);
  background: #fbfcfd;
}

.preview-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.preview-toolbar {
  position: relative;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 6px;
}

.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.05rem;
  line-height: 1;
  padding: 0;
  border: 1px solid var(--line);
  background: #f8fafc;
}

.icon-btn:hover {
  border-color: #b5bcc7;
  background: #f2f4f7;
}

.icon-btn[aria-expanded="true"] {
  background: #e6f6f6;
  border-color: color-mix(in srgb, var(--action) 45%, #8aa0b2);
  color: var(--action-dark);
}

.icon-btn[aria-pressed="true"] {
  background: #fff3d6;
  border-color: #f2b84b;
  color: #b45309;
}

#previewInspectBtn[aria-pressed="false"] {
  animation: inspect-soft-pulse 1.9s ease-in-out infinite;
}

@keyframes inspect-soft-pulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgb(245 158 11 / 0);
    transform: scale(1);
  }
  50% {
    box-shadow: 0 0 0 6px rgb(245 158 11 / 0.24);
    transform: scale(1.045);
  }
}

.icon-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.preview-options-popover {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  width: min(420px, 80vw);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 12px 32px rgb(16 24 40 / 0.16);
  z-index: 30;
}

.preview-options-popover .section-content {
  padding: 10px;
}

.preview-options-popover .status-inline {
  margin: 0;
}

.sr-only {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.preview-header h2,
.panel-header h1 {
  margin: 0;
  font-size: 1.02rem;
  font-weight: 700;
  color: var(--action-dark);
}

.panel-header h1 {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.app-title-logo {
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
  display: block;
}

.panel-header p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.tabs {
  display: flex;
  gap: 8px;
  margin: 12px 0;
  border-bottom: 1px solid var(--line-soft);
  padding-bottom: 8px;
}

.editor-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 2px 0 10px;
}

.tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid #c9ced6;
  background: #f9f9f9;
  color: #596574;
  border-radius: 7px;
  padding: 6px 10px;
  cursor: pointer;
  font-weight: 600;
}

.tab-icon {
  width: 18px;
  height: 18px;
  display: inline-block;
  flex: 0 0 18px;
  font-size: 18px;
  line-height: 1;
  font-variation-settings: "FILL" 0, "wght" 400, "GRAD" 0, "opsz" 20;
  color: var(--action);
}

.tab.active {
  background: #fff;
  color: var(--action-dark);
  border-color: #bfc5ce;
  box-shadow: 0 1px 0 0 #fff inset;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.panel-block {
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 10px;
  background: #fff;
}

details {
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 10px;
  overflow: hidden;
  background: #fff;
  display: grid;
  grid-template-rows: auto 0fr;
  transition: grid-template-rows 320ms cubic-bezier(0.22, 0.61, 0.36, 1), border-color 220ms ease;
}

details[open] {
  grid-template-rows: auto 1fr;
}

summary {
  padding: 8px 10px;
  cursor: pointer;
  font-weight: 600;
  color: var(--action-dark);
  background: #f8fafc;
  border-bottom: 1px solid var(--line-soft);
}

.summary-icon {
  font-size: 18px;
  line-height: 1;
  margin-right: 6px;
  vertical-align: -3px;
  color: var(--action);
}

.section-content {
  padding: 10px;
}

details > .section-content {
  overflow: hidden;
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 260ms ease, transform 300ms cubic-bezier(0.22, 0.61, 0.36, 1);
}

details[open] > .section-content {
  opacity: 1;
  transform: translateY(0);
}

.section-title {
  margin: 0 0 8px;
  font-size: 0.95rem;
  color: var(--action-dark);
}

.section-icon {
  font-size: 18px;
  line-height: 1;
  margin-right: 6px;
  vertical-align: -3px;
  color: var(--action);
}

.inline-icon {
  font-size: 18px;
  line-height: 1;
  margin-right: 6px;
  vertical-align: -3px;
  color: currentColor;
}

.button-row {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.image-actions {
  display: none;
  margin-top: 0;
  margin-bottom: 8px;
}

.image-actions.active {
  display: flex;
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f9fafb;
  padding: 6px 10px;
  cursor: pointer;
  color: #344054;
  font-weight: 600;
  transition: background-color 150ms ease, border-color 150ms ease, box-shadow 150ms ease;
}

button:hover {
  border-color: #b9c1cd;
  background: #f3f4f6;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 0;
  box-shadow: 0 0 0 2px rgb(11 161 161 / 0.24);
}

#exportBtn,
#elpxPickBtn,
#exportElpxBtn {
  background: var(--action);
  border-color: var(--action);
  color: #fff;
}

#exportBtn:hover,
#elpxPickBtn:hover,
#exportElpxBtn:hover {
  background: var(--action-dark);
  border-color: var(--action-dark);
}

.file-label {
  display: inline-block;
  margin-bottom: 6px;
  font-weight: 600;
  color: var(--action-dark);
}

.load-group {
  border: 1px solid #e4ebf2;
  border-radius: 8px;
  background: #fafcff;
  padding: 10px;
  margin-bottom: 10px;
}

.load-group:last-of-type {
  margin-bottom: 6px;
}

.style-choice-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 10px;
}

.style-choice-col {
  min-width: 0;
}

#zipInput {
  width: 100%;
}

.file-picker-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

#zipPickBtn {
  background: var(--action);
  border-color: var(--action);
  color: #fff;
}

#zipPickBtn:hover {
  background: var(--action-dark);
  border-color: var(--action-dark);
}

.file-picked-name {
  color: var(--muted);
  font-size: 0.9rem;
}

#officialStyleSelect {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 8px;
  background: #fff;
}

#fileTypeFilter,
#fileNameFilter {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 8px;
  background: #fff;
  margin-bottom: 8px;
}

.official-preview {
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}

.official-preview.empty {
  padding: 8px;
  color: var(--muted);
  font-size: 0.9rem;
}

.official-preview.hidden {
  display: none;
}

.official-preview figure {
  margin: 0;
}

.official-preview img {
  display: block;
  width: 100%;
  height: auto;
  border-bottom: 1px solid var(--line);
  background: #f4f7fb;
}

.official-preview figcaption {
  padding: 8px 10px;
  display: grid;
  gap: 4px;
  font-size: 0.88rem;
}

.official-preview .title {
  font-weight: 700;
  color: var(--theme-title);
}

.official-preview .meta {
  color: var(--muted);
}

.official-preview .desc {
  color: var(--theme-text);
}

.status {
  margin: 10px 0 0;
  color: var(--muted);
  min-height: 1.2em;
}

.report {
  margin: 8px 0 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7fafc;
  padding: 8px;
  max-height: 180px;
  overflow: auto;
  white-space: pre-wrap;
}

.file-list {
  border: 1px solid var(--line);
  border-radius: 8px;
  max-height: 220px;
  overflow: auto;
  background: #fff;
}

.file-item {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  border-bottom: 1px solid var(--line-soft);
  background: transparent;
  border-radius: 0;
  padding: 7px 10px;
  color: #344054;
  font-weight: 500;
}

.file-group-header {
  padding: 6px 10px;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #667085;
  background: #f8fafc;
  border-bottom: 1px solid var(--line-soft);
  border-top: 1px solid var(--line-soft);
}

.file-item.active {
  background: #f0f9f9;
  color: #0f766e;
}

.editor-path {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.9rem;
}

.editor-surface {
  position: relative;
  overflow: hidden;
  border-radius: 6px;
}

.editor-inline-action {
  position: absolute;
  top: 8px;
  right: 20px;
  z-index: 4;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border-radius: 8px;
}

.editor-inline-action .inline-icon {
  font-size: 1rem;
  margin-right: 0;
  vertical-align: 0;
}

.editor-surface.has-inline-action #textEditor,
.editor-surface.has-inline-action .text-highlight {
  padding-top: 38px;
}

#textEditor {
  width: 100%;
  min-height: 260px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px;
  font-family: "DejaVu Sans Mono", monospace;
  font-size: 0.9rem;
  line-height: 1.5;
  background: #fff;
  position: relative;
  z-index: 2;
  overflow-wrap: normal;
  white-space: pre;
}

.text-highlight {
  display: none;
  margin: 0;
  position: absolute;
  inset: 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px;
  font-family: "DejaVu Sans Mono", monospace;
  font-size: 0.9rem;
  line-height: 1.5;
  white-space: pre;
  pointer-events: none;
  background: #f8fafc;
  scrollbar-width: none;
}

.text-highlight::-webkit-scrollbar {
  width: 0;
  height: 0;
}

.text-highlight.hljs {
  background: #f8fafc;
}

.editor-surface.syntax-active .text-highlight {
  display: block;
}

.editor-surface.syntax-active #textEditor {
  background: transparent;
  color: transparent;
  border-color: transparent;
  caret-color: #111827;
}

.editor-surface.syntax-active #textEditor::selection {
  background: rgb(15 23 42 / 0.16);
  color: transparent;
}

.binary-preview {
  display: none;
  margin-top: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 8px;
  overflow: auto;
}

.binary-preview.active {
  display: block;
}

.binary-preview img {
  display: block;
  max-width: 100%;
  max-height: 360px;
  width: auto;
  height: auto;
  margin: 0 auto;
}

.binary-preview .file-meta {
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
}

.font-quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 10px 6px;
}

.font-quick-actions button {
  padding: 5px 8px;
  font-size: 0.85rem;
}

.quick-grid {
  display: grid;
  gap: 10px;
}

.palette-compact {
  display: grid;
  gap: 10px 12px;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
}

.quick-grid label {
  display: grid;
  gap: 4px;
  font-size: 0.9rem;
}

.toggle-item {
  display: flex;
  align-items: center;
  gap: 10px;
}

.toggle-control {
  position: relative;
  display: inline-flex;
  width: 42px;
  min-width: 42px;
  height: 24px;
}

.toggle-input {
  position: absolute;
  opacity: 0;
  inset: 0;
  margin: 0;
  cursor: pointer;
  z-index: 2;
}

.toggle-visual {
  width: 100%;
  height: 100%;
  border-radius: 999px;
  background: #d3d8e0;
  border: 1px solid #bdc5cf;
  transition: background-color .2s ease, border-color .2s ease;
  position: relative;
  pointer-events: none;
}

.toggle-visual::after {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  left: 2px;
  top: 2px;
  background: #fff;
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.25);
  transition: transform .2s ease;
}

.toggle-input:checked + .toggle-visual {
  background: #0ba1a1;
  border-color: #0b8f8f;
}

.toggle-input:checked + .toggle-visual::after {
  transform: translateX(18px);
}

.toggle-input:focus-visible + .toggle-visual {
  box-shadow: 0 0 0 2px rgb(11 161 161 / 0.35);
}

.toggle-label {
  cursor: pointer;
  user-select: none;
}

.preview-toggle-list {
  display: grid;
  gap: 10px;
}

.quick-grid input[type="text"],
.quick-grid input[type="number"],
.quick-grid input[type="url"],
.quick-grid select {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 8px;
  background: #fff;
  color: #1d2939;
}

.quick-grid textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px;
  resize: vertical;
  min-height: 110px;
  font-family: inherit;
}

.quick-grid input[type="color"] {
  width: 56px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  padding: 2px;
}

.inline-two {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 12px;
}

.inline-three {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px 12px;
}

.info-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.info-grid .button-row,
.info-grid .status,
.info-grid .full-width {
  grid-column: 1 / -1;
}

.status-inline {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgb(15 23 42 / 0.35);
  z-index: 120;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
}

.modal-card {
  position: absolute;
  width: min(520px, 96vw);
  max-height: calc(100dvh - 24px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 18px 44px rgb(15 23 42 / 0.24);
  padding: 16px;
  display: grid;
  gap: 12px;
}

.modal-card-centered {
  position: relative;
}

.modal-card h3 {
  margin: 0;
  color: var(--action-dark);
  cursor: move;
  user-select: none;
}

.modal-card-centered h3 {
  cursor: default;
  user-select: text;
}

.click-selector {
  margin: 0;
  padding: 9px 10px;
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  background: #f8fafc;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9rem;
  color: #334155;
  overflow-wrap: anywhere;
}

.modal-card .status-inline {
  margin: 0;
}

.click-edit-grid {
  gap: 12px 16px;
}

.click-edit-grid label {
  display: grid;
  gap: 6px;
  font-weight: 600;
  color: #344054;
}

.click-edit-grid input[type="number"],
.click-edit-grid input[type="text"],
.click-edit-grid select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  background: #fff;
  color: #1d2939;
}

.click-edit-grid input[type="color"] {
  width: 100%;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 2px;
  background: #fff;
}

.click-edit-toggle {
  margin: 2px 0;
  padding: 8px 10px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: #f8fafc;
}

.click-edit-actions {
  justify-content: flex-end;
  gap: 8px;
  margin-top: 2px;
}

.click-edit-actions button {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 10px;
  min-height: 32px;
  border-radius: 6px;
  font-size: 0.96rem;
  font-weight: 600;
}

#clickEditCancelBtn {
  background: #fff;
  border-color: #c7ced8;
  color: #334155;
}

#clickEditCancelBtn:hover {
  background: #f8fafc;
  border-color: #b5beca;
}

#exportRenameHelp {
  min-height: 1.2em;
  color: #475467;
}

#exportRenameHelp.error {
  color: #b42318;
  font-weight: 600;
}

#exportRenameHelp.warn {
  color: #b54708;
  font-weight: 600;
}

#exportRenameCancelBtn {
  background: #fff;
  border-color: #c7ced8;
  color: #334155;
}

#exportRenameCancelBtn:hover {
  background: #f8fafc;
  border-color: #b5beca;
}

.group-card {
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  padding: 10px;
  background: #fbfcfd;
}

.group-title {
  margin: 0 0 8px;
  font-size: 0.95rem;
  color: var(--action-dark);
}

.nav-icon-grid {
  display: grid;
  gap: 8px;
}

#previewFrame {
  width: 100%;
  height: 100%;
  border: 0;
  border-radius: 0 0 10px 10px;
  background: #fff;
}


.app-footer {
  border-top: 1px solid var(--line-soft);
  background: #f8fafc;
  padding: 6px 12px 10px;
  text-align: center;
  color: var(--muted);
  font-size: 0.86rem;
}

.app-footer p {
  margin: 0;
}

.app-footer a {
  color: inherit;
}

@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(320px, 45vh) 1fr;
    height: 100%;
    min-height: 0;
  }

  .preview-panel {
    position: relative;
    top: auto;
    height: 100%;
  }

  .editor-panel {
    min-height: 50vh;
  }

  .inline-three {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .info-grid {
    grid-template-columns: 1fr;
  }

  .preview-header-top {
    align-items: flex-start;
  }

  .preview-options-popover {
    width: min(360px, 90vw);
  }
}

@media (max-width: 360px) {
  .palette-compact {
    grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  }

  .inline-two {
    grid-template-columns: 1fr;
  }

  .inline-three {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .click-edit-actions button {
    flex: 1 1 100%;
  }
}
