:root {
  --bg: #eef1f5;
  --panel: #ffffff;
  --text: #1e2732;
  --muted: #667282;
  --line: #ccd4df;
  --line-strong: #aeb9c7;
  --accent: #0d6b9f;
  --accent-dark: #064a72;
  --soft: #e8f4fb;
  --bad: #a43f28;
  --ok: #1f7a4b;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
  font-size: 15px;
}

button, textarea, select, input { font: inherit; box-sizing: border-box; }

.page {
  width: min(980px, calc(100% - 24px));
  margin: 18px auto;
}

.top-line {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 10px;
}

.home-brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  flex: 0 0 auto;
  min-height: 56px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 10px 28px rgba(32, 42, 55, .10);
  color: #1f2937;
  text-decoration: none;
  font-size: 20px;
  font-weight: 800;
  line-height: 1;
  padding: 8px 14px 8px 10px;
}

.home-brand img {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: contain;
  background: #f1f2f3;
  padding: 6px;
}

.disclaimer {
  flex: 1 1 auto;
  border: 1px solid #e1ad72;
  border-radius: 6px;
  background: #fff7e8;
  color: #7a3d08;
  padding: 11px 14px;
  font-weight: 700;
}
.tool {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 18px 44px rgba(32, 42, 55, .14);
  overflow: hidden;
}

.head, .paste-box, .controls, .edits, .history-panel, .result-grid {
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

.head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  background: #f8fafc;
}

.language-control {
  min-width: 150px;
}

.language-control select {
  min-width: 130px;
}

.head p, .paste-box p, .status, .summary, label span {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

h1, h2 { margin: 0; letter-spacing: 0; }
h1 { margin-top: 2px; font-size: clamp(24px, 4vw, 34px); line-height: 1.05; }
.head .brand-scope { margin-top: 7px; max-width: 760px; color: var(--muted); font-size: 12px; line-height: 1.35; font-weight: 700; }
h2 { font-size: 17px; }

button, .file-button {
  min-height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #fff;
  color: var(--accent-dark);
  padding: 8px 12px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

button:hover, .file-button:hover { border-color: var(--accent); background: var(--soft); }
button:disabled { opacity: .55; cursor: default; }

.paste-box {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
}

.file-button input { display: none; }

.qr-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.camera-panel {
  display: grid;
  gap: 10px;
  width: calc(100% - 40px);
  margin: 18px 20px 0;
}

.camera-panel[hidden] { display: none; }

#cameraVideo {
  width: 100%;
  max-height: 52vh;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #101720;
  object-fit: cover;
}

#stopCamera { justify-self: start; }

textarea {
  display: block;
  width: calc(100% - 40px);
  min-height: 132px;
  margin: 18px 20px 6px;
  resize: vertical;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  padding: 12px;
  background: #fbfdff;
  color: #101720;
  font-family: Consolas, "Courier New", monospace;
  outline: none;
}

textarea:focus, select:focus, input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(13, 107, 159, .13);
}

.status { padding: 0 20px 16px; font-weight: 600; }
.status.error { color: var(--bad); }
.status.ok { color: var(--ok); }

.controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  column-gap: 18px;
  row-gap: 14px;
}

label { display: grid; gap: 7px; }

select, .edit-row input, .edit-row select {
  width: 100%;
  min-width: 0;
  min-height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 7px 10px;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.edit-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.edit-rows { display: grid; gap: 9px; }

.edit-row {
  display: grid;
  grid-template-columns: 96px minmax(160px, 220px) minmax(0, 1fr) 42px;
  column-gap: 12px;
  row-gap: 8px;
  align-items: end;
}

.edit-row button, #clearHistory, #deleteHistory, #deleteEditSet { color: var(--bad); }

.history-title-row { margin-bottom: 0; }

.result-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 18px;
  border-bottom: 0;
}

.result-field {
  min-height: 190px;
  max-height: 360px;
  overflow: auto;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #fbfdff;
  color: #101720;
  padding: 12px;
  font-family: Consolas, "Courier New", monospace;
  font-size: 13px;
  line-height: 1.55;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  outline: none;
  user-select: text;
}

.result-field:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(13, 107, 159, .13);
}

.result-field span { color: #d82121; font-weight: 800; }
.result-copy { justify-self: start; }

.result-grid aside {
  display: grid;
  align-content: start;
  gap: 12px;
}

.summary {
  min-height: 76px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafc;
  padding: 11px;
  line-height: 1.55;
  white-space: pre-line;
}

canvas, #qrImage {
  width: 260px;
  height: 260px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}


.edit-set-modal-box {
  display: grid;
  gap: 14px;
  width: min(720px, calc(100vw - 28px));
  max-height: calc(100vh - 36px);
  overflow: auto;
  border-radius: 8px;
  background: #fff;
  padding: 18px;
}

.edit-set-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.edit-set-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

#editSetList, #historyList {
  min-height: 190px;
}
.qr-modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  background: rgba(10, 16, 24, .86);
  padding: 18px;
}

.qr-modal[hidden] { display: none; }

.qr-modal-box {
  display: grid;
  gap: 12px;
  justify-items: center;
  max-width: min(92vw, 760px);
}

.qr-close { justify-self: end; background: #fff; }

#qrFullCanvas, #qrFullImage {
  width: min(88vw, 720px);
  height: min(88vw, 720px);
  border: 12px solid #fff;
  border-radius: 8px;
  background: #fff;
}

@media (max-width: 760px) {
  .top-line { flex-direction: column; align-items: stretch; }
  .home-brand { align-self: flex-start; }
  .page { width: min(100% - 12px, 980px); margin: 6px auto; }
  .qr-actions, .edit-actions { justify-content: stretch; }
  .qr-actions button, .qr-actions .file-button, .edit-actions button, .edit-set-actions button { width: 100%; text-align: center; }
  .camera-panel { width: calc(100% - 28px); margin-left: 14px; margin-right: 14px; }
  .head, .paste-box, .result-grid { grid-template-columns: 1fr; flex-direction: column; align-items: stretch; }
  .language-control { width: 100%; }
  .controls, .result-grid { display: grid; }
  .edit-row { grid-template-columns: 74px minmax(124px, 1fr) minmax(86px, 1fr) 38px; column-gap: 8px; }
  textarea { width: calc(100% - 28px); margin-left: 14px; margin-right: 14px; }
  canvas, #qrImage { width: min(260px, 100%); height: auto; aspect-ratio: 1; }
}




