:root {
  color-scheme: light;
  --bg: #eef1f4;
  --surface: #ffffff;
  --line: #cfd6de;
  --text: #20242a;
  --muted: #626c77;
  --accent: #1f6feb;
  --accent-dark: #185abc;
  --danger: #b42318;
  --shadow: 0 10px 28px rgba(31, 42, 55, 0.16);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
}

button,
input {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  background: #f8fafc;
  color: var(--text);
  border-radius: 6px;
  cursor: pointer;
  min-height: 34px;
}

button:hover {
  background: #eef4fb;
}

button:disabled {
  color: #9aa4af;
  cursor: not-allowed;
  background: #f4f6f8;
}

.app-shell {
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

.browser-toolbar {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding: 10px;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.03);
  z-index: 2;
}

.brand {
  font-weight: 700;
  margin-bottom: 8px;
}

.nav-row,
.tool-row {
  display: flex;
  gap: 7px;
  align-items: center;
}

.tool-row {
  margin-top: 8px;
  flex-wrap: wrap;
}

.icon-btn {
  width: 36px;
  min-width: 36px;
  padding: 0;
  font-size: 20px;
  line-height: 1;
}

.address-form {
  flex: 1;
  display: flex;
  gap: 7px;
  min-width: 160px;
}

#addressInput {
  width: 100%;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 10px;
  color: var(--text);
  background: #fff;
}

#addressInput:focus {
  outline: 2px solid rgba(31, 111, 235, 0.18);
  border-color: var(--accent);
}

.go-btn {
  min-width: 64px;
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.go-btn:hover {
  background: var(--accent-dark);
}

.toggle {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  min-height: 34px;
  color: var(--muted);
}

.status-line {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.compat-notice {
  margin-top: 8px;
  padding: 8px 10px;
  border: 1px solid #f0c36d;
  background: #fff8e1;
  color: #714b00;
  border-radius: 6px;
  font-size: 13px;
}

.viewport-wrap {
  position: relative;
  flex: 1;
  min-height: 420px;
  background: #fff;
}

#browserFrame {
  width: 100%;
  height: calc(100vh - 138px);
  min-height: 420px;
  display: none;
  border: 0;
  background: #fff;
}

.empty-state {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
  color: var(--muted);
}

.empty-state h1 {
  margin: 0 0 8px;
  font-size: 24px;
  color: var(--text);
}

.empty-state p {
  margin: 0;
  max-width: 520px;
  line-height: 1.5;
}

.side-panel {
  position: fixed;
  right: 16px;
  top: 84px;
  bottom: 16px;
  width: min(560px, calc(100vw - 32px));
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  display: none;
  z-index: 5;
}

.side-panel.open {
  display: flex;
  flex-direction: column;
}

.panel-head {
  height: 46px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 10px 0 14px;
}

.panel-body {
  overflow: auto;
  padding: 12px;
  font-size: 13px;
}

.source-pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: Consolas, Monaco, monospace;
  line-height: 1.45;
}

.resource-table {
  width: 100%;
  border-collapse: collapse;
}

.resource-table th,
.resource-table td {
  border-bottom: 1px solid var(--line);
  text-align: left;
  padding: 7px 6px;
  vertical-align: top;
  word-break: break-word;
}

.resource-table th {
  color: var(--muted);
  font-weight: 700;
  background: #f8fafc;
}

.kv {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 6px 10px;
}

.kv div:nth-child(odd) {
  color: var(--muted);
}

@media (max-width: 720px) {
  .nav-row {
    flex-wrap: wrap;
  }

  .address-form {
    order: 2;
    flex-basis: 100%;
  }

  .tool-row button {
    flex: 1 1 auto;
  }

  #browserFrame {
    height: calc(100vh - 216px);
  }

  .side-panel {
    top: 12px;
    left: 12px;
    right: 12px;
    bottom: 12px;
    width: auto;
  }
}
