* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
  color: #1f2937;
  background: #f6f7f9;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
  background: #2563eb;
  color: #fff;
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
}

button.secondary {
  background: #4b5563;
}

button.danger {
  background: #dc2626;
}

button:disabled {
  background: #9ca3af;
  cursor: not-allowed;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  padding: 8px 10px;
  background: #fff;
}

textarea {
  min-height: 90px;
  resize: vertical;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: #eef2f7;
}

.login-box {
  width: min(420px, calc(100vw - 32px));
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 28px;
  box-shadow: 0 18px 50px rgba(31, 41, 55, 0.08);
}

.shell {
  min-height: 100vh;
}

.topbar {
  height: 56px;
  background: #111827;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
}

.layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: calc(100vh - 56px);
}

.nav {
  background: #fff;
  border-right: 1px solid #e5e7eb;
  padding: 16px;
}

.nav button {
  display: block;
  width: 100%;
  text-align: left;
  margin-bottom: 8px;
  background: transparent;
  color: #374151;
}

.nav button.active {
  background: #e8f0ff;
  color: #1d4ed8;
}

.main {
  padding: 20px;
}

.panel {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 16px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  align-items: end;
}

.stat {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 16px;
}

.stat strong {
  display: block;
  font-size: 28px;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
}

th,
td {
  border-bottom: 1px solid #e5e7eb;
  padding: 10px;
  text-align: left;
  vertical-align: top;
}

th {
  background: #f9fafb;
  font-weight: 600;
}

.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.muted {
  color: #6b7280;
}

.error {
  color: #b91c1c;
  background: #fee2e2;
  border: 1px solid #fecaca;
  border-radius: 6px;
  padding: 10px;
  margin: 10px 0;
}

.success {
  color: #166534;
  background: #dcfce7;
  border: 1px solid #bbf7d0;
  border-radius: 6px;
  padding: 10px;
  margin: 10px 0;
}

.hidden {
  display: none !important;
}

.score {
  font-size: 36px;
  font-weight: 700;
}

/* The Android shell opts into this compact layout with ?app=1. */
.app-mode body {
  background: #f7f8fa;
  color: #17202a;
  overscroll-behavior-y: none;
  -webkit-tap-highlight-color: transparent;
}

.app-mode .login-page {
  min-height: 100dvh;
  align-items: start;
  padding: max(72px, 12vh) 20px 32px;
  background: #fff;
}

.app-mode .login-box {
  width: 100%;
  max-width: 390px;
  padding: 0;
  border: 0;
  box-shadow: none;
}

.app-mode .login-box h1 {
  margin: 0 0 8px;
  font-size: 28px;
  line-height: 1.25;
}

.app-mode .login-box form {
  margin-top: 32px;
}

.app-mode .login-box label {
  display: block;
  margin-bottom: 8px;
  color: #39424e;
  font-size: 14px;
  font-weight: 600;
}

.app-mode input,
.app-mode select,
.app-mode textarea {
  min-height: 48px;
  border-color: #d9dee5;
  border-radius: 6px;
  padding: 11px 12px;
}

.app-mode button {
  min-height: 44px;
  padding: 10px 16px;
  border-radius: 6px;
  background: #176b87;
  font-weight: 600;
}

.app-mode button.secondary {
  background: #eef1f4;
  color: #303944;
}

.app-mode button.danger {
  background: #b42318;
}

.app-mode .login-box button[type="submit"] {
  width: 100%;
  margin-top: 8px;
}

.app-mode .topbar {
  position: sticky;
  z-index: 10;
  top: 0;
  height: auto;
  min-height: 56px;
  padding: 8px 16px;
  background: #fff;
  color: #17202a;
  border-bottom: 1px solid #e3e7ec;
}

.app-mode .topbar > div {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

.app-mode .topbar .secondary {
  min-height: 36px;
  padding: 6px 10px;
}

.app-mode .layout {
  display: block;
  min-height: calc(100dvh - 56px);
}

.app-mode .nav {
  position: sticky;
  z-index: 9;
  top: 56px;
  display: flex;
  gap: 4px;
  overflow-x: auto;
  padding: 8px 12px;
  border: 0;
  border-bottom: 1px solid #e3e7ec;
  scrollbar-width: none;
}

.app-mode .nav::-webkit-scrollbar {
  display: none;
}

.app-mode .nav button {
  width: auto;
  min-height: 38px;
  flex: 0 0 auto;
  margin: 0;
  padding: 7px 12px;
  text-align: center;
  white-space: nowrap;
}

.app-mode .nav button.active {
  background: #e7f2f5;
  color: #0f5e77;
}

.app-mode .main {
  max-width: 720px;
  margin: 0 auto;
  padding: 20px 16px 40px;
}

.app-mode .main h2 {
  margin: 0 0 18px;
  font-size: 22px;
  line-height: 1.35;
}

.app-mode .panel {
  padding: 16px 0;
  border: 0;
  border-bottom: 1px solid #e3e7ec;
  border-radius: 0;
  background: transparent;
}

.app-mode .grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.app-mode .stat {
  min-width: 0;
  padding: 14px;
  border-color: #e3e7ec;
  border-radius: 6px;
}

.app-mode .stat strong {
  margin-top: 4px;
  font-size: 25px;
}

.app-mode .form-grid {
  grid-template-columns: 1fr;
}

.app-mode .actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.app-mode .actions button:last-child:nth-child(odd) {
  grid-column: 1 / -1;
}

.app-mode table {
  display: block;
  overflow-x: auto;
  white-space: nowrap;
  background: transparent;
}

.app-mode th,
.app-mode td {
  padding: 11px 10px;
}

.app-mode audio {
  width: 100%;
  margin-top: 12px;
}

.app-mode .score {
  color: #176b87;
  font-size: 40px;
}

@media (max-width: 760px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .nav {
    border-right: 0;
    border-bottom: 1px solid #e5e7eb;
  }
}
