/* WizMerge v2.0.0 — styles */
:root {
  --bg: #f3f5f9;
  --panel: #ffffff;
  --ink: #1c2333;
  --muted: #667085;
  --line: #e2e7f0;
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --danger: #dc2626;
  --ok: #16a34a;
  --warn: #b45309;
  --warn-bg: #fef3c7;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(16, 24, 40, .08);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  -webkit-text-size-adjust: 100%;
}

.hidden { display: none !important; }

/* ---------- header ---------- */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  background: #0f1b33;
  color: #fff;
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  font-size: 30px;
  background: var(--accent);
  width: 48px; height: 48px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 12px;
}
.brand h1 { margin: 0; font-size: 22px; letter-spacing: .5px; }
.tagline { margin: 2px 0 0; font-size: 12px; color: #aeb9d4; }
.auth-area { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.auth-status {
  font-size: 13px;
  padding: 6px 12px;
  border-radius: 999px;
  background: #233252;
  color: #cdd7ee;
}
.auth-status.signed-in { background: #123f2a; color: #8ee6ae; }

/* ---------- banners ---------- */
.banner {
  margin: 12px 20px 0;
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.banner-warn { background: var(--warn-bg); border: 1px solid #f5d48a; color: #7c4a03; }

/* ---------- tab bar ---------- */
.tab-bar {
  display: flex;
  gap: 4px;
  padding: 12px 20px 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.tab-btn {
  border: 1px solid var(--line);
  border-bottom: none;
  background: #e9edf4;
  color: var(--muted);
  padding: 10px 18px;
  border-radius: var(--radius) var(--radius) 0 0;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.tab-btn.active { background: var(--panel); color: var(--accent-dark); }

/* ---------- layout ---------- */
main { padding: 0 20px 20px; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 0 var(--radius) var(--radius) var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
  min-width: 0;
}
.tab-panel .panel:first-child { border-radius: var(--radius); }
.panel h2 { margin: 0 0 10px; font-size: 17px; }
.panel h3 { margin: 16px 0 8px; font-size: 14px; }

.tm-grid { display: grid; grid-template-columns: 340px 1fr; gap: 16px; align-items: start; }
.tm-grid .panel { border-radius: var(--radius); }
.stack .panel { border-radius: var(--radius); }
.lg-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; align-items: start; }
.lg-grid .panel { border-radius: var(--radius); }

.action-bar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  position: sticky;
  bottom: 0;
  border-radius: var(--radius);
}

/* ---------- forms ---------- */
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-weight: 600; font-size: 13px; margin-bottom: 6px; }
.input {
  width: 100%;
  padding: 9px 12px;
  font-size: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-family: inherit;
  background: #fff;
  color: var(--ink);
}
.input:focus { outline: 2px solid var(--accent); border-color: var(--accent); }
.input-sm { padding: 7px 10px; font-size: 13px; }
textarea.input { resize: vertical; }

.hint { font-size: 13px; color: var(--muted); }
.hint-inline { font-weight: 400; color: var(--muted); }
code { background: #eef1f7; padding: 1px 6px; border-radius: 5px; font-size: 12.5px; }

.btn {
  display: inline-block;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  padding: 9px 16px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.btn:hover { background: #f1f4fa; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); }
.btn-danger { color: var(--danger); border-color: #f3b6b6; }
.btn-danger:hover { background: #fef2f2; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-lg { padding: 12px 24px; font-size: 16px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }

.file-label .btn { cursor: pointer; }
.file-label input[type="file"] { display: none; }
.file-label-inline { cursor: pointer; }
.file-meta { font-size: 13px; color: var(--muted); margin-top: 8px; }
.linklike { color: var(--accent); cursor: pointer; text-decoration: underline; }
.linklike input { display: none; }
.form-msg { margin-top: 10px; font-size: 14px; }
.form-msg.ok { color: var(--ok); }
.form-msg.err { color: var(--danger); }

/* ---------- chips ---------- */
.chip-bar { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 4px; min-height: 34px; }
.chip {
  background: #e8effe;
  color: var(--accent-dark);
  border: 1px solid #bcd0fb;
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 13px;
  font-family: monospace;
  cursor: pointer;
}
.chip:hover { background: #d5e3fd; }

/* ---------- pill inputs ---------- */
.pill-input {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 8px;
  background: #fff;
  cursor: text;
  min-height: 42px;
  align-items: center;
}
.pill-input:focus-within { outline: 2px solid var(--accent); border-color: var(--accent); }
.pill-input input {
  border: none; outline: none; flex: 1; min-width: 140px;
  font-size: 14px; font-family: inherit; padding: 4px;
}
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  background: #eef2ff; border: 1px solid #c7d6fe; color: #1e3a8a;
  border-radius: 999px; padding: 3px 6px 3px 12px; font-size: 13px;
}
.pill button {
  border: none; background: none; cursor: pointer; color: #1e3a8a;
  font-size: 14px; line-height: 1; padding: 2px 4px;
}

/* ---------- WYSIWYG ---------- */
.wys-toolbar { display: flex; gap: 4px; margin-bottom: 6px; flex-wrap: wrap; }
.wys-toolbar button {
  border: 1px solid var(--line); background: #f8fafc; border-radius: 6px;
  min-width: 34px; height: 30px; cursor: pointer; font-size: 14px;
}
.wys-toolbar button:hover { background: #eef2f7; }
.wys {
  border: 1px solid var(--line); border-radius: 8px; padding: 12px;
  min-height: 180px; font-size: 14px; background: #fff;
}
.wys-small { min-height: 90px; }
.wys:focus { outline: 2px solid var(--accent); border-color: var(--accent); }
.wys:empty::before { content: attr(data-placeholder); color: #9aa3b5; }

/* ---------- dropzone / files ---------- */
.dropzone {
  border: 2px dashed #b9c4d8; border-radius: var(--radius);
  padding: 22px; text-align: center; color: var(--muted); font-size: 14px;
  background: #fafbfe; cursor: pointer;
}
.dropzone.drag { border-color: var(--accent); background: #eef4ff; }
.file-list { list-style: none; margin: 10px 0 0; padding: 0; }
.file-list li {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px;
  margin-bottom: 6px; font-size: 13px;
}
.btn-remove {
  border: 1px solid #f3b6b6; background: #fff; color: var(--danger);
  border-radius: 6px; padding: 4px 10px; cursor: pointer; font-size: 12px;
}

/* ---------- merger ---------- */
.progress {
  height: 14px; background: #e9edf4; border-radius: 999px; overflow: hidden; margin: 14px 0 6px;
}
.progress-bar { height: 100%; width: 0; background: var(--accent); transition: width .25s; }
.counters { font-size: 14px; color: var(--muted); margin-bottom: 6px; }
.result-list { list-style: none; margin: 8px 0 0; padding: 0; max-height: 260px; overflow: auto; font-size: 13px; }
.result-list li { padding: 6px 4px; border-bottom: 1px solid var(--line); }
.result-list li.ok { color: var(--ok); }
.result-list li.fail { color: var(--danger); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; margin-top: 10px; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th, .data-table td {
  text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
.data-table th { background: #f4f6fb; font-size: 12px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); }
.badge { border-radius: 999px; padding: 2px 10px; font-size: 12px; font-weight: 700; }
.badge-info { background: #e0e9ff; color: #1d4ed8; }
.badge-success { background: #dcf5e3; color: #15803d; }
.badge-error { background: #fee2e2; color: #b91c1c; }

/* ---------- tester ---------- */
.var-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.preview-box {
  border: 1px solid var(--line); border-radius: 8px; padding: 14px;
  background: #fafbfe; font-size: 14px; margin-bottom: 14px; overflow-x: auto;
}
.preview-box h4 { margin: 0 0 6px; font-size: 15px; }

/* ---------- logger ---------- */
.filter-row { display: flex; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.filter-row .input-sm { flex: 1; min-width: 140px; }
.console {
  background: #0d1526; color: #b8f5c8; border-radius: 8px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px; padding: 12px; height: 420px; overflow-y: auto; white-space: pre-wrap;
}
.console .c-err { color: #ff9d9d; }
.console .c-ok { color: #7ef0a0; }
.console .c-dim { color: #7d8aa5; }
.log-dialog-wide { max-width: 760px; }
.console-full { height: 62vh; min-height: 420px; font-size: 13px; margin-bottom: 14px; }

/* ---------- instructions / SOP ---------- */
.sop h3 { margin: 20px 0 8px; font-size: 15px; color: var(--accent-dark); }
.sop ol, .sop ul { margin: 6px 0 12px; padding-left: 22px; font-size: 14px; }
.sop p { font-size: 14px; line-height: 1.6; }

/* ---------- dialog / toast ---------- */
dialog {
  border: 1px solid var(--line); border-radius: 12px; padding: 22px;
  max-width: 560px; width: calc(100% - 40px); box-shadow: 0 12px 40px rgba(0,0,0,.25);
}
dialog::backdrop { background: rgba(15, 27, 51, .55); }
.dialog-actions { justify-content: flex-end; margin-top: 16px; }
.terms-body { max-height: 60vh; overflow-y: auto; font-size: 14px; line-height: 1.6; }
.terms-body h3 { font-size: 15px; margin: 16px 0 6px; }
.terms-body h3:first-child { margin-top: 0; }
.terms-body p, .terms-body ul { margin: 6px 0; }
.terms-body ul { padding-left: 20px; }
.app-footer a { color: inherit; }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: #0f1b33; color: #fff; padding: 12px 20px; border-radius: 10px;
  font-size: 14px; box-shadow: 0 8px 24px rgba(0,0,0,.3); z-index: 99; max-width: 90vw;
}

.app-footer {
  text-align: center; color: var(--muted); font-size: 12px; padding: 18px 10px 30px;
}

/* ---------- radio group ---------- */
.radio-group { display: flex; gap: 10px; flex-wrap: wrap; margin: 4px 0 10px; }
.radio {
  display: inline-flex; align-items: center; gap: 8px;
  border: 1px solid var(--line); border-radius: var(--radius); padding: 9px 14px;
  font-size: 14px; cursor: pointer; background: var(--panel);
}
.radio input { accent-color: var(--accent); width: 16px; height: 16px; }
.radio:has(input:checked) { border-color: var(--accent); background: #eff4ff; }

/* ---------- validation & preview ---------- */
.field-inline { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.field-inline > span { margin-bottom: 0; }
.input-num { width: 90px; flex: 0 0 auto; }
button.linklike { background: none; border: none; padding: 0; font-size: inherit; }
.validation { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; margin: 10px 0; font-size: 13px; display: grid; gap: 6px; }
.v-ok { color: var(--ok); font-weight: 600; }
.v-err { color: var(--danger); }
.v-warn { color: var(--warn); }
.v-note { color: var(--muted); }
.preview-list { display: grid; gap: 10px; margin: 10px 0; }
.preview-list h4 { margin: 0; font-size: 14px; }
.preview-mail { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; background: var(--panel); }
.preview-mail-head { font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.preview-mail-subject { font-weight: 700; margin-bottom: 6px; }
.preview-mail-body { font-size: 14px; border-top: 1px solid var(--line); padding-top: 6px; }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .tm-grid, .lg-grid { grid-template-columns: 1fr; }
  .app-header { padding: 10px 14px; }
  main { padding: 0 12px 12px; }
  .tab-bar, .banner { margin-left: 0; margin-right: 0; }
  .banner { margin: 10px 12px 0; }
  .tab-bar { padding: 10px 12px 0; }
  .tab-btn { padding: 9px 14px; font-size: 13px; }
  .action-bar { position: static; }
}
