:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --text: #1f2937;
  --muted: #4b5563;
  --border: #d1d5db;
  --primary: #005b99;
  --danger: #a61b1b;
  --focus: #0a66b2;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, sans-serif;
  line-height: 1.5;
  color: var(--text);
  background: radial-gradient(circle at top left, #ffffff, var(--bg));
}
h1, h2 {
  margin: 0;
}
h1 {
  font-size: 1.85rem;
  line-height: 1.2;
  letter-spacing: 0.01em;
}
h2 {
  font-size: 1.2rem;
  line-height: 1.3;
  margin-bottom: 6px;
}
main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 16px;
  display: grid;
  gap: 12px;
}
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
}
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.volume-controls {
  margin-top: 8px;
}
.volume-controls label {
  display: flex;
  align-items: center;
  gap: 6px;
}
.volume-controls input[type="range"] {
  width: 160px;
}
input, select, button, textarea {
  font: inherit;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  min-height: 44px;
}
button,
input,
select,
textarea {
  line-height: 1.3;
}
button {
  background: var(--primary);
  color: #fff;
  border: none;
  cursor: pointer;
}
button.secondary { background: #4b5563; }
button:disabled { opacity: 0.55; cursor: not-allowed; }
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
.menu-item-touch:focus-visible,
.actions-item-btn:focus-visible,
#menu-list:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}
.status { color: var(--muted); }
.status.error { color: var(--danger); }
.grid {
  display: grid;
  grid-template-columns: minmax(260px, 0.8fr) minmax(520px, 1.9fr);
  gap: 12px;
}
.menu-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  max-height: 440px;
  overflow-y: auto;
}
.menu-item {
  width: 100%;
  padding: 8px;
  text-align: left;
  border-radius: 0;
  background: #fff;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  cursor: default;
}
.menu-item:last-child { border-bottom: 0; }
.menu-item.active {
  background: #e5f1fb;
  outline: 2px solid #93c5fd;
}
.menu-item-touch {
  width: 100%;
  min-height: 44px;
  padding: 8px;
  text-align: left;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--text);
}
.history {
  border: 1px solid var(--border);
  border-radius: 8px;
  min-height: 480px;
  height: 62vh;
  overflow-y: auto;
  padding: 8px;
  background: #fbfdff;
  white-space: pre-wrap;
  resize: none;
}
.history-entry { margin: 0 0 6px; }
.history-log {
  border: 1px solid var(--border);
  border-radius: 8px;
  min-height: 480px;
  height: 62vh;
  overflow-y: auto;
  padding: 8px;
  background: #fbfdff;
}
.history-line {
  margin: 0 0 6px 0;
  white-space: pre-wrap;
}
.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}
.history-toggle-title {
  background: transparent;
  border: 0;
  color: var(--text);
  padding: 0;
  font-size: inherit;
  font-weight: inherit;
  cursor: default;
}
.actions-btn {
  margin-left: 8px;
}
.actions-list {
  list-style: none;
  margin: 8px 0 0 0;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  max-height: 40vh;
  overflow-y: auto;
}
.actions-item-btn {
  width: 100%;
  text-align: left;
  border: 0;
  border-radius: 0;
  border-bottom: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  min-height: 44px;
}
.actions-list li:last-child .actions-item-btn {
  border-bottom: 0;
}
dialog {
  border: 1px solid var(--border);
  border-radius: 10px;
  width: min(420px, 92vw);
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}
.footer {
  text-align: right;
}
#login-dialog input,
#login-dialog button {
  min-height: 44px;
}
#connect-form label {
  display: grid;
  gap: 6px;
}
@media (max-width: 900px) {
  .grid { grid-template-columns: 1fr; }
  main {
    gap: 14px;
  }
  .panel {
    padding: 14px;
  }
  .row {
    gap: 10px;
  }
  .history {
    display: none;
  }
  .history-log {
    display: block;
    min-height: 300px;
    height: 42vh;
  }
  .history-toggle-title {
    cursor: pointer;
    text-decoration: underline;
  }
}
