/* Brother MFC-7360N WebUSB Print — mobile-first UI */

:root {
  --bg: #14141f;
  --surface: #1f1f2e;
  --surface-2: #262638;
  --border: #353550;
  --text: #e8e8f0;
  --muted: #a0a0b8;
  --accent: #5b8cff;
  --accent-press: #3d6fe0;
  --ok: #3ecf8e;
  --danger: #ff6b6b;
  --radius: 12px;
  --tap: 48px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 17px;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
}

.app-header {
  padding: env(safe-area-inset-top) 16px 0;
  padding-top: max(16px, env(safe-area-inset-top));
  text-align: center;
}

.app-header h1 {
  font-size: 1.35rem;
  margin: 12px 0 4px;
}

.lede {
  color: var(--muted);
  margin: 0 0 8px;
  font-size: 0.95rem;
}

.app-main {
  max-width: 640px;
  margin: 0 auto;
  padding: 8px 16px 24px;
}

/* Dropzone (hero) */
.dropzone {
  margin: 20px 0;
}

.drop-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  min-height: 180px;
  padding: 28px 20px;
  background: var(--surface);
  color: var(--text);
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  text-align: center;
}

.drop-btn:active { transform: translateY(1px); }
.dropzone.is-drag .drop-btn {
  border-color: var(--accent);
  background: var(--surface-2);
}

.drop-icon {
  font-size: 2.4rem;
  line-height: 1;
  color: var(--accent);
  font-weight: 300;
}
.drop-title { font-size: 1.15rem; font-weight: 700; }
.drop-sub { font-size: 0.88rem; color: var(--muted); }

/* Filebar */
.work { margin-top: 8px; }

.filebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 8px 0 12px;
}
.filename {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.link {
  flex: none;
  background: none;
  border: 0;
  color: var(--accent);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  padding: 8px;
}

/* Fields */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.field > span {
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 600;
}

/* Checkbox field: checkbox inline with its label text */
.field-check {
  flex-direction: row;
  align-items: center;
  gap: 10px;
}

.field-check input[type="checkbox"] {
  width: auto;
  min-height: auto;
  margin: 0;
  accent-color: var(--accent);
}

textarea,
input[type="text"],
input[type="number"],
input[type="file"],
select {
  width: 100%;
  min-height: var(--tap);
  padding: 12px 14px;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  font: inherit;
}

textarea { min-height: 120px; resize: vertical; }

input[type="file"] { padding: 10px; }

select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
                    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
  background-size: 5px 5px;
  background-repeat: no-repeat;
}

textarea:focus,
input:focus,
select:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.hint { color: var(--muted); font-size: 0.85rem; margin: 4px 0 0; }

/* Controls grid */
.controls {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin: 8px 0 16px;
}

.controls .field { margin-bottom: 0; }

/* Brightness slider */
.range-field { margin: 4px 0 16px; }
.range-field > span { display: flex; align-items: center; gap: 6px; }
.range-field small { color: var(--text); font-weight: 700; min-width: 2.4em; }
.range-field em { color: var(--muted); font-style: normal; font-weight: 400; }
input[type="range"] {
  width: 100%;
  min-height: var(--tap);
  accent-color: var(--accent);
  background: transparent;
  border: 0;
  padding: 0;
}

/* Section titles */
.section-title {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 16px 0 8px;
}

/* Preview */
.preview-frame {
  display: flex;
  justify-content: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
}

#preview {
  background: #fff;
  max-width: 100%;
  height: auto;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
  image-rendering: auto;
}

/* Actions */
.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 20px 0;
}

.btn {
  min-height: var(--tap);
  padding: 12px 16px;
  border: 1px solid transparent;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  color: #fff;
}

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

.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-primary { background: var(--accent); }
.btn-primary:active:not(:disabled) { background: var(--accent-press); }

.btn-secondary { background: var(--surface-2); border-color: var(--border); }

.btn-ghost {
  grid-column: 1 / -1;
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}

.btn.is-connected { background: var(--ok); color: #0a2a1c; }

/* Log */
.log {
  background: #0c0c14;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  margin: 0;
  max-height: 220px;
  overflow: auto;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.8rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--muted);
}

.log .err { color: var(--danger); }
.log .ok { color: var(--ok); }

/* Collapsible sections (log + testing tools) */
.logbox,
.testing {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px 14px;
  margin: 16px 0;
}
.logbox[open],
.testing[open] { padding-bottom: 14px; }

.logbox > summary,
.testing > summary {
  min-height: var(--tap);
  display: flex;
  align-items: center;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  list-style: none;
}
.logbox > summary::-webkit-details-marker,
.testing > summary::-webkit-details-marker { display: none; }
.logbox > summary::before,
.testing > summary::before {
  content: "▸";
  margin-right: 8px;
  transition: transform 0.15s;
}
.logbox[open] > summary::before,
.testing[open] > summary::before { transform: rotate(90deg); }

.logbox .log { margin-top: 4px; }

/* Note + footer */
.note {
  color: var(--muted);
  font-size: 0.82rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  margin-top: 18px;
}

.app-footer {
  text-align: center;
  color: var(--muted);
  font-size: 0.78rem;
  padding: 16px;
  padding-bottom: max(16px, env(safe-area-inset-bottom));
}

.app-footer a { color: var(--accent); }

/* Wider screens */
@media (min-width: 560px) {
  .actions { grid-template-columns: 1fr 1fr 1fr; }
  .btn-ghost { grid-column: auto; }
}
