@font-face {
  font-family: "Candal";
  src: url("fonts/Candal-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  --workspace-width: min(92vw, 1560px);
  --sidebar-width: 420px;
}

body {
  margin: 0;
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  font-family: "Manrope", "Avenir Next", "Segoe UI", sans-serif;
  color: #0f172a;
  background:
    radial-gradient(circle at 8% 12%, #fde68a 0%, rgba(253, 230, 138, 0) 32%),
    radial-gradient(circle at 88% 5%, #bfdbfe 0%, rgba(191, 219, 254, 0) 36%),
    radial-gradient(circle at 84% 82%, #ddd6fe 0%, rgba(221, 214, 254, 0) 38%),
    linear-gradient(160deg, #f8fafc 0%, #eef2ff 100%);
}

.pageHeader {
  flex: 0 0 auto;
  width: var(--workspace-width);
  margin: 26px auto 14px;
}

.pageHeaderInline {
  display: flex;
  align-items: baseline;
  justify-content: flex-start;
  gap: 20px;
  flex-wrap: nowrap;
}

.pageHeader h1 {
  margin: 0;
  font-family: "Candal", "Avenir Next", "Segoe UI", sans-serif;
  font-size: clamp(2.4rem, 5vw, 4rem);
  font-weight: 900;
  letter-spacing: 0.01em;
  line-height: 0.95;
  color: #0b1226;
}

.pageHeader p {
  margin: 0;
  max-width: none;
  color: #475569;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mobileHeader {
  display: none;
}

.pageFooter {
  width: var(--sidebar-width);
  margin: 2px max(24px, calc((100vw - var(--workspace-width)) / 2)) 14px auto;
  font-size: 0.86rem;
  color: #64748b;
  text-align: center;
}

.pageFooter a {
  color: #1d4ed8;
  text-decoration: none;
}

.pageFooter a:hover {
  text-decoration: underline;
}

#beautifier {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: row;
  align-items: stretch;
  gap: 24px;
  width: var(--workspace-width);
  margin: 0 auto 30px;
}

#previewColumn {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 18px;
  background: linear-gradient(165deg, rgba(255, 255, 255, 0.85), rgba(248, 250, 252, 0.72));
  box-shadow: 0 24px 48px -36px #334155;
  padding: 24px;
  overflow: hidden;
}

#previewStage {
  flex: 1;
  min-height: 0;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
  scrollbar-gutter: stable both-edges;
}

#imagePreview {
  width: max-content;
  min-width: 100%;
  max-height: 100%;
  flex: 0 0 auto;
  display: flex;
  justify-content: center;
  align-items: center;
  line-height: 0;
}

#imageBackground {
  margin: 0 auto;
}

#texts {
  display: flex;
  line-height: 1;
  padding: 10px 0;
}

.captionText {
  width: 50%;
}

.captionTextLeft {
  text-align: left;
}

.captionTextRight {
  text-align: right;
}

#windowFrame {
  border-radius: inherit;
}

#windowFrameBar {
  display: none;
}

#windowFrameContent {
  border-radius: inherit;
}

#windowFrame.is-enabled {
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  background: #ffffff;
  box-shadow: 0 16px 26px -24px #334155;
  overflow: hidden;
}

#windowFrame.is-enabled #windowFrameBar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 7px 10px;
  border-bottom: 1px solid #dbe2ee;
  font-size: 0.72rem;
  line-height: 1;
}

#windowFrame.is-enabled #windowFrameContent {
  padding: 4px;
}

#windowFrameTitle {
  grid-column: 2;
  justify-self: center;
  color: #64748b;
  font-weight: 700;
}

#windowFrameMacControls,
#windowFrameWinControls {
  display: none;
  gap: 6px;
  min-width: 56px;
}

#windowFrameWinControls {
  grid-column: 3;
  justify-self: end;
  margin-left: auto;
}

#windowFrame.macos #windowFrameBar {
  background: linear-gradient(180deg, #f8fafc, #f1f5f9);
}

#windowFrame.macos #windowFrameMacControls {
  display: inline-flex;
}

#windowFrame.windows #windowFrameBar {
  background: #e8edf5;
}

#windowFrame.windows #windowFrameWinControls {
  display: inline-flex;
}

.windowDot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

.windowDot.red {
  background: #ff5f57;
}

.windowDot.yellow {
  background: #febc2e;
}

.windowDot.green {
  background: #28c840;
}

.windowControl {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  color: #334155;
  font-size: 0.62rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

#images {
  display: flex;
  justify-content: center;
}

#theImage {
  display: block;
  max-width: 100%;
  max-height: 65vh;
  box-shadow: 0 14px 30px -24px #0f172a;
  cursor: pointer;
}

#sidebar {
  width: var(--sidebar-width);
  min-height: 0;
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(8px);
  box-shadow: 0 24px 48px -36px #334155;
  overflow: hidden;
  height: 100%;
  display: flex;
  flex-direction: column;
}

#sidebarTabs {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px 20px 0;
  border-bottom: 1px solid rgba(148, 163, 184, 0.22);
  background: rgba(248, 250, 252, 0.8);
}

.sidebarTab {
  flex: 1;
  border: 1px solid transparent;
  border-radius: 10px 10px 0 0;
  background: rgba(255, 255, 255, 0.45);
  color: #64748b;
  font-weight: 700;
  padding: 10px 10px 9px;
  cursor: pointer;
  margin-bottom: -1px;
  transition: background-color 120ms ease, color 120ms ease, border-color 120ms ease;
}

.sidebarTab.is-active {
  background: #ffffff;
  border-color: rgba(148, 163, 184, 0.38);
  border-bottom-color: #ffffff;
  color: #0f172a;
}

.sidebarTab:not(.is-active):hover {
  background: rgba(255, 255, 255, 0.62);
  color: #334155;
}

#previewHelp {
  margin: 16px 0 0;
  width: 100%;
  text-align: center;
  color: #475569;
  font-size: 0.92rem;
}

#uploadImageLink {
  color: #2563eb;
  font-weight: 700;
}

#uploadImageLink:hover {
  color: #1d4ed8;
}

#screenshotInput {
  display: none;
}

#downloadButton {
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  display: inline-block;
  padding: 10px 14px;
  cursor: pointer;
  font-weight: 600;
  background: #ffffff;
  transition: transform 120ms ease, box-shadow 120ms ease, border-color 120ms ease;
}

#downloadButton:hover {
  border-color: #94a3b8;
  box-shadow: 0 12px 22px -18px #0f172a;
  transform: translateY(-1px);
}

#previewColumn.is-dragover {
  border-color: #2563eb;
  background: linear-gradient(165deg, rgba(255, 255, 255, 0.9), rgba(219, 234, 254, 0.6));
}

.input {
  padding: 4px 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.95rem;
}

.input input {
  margin: 0;
}

.tabTextInput {
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  padding: 8px 10px;
  background: linear-gradient(180deg, #ffffff, #f8fafc);
  color: #0f172a;
  font-weight: 500;
}

.tabTextInput::placeholder {
  color: #94a3b8;
}

.tabTextInput:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.input .controls {
  display: flex;
  flex-direction: row;
  gap: 8px;
}

.presetActions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.presetRow {
  display: flex;
  gap: 8px;
}

.presetRow .panelButton {
  flex: 1;
}

.presetHint {
  margin: 2px 2px 0;
  font-size: 0.8rem;
  color: #64748b;
}

#presetList {
  max-height: none;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border: 1px solid #bfdbfe;
  border-radius: 12px;
  background: linear-gradient(180deg, #ffffff, #f8fbff);
  padding: 8px;
  flex: 1;
}

#predefinedPresetList {
  max-height: none;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border: 1px solid #dbeafe;
  border-radius: 12px;
  background: linear-gradient(180deg, #ffffff, #f8fbff);
  padding: 8px;
  flex: 1;
}

#presetsPanel .settingGroup {
  height: 99%;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

#presetsPanel .settingGroupContent {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 0;
}

.presetSection {
  display: flex;
  flex-direction: column;
  gap: 6px;
  border: 1px solid rgba(148, 163, 184, 0.24);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.72);
  padding: 8px;
  flex: 1;
  min-height: 0;
}

.presetEmpty {
  color: #64748b;
  font-size: 0.9rem;
  padding: 8px;
}

.presetCard {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid #dbeafe;
  border-radius: 10px;
  background: #ffffff;
  padding: 4px;
}

.presetCard.is-active {
  border-color: #60a5fa;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.12);
}

.presetLoadButton {
  flex: 1;
  border: 0;
  background: transparent;
  color: #0f172a;
  text-align: left;
  font-weight: 600;
  padding: 7px 8px;
  border-radius: 8px;
  cursor: pointer;
}

.presetLoadButton:hover {
  background: #eff6ff;
}

.presetRemoveButton {
  width: 28px;
  height: 28px;
  border: 1px solid #fecaca;
  border-radius: 8px;
  background: #fef2f2;
  color: #b91c1c;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
}

.presetRemoveButton:hover {
  border-color: #fca5a5;
}

.panelButton {
  border: 1px solid #cbd5e1;
  border-radius: 9px;
  background: #ffffff;
  color: #0f172a;
  padding: 8px 10px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease, border-color 120ms ease;
}

.panelButton:hover {
  border-color: #94a3b8;
  transform: translateY(-1px);
  box-shadow: 0 10px 20px -16px #0f172a;
}

.panelButton.is-active {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

body.is-color-picking #theImage {
  cursor: crosshair;
}

.saveButton {
  background: linear-gradient(120deg, #2563eb, #0ea5e9);
  color: #ffffff;
  border-color: transparent;
}

.dangerButton {
  background: #fef2f2;
  color: #b91c1c;
  border-color: #fecaca;
}

.dangerButton:hover {
  border-color: #fca5a5;
  box-shadow: 0 10px 20px -16px #b91c1c;
}

.exportButton,
.importButton {
  background: #f8fafc;
}

#importPresetInput {
  display: none;
}

.sidebarPanel {
  flex: 1;
  min-height: 0;
  padding: 12px 20px 22px;
  display: block;
  overflow-y: scroll;
  overscroll-behavior: contain;
}

.sidebarPanel[hidden] {
  display: none !important;
}

#sidebarActions {
  position: sticky;
  bottom: 0;
  padding: 12px 20px 16px;
  border-top: 1px solid rgba(148, 163, 184, 0.22);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(6px);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

#sidebarActions .compactInput {
  font-size: 0.84rem;
  color: #475569;
}

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

.compactSelectRow span {
  font-weight: 600;
  white-space: nowrap;
}

#sidebarActions select {
  width: auto;
  min-width: 72px;
  padding: 4px 26px 4px 10px;
  border-radius: 999px;
  border: 1px solid #cbd5e1;
  background: linear-gradient(180deg, #ffffff, #f8fafc);
  font-size: 0.84rem;
  font-weight: 700;
  color: #0f172a;
}

.sidebarPanel > * + * {
  margin-top: 10px;
}

#sidebar label {
  color: #334155;
}

.settingGroup {
  border: 1px solid rgba(148, 163, 184, 0.24);
  background: rgba(255, 255, 255, 0.78);
  border-radius: 14px;
  overflow: visible;
}

.settingGroup > summary {
  cursor: pointer;
  list-style: none;
  font-weight: 700;
  color: #0f172a;
  padding: 11px 12px;
  user-select: none;
}

.settingGroup > summary::-webkit-details-marker {
  display: none;
}

.settingGroup > summary::after {
  content: "+";
  float: right;
  color: #64748b;
}

.settingGroup[open] > summary {
  border-bottom: 1px solid rgba(148, 163, 184, 0.2);
  background: rgba(255, 255, 255, 0.9);
}

.settingGroup[open] > summary::after {
  content: "-";
}

.settingGroupContent {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 12px;
}

#settings .settingGroupContent > .input,
#settings .settingGroupContent > #backgroundColor {
  padding: 4px 0;
}

#backgroundColor > label,
#customBackgroundGradient label,
#generatedBackgroundGradient label {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

#dirLabel {
  white-space: nowrap;
}

.textSubgroup {
  border: 1px solid rgba(148, 163, 184, 0.24);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.64);
}

.textSubgroup > summary {
  cursor: pointer;
  list-style: none;
  font-weight: 700;
  color: #0f172a;
  font-size: 0.9rem;
  padding: 10px 12px;
  user-select: none;
}

.textSubgroup > summary::-webkit-details-marker {
  display: none;
}

.textSubgroup > summary::after {
  content: "+";
  float: right;
  color: #64748b;
}

.textSubgroup[open] > summary::after {
  content: "-";
}

.textSubgroupContent {
  padding: 0 12px 10px;
}

.inlineToggle {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}

.inlineToggle input {
  margin: 0;
}

#settings input[type="number"] {
  width: 68px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 4px 6px;
}

#settings select,
#settings input[type="color"] {
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 6px;
  background: #ffffff;
}

#settings input[type="range"] {
  width: 100%;
  accent-color: #2563eb;
}

#settings input[type="color"] {
  width: 100%;
  height: 44px;
  border-radius: 10px;
  padding: 3px;
  cursor: pointer;
}

.colorInputWithPicker {
  display: flex;
  align-items: center;
  gap: 8px;
}

.colorInputWithPicker .panelButton {
  white-space: nowrap;
  height: 44px;
  min-width: 74px;
  padding: 0 12px;
  font-size: 0.82rem;
}

#settings input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 0;
}

#settings input[type="color"]::-webkit-color-swatch {
  border: none;
  border-radius: 8px;
}

#settings input[type="color"]::-moz-color-swatch {
  border: none;
  border-radius: 8px;
}

#downloadButton {
  width: 100%;
  background: linear-gradient(120deg, #0891b2, #2563eb);
  color: #ffffff;
  border: 0;
  padding: 12px;
}

@media (max-width: 1080px) {
  .pageHeader {
    display: none;
  }

  .mobileHeader {
    display: block;
    width: calc(100% - 24px);
    margin: 16px auto;
    font-family: "Candal", "Avenir Next", "Segoe UI", sans-serif;
    font-size: clamp(2rem, 8vw, 2.6rem);
    font-weight: 800;
    letter-spacing: 0.01em;
    color: #0b1226;
    line-height: 1;
  }

  body {
    height: auto;
    min-height: 100vh;
    overflow: auto;
  }

  #beautifier {
    flex-direction: column;
    width: calc(100% - 24px);
    height: auto;
    min-height: 0;
    margin: 0 auto 16px;
    gap: 12px;
  }

  #previewColumn {
    min-height: 52vh;
    padding: 12px;
  }

  #previewStage {
    overflow: auto;
  }

  #imagePreview {
    width: 100%;
  }

  #sidebar {
    width: 100%;
    height: auto;
    max-height: none;
  }

  .sidebarPanel {
    max-height: 42vh;
  }

  #sidebarActions {
    position: static;
  }

  .pageFooter {
    width: calc(100% - 24px);
    margin: 0 auto 16px;
    text-align: center;
  }
}

@media (max-width: 640px) {
  #theImage {
    max-height: 46vh;
  }

  #sidebarTabs {
    padding: 10px 12px 8px;
  }

  .sidebarPanel {
    padding: 10px 12px 14px;
  }
}
