:root {
  --bg: #f7f7f8;
  --panel: #ffffff;
  --muted: #6b7280;
  --accent: #0b5fff;
  --border: #e5e7eb;
  --editor-bg: #0f1720;
  --editor-fg: #e6eef6;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, "Roboto Mono", monospace;
}

/* ===== Base ===== */
* {
  box-sizing: border-box;
  max-width: 100%;
}

html, body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: #0f1720;
  display: flex;
  flex-direction: column;
  font-family: Inter, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ===== Header ===== */
.topbar {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 12px;
  padding: 12px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}

.brand {
  flex: 1 1 auto;
  min-width: 240px;
  padding-right: 12px;
}

.brand h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}

.brand p.muted {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
  max-width: 800px;
  word-break: break-word;
}

/* ===== Controls ===== */
.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
  transition: all 0.3s ease;
}

.controls button {
  background: var(--panel);
  border: 1px solid var(--border);
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  white-space: nowrap;
  transition: background 0.2s;
}

.controls button.primary {
  background: var(--accent);
  color: #fff;
  border: none;
}

.controls button.danger {
  background: #ef4444;
  color: #fff;
  border: none;
}

.controls button:hover:not(.primary):not(.danger) {
  background: #f3f4f6;
}

/* ===== Menu Toggle ===== */
.menu-toggle {
  position: absolute;
  top: 14px;
  right: 16px;
  font-size: 22px;
  border: none;
  background: transparent;
  cursor: pointer;
  color: #0f1720;
  padding: 6px 10px;
  transition: background 0.2s ease;
  display: none; /* hidden on desktop */
}

.menu-toggle:hover {
  background: #f3f4f6;
  border-radius: 6px;
}

.menu-toggle:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ===== Layout ===== */
main.layout.full {
  display: flex;
  flex-direction: column;
  flex: 1;
  height: 100%;
  overflow: hidden;
}

.panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--border);
  min-height: 0;
}

.title {
  padding: 10px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  color: var(--muted);
  background: var(--panel);
}

.editor-wrap {
  flex: 1;
  display: flex;
  background: var(--editor-bg);
}

/* ===== Textareas ===== */
#htmlInput, #encodedOutput {
  flex: 1;
  padding: 14px 16px;
  border: none;
  resize: none;
  outline: none;
  background: transparent;
  color: var(--editor-fg);
  font-family: var(--mono);
  font-size: 15px;
  line-height: 1.6;
  overflow: auto;
}

#encodedOutput {
  background: #fafafa;
  color: #0f1720;
}

.editor-footer {
  padding: 8px 12px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  background: var(--panel);
  flex-wrap: wrap;
}

/* ===== Toast ===== */
.toast {
  position: fixed;
  bottom: 18px;
  right: 18px;
  background: #111827;
  color: #fff;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 14px;
  display: none;
  z-index: 10;
}
.toast.show { display: block; }

/* ===== Footer ===== */
.bottombar {
  background: var(--panel);
  border-top: 1px solid var(--border);
  padding: 8px 16px;
  text-align: center;
}

/* ===== Responsive ===== */

/* Tablet / Medium screens */
@media (max-width: 1024px) {
  .brand p.muted {
    max-width: 100%;
  }
  .controls {
    flex-wrap: wrap;
    justify-content: flex-start;
  }
}

/* Mobile */
@media (max-width: 850px) {
  .menu-toggle {
    display: block; /* visible on mobile */
  }

  .controls {
    width: 100%;
    display: none;
    flex-direction: column;
    align-items: stretch;
    margin-top: 8px;
  }

  .controls.open {
    display: flex;
  }

  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .brand {
    padding-right: 40px;
  }

  .controls button {
    width: 100%;
    text-align: center;
  }

  main.layout.full {
    flex-direction: column;
  }

  #htmlInput, #encodedOutput {
    font-size: 16px;
    padding: 14px;
  }

  .toast {
    bottom: 10px;
    right: 10px;
    font-size: 13px;
  }
}

/* Extra Small Devices */
@media (max-width: 480px) {
  .brand h1 {
    font-size: 16px;
  }
  .brand p.muted {
    font-size: 12px;
  }
  .controls button {
    font-size: 13px;
    padding: 8px;
  }
  #htmlInput, #encodedOutput {
    font-size: 13px;
  }
}