html,
body {
  height: 100%;
  margin: 0;
  padding: 0;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.main-content {
  flex: 1 1 0;
  display: flex;
  flex-direction: row;
  min-height: 0;
}

body {
  font-family: 'Segoe UI', Arial, sans-serif;
  margin: 0;
  padding: 0;
  background: #181c20;
  color: #f3f3f3;
  min-height: 100vh;
}

h1 {
  text-align: center;
  margin: 0;
  padding: 0.5rem;
  font-size: 2.2rem;
  letter-spacing: 1px;
}

.section {
  background: #23272b;
  border-radius: 10px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  padding: 1.2rem;
  max-width: 700px;
  position: relative;
}

.section h2 {
  margin-top: 0;
  margin-bottom: 0.5em;
}

label {
  display: block;
  margin-bottom: 1rem;
  font-weight: 500;
}

input[type='file'],
input[type='text'] {
  background: #222;
  color: #f3f3f3;
  border: 1px solid #444;
  border-radius: 5px;
  padding: 0.5em;
  margin-top: 0.3em;
  display: block;
  width: 100%;
  height: 2.3rem;
  max-width: 350px;
  box-sizing: border-box;
}

button {
  background: #2d8cf0;
  color: #fff;
  border: none;
  border-radius: 5px;
  padding: 0.7em 1.5em;
  font-size: 1em;
  cursor: pointer;
  transition: background 0.2s;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}
button:hover {
  background: #106adf;
}

button.secondary {
  background: #444;
}
button.secondary:hover,
button.secondary:focus {
  background: #666;
}

.preset-row button {
  font-size: 0.95rem;
  padding: 0.4em;
}

.main-content {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  justify-content: center;
  gap: 1rem;
  max-width: 1600px;
  margin: 0 auto;
  width: 100%;
  height: calc(100vh - 6rem);
  padding: 1rem;
  box-sizing: border-box;
}

.controls-group,
.editor-group {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.controls-group {
  flex: 0 0 370px;
  min-width: 320px;
  max-width: 420px;
}

.editor-group {
  flex: 2 1 0;
  min-width: 400px;
  display: flex;
  flex-direction: column;
  height: 100%;
}

.editor-group .section {
  max-width: none;
  height: 100%;
  display: flex;
  flex-direction: column;
}

#input-section,
#preset-section {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

#input-section label {
  margin-bottom: 0;
}

#input-section input[type='file'],
#input-section input[type='text'] {
  margin-top: 0.2em;
  margin-bottom: 0;
}

#editor {
  width: 100% !important;
  height: 100% !important;
  min-height: 350px;
  flex: 1 1 0;
  border: 1px solid #444;
  border-radius: 5px;
  background: #1e1e1e;
}

.tooltip {
  position: relative;
  cursor: help;
  border-bottom: 1px dotted #aaa;
}

.preset-tooltip {
  position: relative;
  display: inline-block;
  cursor: help;
  color: #8ec6f7;
  font-size: 1.1em;
  border-radius: 50%;
  width: 1.5em;
  height: 1.5em;
  text-align: center;
  line-height: 1.5em;
  background: #181c20;
  border: 1px solid #2d8cf0;
  margin-left: 0.3em;
}

.tooltiptext {
  visibility: hidden;
  width: 260px;
  background-color: #252525;
  color: #fff;
  text-align: left;
  border-radius: 6px;
  padding: 0.7em;
  position: absolute;
  z-index: 20;
  left: 105%;
  top: 50%;
  bottom: auto;
  transform: translateY(-50%);
  opacity: 0;
  transition: opacity 0.2s;
  font-size: 0.95rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
  max-width: 90vw;
  box-sizing: border-box;
  white-space: normal;
  word-break: break-word;
}

.tooltip:hover .tooltiptext,
.tooltip:focus .tooltiptext,
.preset-tooltip:hover .tooltiptext,
.preset-tooltip:focus .tooltiptext {
  visibility: visible;
  opacity: 1;
}

.preset-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.preset-row button {
  flex: 1 1 0;
  width: auto;
  min-width: 4em;
}

.disabled-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(24, 28, 32, 0.7);
  z-index: 10;
  pointer-events: all;
  display: block;
}

.overlay-message {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: #fff;
  font-size: 1.1em;
  text-align: center;
  opacity: 0.8;
}

.editor-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1em;
  margin-bottom: 1em;
}
.editor-header h2 {
  margin: 0;
}
.editor-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7em;
  align-items: center;
}

.editor-actions button {
  margin: 0;
  min-width: 110px;
}

.source-link {
  text-align: center;
  opacity: 0.7;
}
.source-link a {
  color: #8ec6f7;
  text-decoration: none;
  transition: color 0.2s;
}
.source-link a:hover {
  color: #2d8cf0;
  text-decoration: underline;
  opacity: 1;
}

.preset-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1em;
}
.preset-notification {
  display: flex;
  gap: 0.7em;
  align-items: right;
  background: #23272b;
  color: #8ec6f7;
  border: 1px solid #2d8cf0;
  border-radius: 5px;
  padding: 0.5em 1em;
  font-size: 1em;
  right: 0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
  text-align: center;
  z-index: 30;
}
.preset-notification.show {
  opacity: 1;
  transition: opacity 0.3s;
}

@keyframes flash-notification {
  0% {
    background: #23272b;
  }
  20% {
    background: #2d8cf0;
    color: #fff;
  }
  100% {
    background: #23272b;
  }
}

.preset-notification.flash {
  animation: flash-notification 0.4s;
}

@media (max-width: 1100px) {
  h1 {
    font-size: 1.3rem;
  }
  h2 {
    font-size: 1.1rem;
  }
  .section {
    padding: 0.7rem;
  }
  .main-content {
    flex-direction: column;
    overflow-x: hidden;
  }
  .controls-group,
  .editor-group {
    max-width: 100%;
    width: 100%;
  }
  button {
    font-size: 0.95rem;
    padding: 0.4em;
  }
  /* Move preset tooltips to the left to keep them in the viewport */
  .preset-tooltip .tooltiptext {
    left: auto;
    right: 105%;
    top: 50%;
    bottom: auto;
    transform: translateY(-50%);
  }
  .preset-notification {
    font-size: 0.8rem;
  }
}

/* Make controls group a row at middle widths */
@media (max-width: 1100px) and (min-width: 651px) {
  .controls-group {
    flex-direction: row;
  }
  #input-section,
  #preset-section {
    flex: 1 1 0;
    max-width: 50%;
  }
}
