* {
  box-sizing: border-box;
}

html {
  font-family:
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
}

body {
  margin: 0;
  background: #f5f5f5;
  color: #111;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled,
input:disabled,
textarea:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}


/* =========================
   TOP BAR
========================= */

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;

  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;

  padding: 10px 14px;

  background: #111;
  color: white;
}

.brand {
  font-weight: 800;
  white-space: nowrap;
}

.top-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.top-actions button {
  min-height: 36px;
  padding: 6px 10px;

  border: 1px solid #555;
  border-radius: 7px;

  background: #222;
  color: white;
}

.top-actions .danger {
  border-color: #a33;
}


/* =========================
   APP
========================= */

.app {
  width: min(900px, 100%);
  margin: auto;
  padding: 14px;
  padding-bottom: 80px;
}

.section {
  margin-bottom: 18px;
}

.section-title {
  margin-bottom: 8px;
  font-size: 14px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #666;
}

.hidden {
  display: none !important;
}


/* =========================
   MENU / ACTION
========================= */

.menu-grid,
.action-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.menu-button,
.action-button {
  border: 1px solid #bbb;
  border-radius: 8px;
  background: white;
  color: #111;

  padding: 9px 13px;
  min-height: 42px;

  text-align: left;
}

.menu-button.active,
.action-button.active {
  border-color: #111;
  background: #111;
  color: white;
}


/* =========================
   FORM
========================= */

#formSection {
  background: white;
  border: 1px solid #ddd;
  border-radius: 10px;
  padding: 14px;
}

.field {
  margin-bottom: 12px;
}

.field-label {
  display: block;
  margin-bottom: 5px;

  font-size: 14px;
  font-weight: 700;
}

.input-row {
  display: flex;
  gap: 5px;
}

.input-row textarea,
.input-row input {
  flex: 1;
  min-width: 0;

  border: 1px solid #bbb;
  border-radius: 7px;

  padding: 8px 10px;

  background: white;
}

.input-row input {
  height: 40px;
}

.input-row textarea {
  min-height: 70px;
  resize: vertical;
}

.input-tool {
  width: 40px;
  min-width: 40px;

  padding: 0;

  border: 1px solid #bbb;
  border-radius: 7px;

  background: #eee;
}

.form-buttons {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}

.form-buttons button {
  min-height: 42px;
  padding: 8px 15px;

  border-radius: 7px;
  border: 1px solid #aaa;
}

.primary {
  background: #111;
  color: white;
  border-color: #111 !important;
}

.secondary {
  background: #eee;
  color: #111;
}

.form-buttons .primary {
  flex: 1;
}


/* =========================
   OUTPUT
========================= */

#outputSection {
  background: #111;
  color: white;

  border-radius: 10px;
  padding: 14px;
}

#outputStatus {
  margin-bottom: 8px;
  font-weight: 800;
}

.status-success {
  color: #76e39a;
}

.status-failed {
  color: #ff8585;
}

#output {
  margin: 0;

  max-height: 500px;
  overflow: auto;

  white-space: pre-wrap;
  word-break: break-word;

  font-family:
    ui-monospace,
    SFMono-Regular,
    Menlo,
    Consolas,
    monospace;

  font-size: 13px;
  line-height: 1.45;
}


/* =========================
   MODAL
========================= */

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;

  display: flex;
  align-items: center;
  justify-content: center;

  padding: 14px;

  background: rgba(0, 0, 0, 0.55);
}

.modal-box {
  width: min(600px, 100%);
  max-height: 90vh;
  overflow: auto;

  padding: 16px;

  background: white;
  border-radius: 10px;
}

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

  margin-bottom: 14px;
}

.modal-header h2 {
  margin: 0;
}

.icon-button {
  width: 36px;
  height: 36px;

  border: 0;
  border-radius: 50%;

  background: #eee;

  font-size: 22px;
}

.credential-row {
  display: flex;
  gap: 5px;
  margin-bottom: 7px;
}

.credential-row input {
  min-width: 0;
  flex: 1;

  height: 38px;

  border: 1px solid #bbb;
  border-radius: 6px;

  padding: 6px 8px;
}

.credential-row button {
  width: 38px;

  border: 1px solid #bbb;
  border-radius: 6px;

  background: #eee;
}

.full {
  width: 100%;
  min-height: 40px;
  margin-top: 8px;
}

.credential-tools {
  display: flex;
  gap: 7px;
  margin-top: 8px;
}

.credential-tools button {
  flex: 1;
  min-height: 40px;
}

.import-mode {
  margin-top: 10px;
  padding: 10px;

  background: #f1f1f1;
  border-radius: 7px;
}

.import-mode button {
  margin-top: 7px;
  min-height: 38px;
}

.modal hr {
  border: 0;
  border-top: 1px solid #ddd;
  margin: 18px 0;
}

.modal input[type="url"] {
  width: 100%;
  height: 40px;

  border: 1px solid #bbb;
  border-radius: 7px;

  padding: 8px;
}


/* =========================
   MOBILE
========================= */

@media (max-width: 600px) {

  .topbar {
    align-items: flex-start;
  }

  .top-actions {
    max-width: 70%;
  }

  .top-actions button {
    font-size: 12px;
  }

  .app {
    padding: 10px;
  }

  .menu-button,
  .action-button {
    min-height: 40px;
  }
}