* { box-sizing: border-box; }

:root { --radius: 6px; }

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 14px;
  color: #1a1a1a;
  background: #f4f5f7;
}

/* ---------- top bar ---------- */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px;
  background: #22303f;
  color: #fff;
  flex-wrap: wrap;
  gap: 8px;
}
.topbar h1 { font-size: 18px; margin: 0; font-weight: bold; }
.topbar .sub { font-size: 12px; font-weight: normal; color: #a8b7c7; margin-left: 6px; }
.base-url { font-size: 12px; color: #a8b7c7; display: flex; align-items: center; gap: 6px; }
.base-url input {
  width: 320px; max-width: 50vw; padding: 5px 7px;
  border: 1px solid #4a5b6d; border-radius: var(--radius); background: #fff; color: #111; font-size: 12px;
}

/* ---------- toolbar ---------- */
.toolbar {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 16px; background: #fff; border-bottom: 1px solid #dcdfe4;
  flex-wrap: wrap;
}
.search { flex: 1; min-width: 180px; max-width: 360px; padding: 6px 9px; border: 1px solid #c4c9d0; border-radius: var(--radius); }
.id-lookup { display: flex; gap: 6px; align-items: center; margin: 0; }
.id-lookup input { width: 220px; padding: 6px 9px; border: 1px solid #c4c9d0; border-radius: var(--radius); font-family: "SF Mono", Consolas, Menlo, monospace; font-size: 12px; }
.spacer { flex: 1; }
.feed-meta { font-size: 12px; color: #667; }

/* ---------- buttons ---------- */
.btn {
  padding: 6px 12px; border: 1px solid #b7bdc6; background: #fff; color: #1a1a1a;
  border-radius: var(--radius); cursor: pointer; font-size: 13px; line-height: 1.2;
}
.btn:hover { background: #eef0f3; }
.btn-primary { background: #1f6feb; border-color: #1f6feb; color: #fff; }
.btn-primary:hover { background: #1a5fd0; }
.btn-danger { background: #c62828; border-color: #c62828; color: #fff; }
.btn-danger:hover { background: #ad2020; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.close-btn { border: none; background: transparent; font-size: 16px; }

/* ---------- main ---------- */
main { padding: 16px; }
.status { padding: 12px; color: #555; }
.status.error { color: #c62828; }

/* ---------- table ---------- */
.feed-table { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid #dcdfe4; }
.feed-table th, .feed-table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid #ececf0; vertical-align: top; font-size: 13px; }
.feed-table th { background: #f0f2f5; font-weight: bold; position: sticky; top: 0; }
.feed-table tbody tr:hover, .feed-table tbody tr:hover { background: #f7f9fc; }
.feed-table.compact th, .feed-table.compact td { padding: 5px 8px; }
.row-title { font-weight: bold; color: #1f6feb; cursor: pointer; text-decoration: underline; }
.row-title:hover { color: #1a5fd0; }
.pill { display: inline-block; padding: 3px 9px; border-radius: var(--radius); background: #e7ebf0; font-size: 11px; line-height: 1.3; white-space: nowrap; }
.pill.temp { background: #ffe6a8; }
.row-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.row-actions .btn { flex: 0 0 auto; min-width: 66px; text-align: center; }
.mono { font-family: "SF Mono", Consolas, Menlo, monospace; font-size: 12px; }

/* ---------- modal ---------- */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: flex-start; justify-content: center; padding: 30px 16px; overflow-y: auto; z-index: 50; }
.modal[hidden] { display: none; }
.modal-box { background: #fff; border-radius: var(--radius); width: 560px; max-width: 100%; box-shadow: 0 8px 30px rgba(0,0,0,.3); }
.modal-lg { width: 860px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid #e2e5ea; }
.modal-head h2 { margin: 0; font-size: 16px; }
.modal-head-actions { display: flex; gap: 6px; align-items: center; }
.modal-body { padding: 16px; }
.modal-foot { display: flex; align-items: center; gap: 8px; padding: 12px 16px; border-top: 1px solid #e2e5ea; }
.hint { color: #666; font-size: 12px; margin: 0 0 10px; }
.inline-msg { font-size: 12px; }
.inline-msg.ok { color: #2e7d32; }
.inline-msg.err { color: #c62828; }
.row { display: flex; align-items: center; gap: 10px; margin-top: 8px; }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 4px; padding: 8px 16px 0; border-bottom: 1px solid #e2e5ea; }
.tab { border: 1px solid #dcdfe4; border-bottom: none; background: #f0f2f5; padding: 6px 14px; cursor: pointer; border-radius: var(--radius) var(--radius) 0 0; font-size: 13px; }
.tab.active { background: #fff; font-weight: bold; margin-bottom: -1px; }

/* ---------- explore pretty view ---------- */
.section { margin-bottom: 18px; }
.section h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: #556; border-bottom: 1px solid #e6e8ec; padding-bottom: 4px; margin: 0 0 8px; }
.kv { display: grid; grid-template-columns: 160px 1fr; gap: 4px 12px; }
.kv dt { color: #667; }
.kv dd { margin: 0; }
.update-block { border: 1px solid #e6e8ec; border-radius: var(--radius); padding: 10px 12px; margin-bottom: 10px; background: #fafbfc; }
.update-block .ts { font-size: 12px; color: #778; margin-bottom: 6px; }
.blk { margin-bottom: 8px; }
.blk .heading { font-weight: bold; }
.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chip { background: #e7ebf0; border-radius: var(--radius); padding: 2px 8px; font-size: 12px; }
.chip.minor { background: #f0e7e7; }
.src-list, .link-list { margin: 0; padding-left: 18px; word-break: break-all; }
.src-list li, .link-list li { margin-bottom: 3px; }
.thumbs { display: flex; flex-wrap: wrap; gap: 8px; }
.thumbs img { max-height: 90px; border: 1px solid #ccc; border-radius: var(--radius); }
.empty { color: #999; font-style: italic; }

#actionConfirmDetail { max-height: 220px; margin-top: 10px; }
.raw-json { background: #1e1e1e; color: #d4d4d4; padding: 14px; border-radius: var(--radius); overflow: auto; max-height: 65vh; font-size: 12px; line-height: 1.5; margin: 0; white-space: pre-wrap; word-break: break-word; }

.json-area { width: 100%; height: 380px; font-family: "SF Mono", Consolas, Menlo, monospace; font-size: 12px; padding: 10px; border: 1px solid #c4c9d0; border-radius: var(--radius); resize: vertical; }

/* ---------- structured editor ---------- */
#editForm .fld { margin-bottom: 10px; }
#editForm label { display: block; font-size: 12px; color: #556; margin-bottom: 3px; font-weight: bold; }
#editForm input[type=text], #editForm input[type=number], #editForm textarea {
  width: 100%; padding: 6px 8px; border: 1px solid #c4c9d0; border-radius: var(--radius); font-size: 13px; font-family: inherit;
}
#editForm textarea { resize: vertical; min-height: 54px; line-height: 1.4; }
#editForm .fld-row { display: flex; gap: 10px; }
#editForm .fld-row .fld { flex: 1; }
.ed-section { border: 1px solid #e2e5ea; border-radius: var(--radius); margin-bottom: 16px; }
.ed-section > header { display: flex; align-items: center; justify-content: space-between; background: #f0f2f5; padding: 7px 12px; border-bottom: 1px solid #e2e5ea; border-radius: var(--radius) var(--radius) 0 0; }
.ed-section > header h4 { margin: 0; font-size: 13px; text-transform: uppercase; letter-spacing: .03em; color: #445; }
.ed-section .ed-body { padding: 12px; }
.update-card { border: 1px solid #dbe0e6; border-radius: var(--radius); padding: 10px 12px; margin-bottom: 12px; background: #fafbfc; }
.update-card .uc-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.update-card .uc-head .idx { font-weight: bold; color: #445; }
.block-card { border: 1px dashed #ccd2da; border-radius: var(--radius); padding: 8px 10px; margin-bottom: 8px; background: #fff; }
.block-card .bc-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 5px; }
.block-card .bc-head span { font-size: 11px; color: #778; }
.repeat-row { display: flex; gap: 8px; align-items: flex-start; margin-bottom: 6px; }
.repeat-row input { flex: 1; }
.btn-sm { padding: 3px 9px; font-size: 12px; }
.btn-add { margin-top: 4px; }
.ed-help { font-size: 11px; color: #889; margin: 2px 0 6px; }

/* ---------- toast ---------- */
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #22303f; color: #fff; padding: 10px 18px; border-radius: var(--radius); font-size: 13px; z-index: 100; box-shadow: 0 4px 16px rgba(0,0,0,.3); }
.toast.err { background: #c62828; }
.toast.ok { background: #2e7d32; }
