:root {
  --sand: #141414;
  --forest: #4d8de8;
  --fern: #2f6fc1;
  --stone: #2a2a2a;
  --ink: #f2f2f2;
  --sun: #f0b45e;
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
}

* {
  box-sizing: border-box;
  scrollbar-color: #3a3a3a #0f0f0f;
  scrollbar-width: thin;
}

*::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

*::-webkit-scrollbar-track {
  background: #0f0f0f;
}

*::-webkit-scrollbar-thumb {
  background: #3a3a3a;
  border-radius: 999px;
  border: 2px solid #0f0f0f;
}

*::-webkit-scrollbar-thumb:hover {
  background: #4a4a4a;
}

body {
  margin: 0;
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at top left, #1f2a25 0%, #141414 45%, #0b0b0b 100%);
  min-height: 100vh;
  color-scheme: dark;
}

.app-header {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: start;
  padding: 24px 40px 10px;
}

.header-copy {
  grid-column: 2;
  text-align: center;
}

.app-header h1 {
  margin: 0;
  font-family: "Palatino Linotype", "Book Antiqua", serif;
  font-size: 34px;
  letter-spacing: 0.5px;
  color: var(--forest);
}

.app-title-inline {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.app-title-icon {
  display: block;
  width: auto;
  height: 1.1em;
  object-fit: contain;
  border-radius: 8px;
  flex: 0 0 auto;
}

.app-header p {
  margin: 6px 0 0;
  color: #a4b3ac;
}

.header-actions {
  grid-column: 3;
  justify-self: end;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.btn {
  border: none;
  border-radius: 8px;
  padding: 10px 18px;
  font-size: 14px;
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease;
}

.btn.primary {
  background: var(--forest);
  color: #fff;
  box-shadow: var(--shadow);
}

.btn.ghost {
  background: transparent;
  border: 1px solid var(--forest);
  color: var(--forest);
}

.btn:hover {
  transform: translateY(-1px);
}

.layout {
  display: grid;
  grid-template-columns: 1fr 1.1fr;
  gap: 24px;
  padding: 16px 40px 40px;
}

.panel {
  background: #1c1c1c;
  border-radius: 18px;
  padding: 24px;
  box-shadow: var(--shadow);
}

dialog,
[role="dialog"],
.modal,
.popup {
  background: #1c1c1c;
  color: var(--ink);
  border: 1px solid #343434;
  box-shadow: var(--shadow);
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.68);
}

.form-panel h2,
.preview-panel h2 {
  margin-top: 0;
  font-family: "Palatino Linotype", "Book Antiqua", serif;
  color: var(--forest);
}

.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 18px;
  margin-bottom: 18px;
}

label {
  display: flex;
  flex-direction: column;
  font-size: 13px;
  color: #b8c5bf;
  gap: 6px;
}

.directory-field {
  position: relative;
}

.directory-suggestions {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 25;
  max-height: 260px;
  overflow-y: auto;
  border: 1px solid #343434;
  border-radius: 12px;
  background: #101010;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
}

.directory-suggestions.hidden {
  display: none;
}

.directory-suggestion {
  padding: 10px 12px;
  cursor: pointer;
  border-bottom: 1px solid #252525;
}

.directory-suggestion:last-child {
  border-bottom: none;
}

.directory-suggestion:hover {
  background: #1a1a1a;
}

.directory-suggestion-name {
  font-size: 14px;
  color: #f2f2f2;
}

.directory-suggestion-meta {
  margin-top: 3px;
  font-size: 12px;
  color: #8ea2b3;
}

input,
select {
  border-radius: 10px;
  border: 1px solid #343434;
  padding: 9px 12px;
  font-size: 14px;
  background: #111;
  color: var(--ink);
}

input:focus,
select:focus {
  outline: none;
  border-color: rgba(77, 141, 232, 0.78);
  box-shadow: 0 0 0 3px rgba(77, 141, 232, 0.18);
}

input::placeholder {
  color: #8ea2b3;
}

select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, rgba(242, 242, 242, 0.82) 50%),
    linear-gradient(135deg, rgba(242, 242, 242, 0.82) 50%, transparent 50%);
  background-position:
    calc(100% - 18px) calc(50% - 3px),
    calc(100% - 12px) calc(50% - 3px);
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  padding-right: 36px;
}

select option,
select optgroup {
  background: #111;
  color: #f2f2f2;
}

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

.preview-title {
  display: flex;
  align-items: center;
  gap: 6px;
}

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

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #b8c5bf;
  position: relative;
  flex-direction: row;
  justify-content: flex-start;
}

.toggle input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.toggle .slider {
  width: 40px;
  height: 22px;
  border-radius: 999px;
  background: #222;
  border: 1px solid #3b3b3b;
  position: relative;
  transition: background 160ms ease, border-color 160ms ease;
}

.toggle .slider::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #b8c5bf;
  top: 2px;
  left: 2px;
  transition: transform 160ms ease, background 160ms ease;
}

.toggle input:checked + .slider {
  background: #1f3d34;
  border-color: #2f6f5f;
}

.toggle input:checked + .slider::after {
  transform: translateX(18px);
  background: #e6f2ee;
}

.toggle-label {
  letter-spacing: 0.2px;
}

.preview-frame {
  border: 1px dashed #343434;
  border-radius: 16px;
  height: 520px;
  overflow: hidden;
  background: #fff;
}

.preview-frame iframe {
  width: 100%;
  height: 100%;
  border: none;
}

.status {
  background: rgba(240, 180, 94, 0.2);
  color: #f0b45e;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
}

.status.pulse {
  animation: pulse 0.35s ease-in-out;
}

@keyframes pulse {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
  100% {
    transform: scale(1);
  }
}

.hint {
  margin-top: 14px;
  font-size: 12px;
  color: #8b9992;
}

.version-pill {
  position: fixed;
  left: 16px;
  bottom: 14px;
  padding: 6px 12px;
  border-radius: 999px;
  background: #191919;
  border: 1px solid #2e2e2e;
  color: #8b9992;
  font-size: 11px;
  letter-spacing: 0.3px;
  box-shadow: var(--shadow);
  pointer-events: none;
}

@media (max-width: 1100px) {
  .layout {
    grid-template-columns: 1fr;
  }

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

  .app-header {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .header-copy,
  .header-actions {
    grid-column: 1;
    justify-self: stretch;
  }

  .header-actions {
    justify-content: center;
  }
}

@media (max-width: 900px) {
  .app-header {
    padding: 18px 18px 8px;
  }

  .layout {
    gap: 16px;
    padding: 14px 18px 24px;
  }

  .panel {
    padding: 18px;
    border-radius: 16px;
  }

  .preview-header,
  .preview-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .btn {
    width: 100%;
  }

  .preview-frame {
    height: 420px;
  }
}
