*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  width: 380px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 13px;
  color: #1e293b;
  background: #f8fafc;
}

/* Header */
.header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px 10px;
  background: #6366f1;
  color: white;
}
.logo { width: 22px; height: 22px; }
.title { font-size: 14px; font-weight: 600; letter-spacing: .3px; }

/* Tabs */
.tabs {
  display: flex;
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
}
.tab {
  flex: 1;
  padding: 9px 4px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  font-size: 12px;
  font-weight: 500;
  color: #64748b;
  cursor: pointer;
  transition: color .15s, border-color .15s;
}
.tab:hover { color: #6366f1; }
.tab.active { color: #6366f1; border-bottom-color: #6366f1; }

/* Content area */
.content { padding: 14px 16px; }

.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* Info row */
.info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 10px;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  margin-bottom: 10px;
}
.info-label { font-size: 11px; color: #64748b; font-weight: 500; text-transform: uppercase; letter-spacing: .5px; }
.info-value { font-size: 13px; font-weight: 600; color: #1e293b; }
.info-value.found { color: #059669; }
.info-value.not-found { color: #dc2626; }

/* Preview */
.preview-block {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 10px;
  margin-bottom: 12px;
}
.preview-block .info-label { margin-bottom: 6px; display: block; }
.preview-text {
  font-size: 12px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 110px;
  overflow-y: auto;
  color: #334155;
}

.muted { color: #94a3b8; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 14px;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s, opacity .15s;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: #6366f1; color: white; width: 100%; }
.btn-primary:not(:disabled):hover { background: #4f46e5; }
.btn-small { padding: 4px 10px; font-size: 11px; }
.btn-danger { background: #fee2e2; color: #dc2626; }
.btn-danger:hover { background: #fecaca; }

/* Status messages */
.status-msg {
  margin-top: 8px;
  min-height: 18px;
  font-size: 12px;
  line-height: 1.4;
  border-radius: 4px;
  padding: 0 2px;
}
.status-msg.success { color: #059669; }
.status-msg.warning { color: #d97706; }
.status-msg.error { color: #dc2626; }

/* Settings form */
.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 10px;
}
.field span {
  font-size: 11px;
  font-weight: 600;
  color: #475569;
  text-transform: uppercase;
  letter-spacing: .4px;
}
.field input,
.field textarea {
  padding: 7px 9px;
  border: 1px solid #cbd5e1;
  border-radius: 5px;
  font-size: 13px;
  font-family: inherit;
  background: #fff;
  color: #1e293b;
  resize: vertical;
  transition: border-color .15s;
}
.field input:focus,
.field textarea:focus {
  outline: none;
  border-color: #6366f1;
  box-shadow: 0 0 0 2px rgba(99,102,241,.15);
}
.field small { font-size: 11px; color: #94a3b8; }
.field code { background: #f1f5f9; border-radius: 3px; padding: 1px 4px; font-family: monospace; }
.preview-link { color: #6366f1; text-decoration: underline; word-break: break-all; }
#settings-form .btn { margin-top: 4px; }
.field-section-label { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .6px; color: #94a3b8; margin-bottom: 8px; }

/* Template selector in fill tab */
.template-select {
  font-size: 12px;
  font-family: inherit;
  border: 1px solid #cbd5e1;
  border-radius: 5px;
  padding: 3px 6px;
  color: #1e293b;
  background: #fff;
  max-width: 180px;
}

/* Templates list */
.templates-list { margin-bottom: 8px; }
.tpl-empty { font-size: 12px; color: #94a3b8; padding: 4px 0 6px; }
.tpl-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 8px;
  border: 1px solid #e2e8f0;
  border-radius: 5px;
  margin-bottom: 4px;
  background: #fff;
  transition: border-color .15s;
}
.tpl-item.tpl-active { border-color: #6366f1; background: #eef2ff; }
.tpl-name { font-size: 12px; font-weight: 500; color: #1e293b; }
.tpl-active .tpl-name { color: #4f46e5; }
.tpl-actions { display: flex; gap: 4px; }
.tpl-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 13px;
  padding: 2px 5px;
  border-radius: 3px;
  color: #94a3b8;
  transition: color .15s, background .15s;
}
.tpl-btn:hover { background: #f1f5f9; color: #475569; }
.tpl-delete:hover { color: #dc2626; background: #fee2e2; }

/* Inline template editor */
.template-editor {
  border: 1px solid #c7d2fe;
  border-radius: 6px;
  padding: 10px;
  background: #f5f3ff;
  margin: 6px 0 10px;
}
.template-editor .field { margin-bottom: 8px; }

/* New template button */
.btn-add-tpl { background: #f8fafc; color: #6366f1; border: 1px dashed #c7d2fe; width: 100%; justify-content: center; margin-bottom: 4px; }

/* History */
.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.history-list {
  max-height: 280px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.history-entry {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 9px 10px;
}
.history-meta {
  display: flex;
  justify-content: space-between;
  margin-bottom: 3px;
}
.history-name { font-weight: 600; color: #1e293b; font-size: 13px; }
.history-date { font-size: 11px; color: #94a3b8; }
.history-url { font-size: 11px; color: #6366f1; margin-bottom: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.history-msg { font-size: 11px; color: #64748b; white-space: pre-wrap; line-height: 1.5; }
.history-filled { font-size: 10px; color: #059669; margin-top: 3px; }
.empty { text-align: center; padding: 20px 0; font-size: 12px; }
