:root {
  --bg: #0f1419;
  --surface: #1a222d;
  --text: #e8eef5;
  --muted: #8b9aad;
  --accent: #3d9cf5;
  --accent-hover: #5cb0ff;
  --danger: #f07178;
  --success: #7fd99a;
  --warning: #ffcc66;
  --radius: 12px;
  font-family: system-ui, "Segoe UI", Roboto, Ubuntu, sans-serif;
}

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

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1rem;
  background: var(--surface);
  border-bottom: 1px solid #2a3544;
  flex-wrap: wrap;
}

.logo {
  font-weight: 700;
  color: var(--text);
}

.logo:hover {
  text-decoration: none;
  color: var(--accent);
}

.site-header nav {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.site-header nav > span {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.nav-user {
  color: var(--muted);
  font-size: 0.9rem;
}

.hidden {
  display: none !important;
}

.container {
  max-width: 28rem;
  margin: 0 auto;
  padding: 1.25rem;
}

.container-wide {
  max-width: 32rem;
}

.hero {
  text-align: center;
  padding: 2rem 0;
}

.hero h1 {
  margin: 0 0 0.5rem;
  font-size: 1.75rem;
}

.lead {
  color: var(--muted);
  margin: 0 0 1.5rem;
}

.actions {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.actions-stack {
  margin-top: 1rem;
}

@media (min-width: 400px) {
  .actions {
    flex-direction: row;
    justify-content: center;
  }

  .actions-stack {
    flex-direction: column;
  }
}

.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.5rem;
  border: 1px solid #2a3544;
}

.card h1 {
  margin: 0 0 1rem;
  font-size: 1.35rem;
}

.card h2 {
  margin: 0 0 0.75rem;
  font-size: 1.1rem;
  font-weight: 600;
}

.stack-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.stack-form label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.9rem;
  color: var(--muted);
}

.stack-form input,
.stack-form select,
.stack-form textarea {
  padding: 0.65rem 0.75rem;
  border-radius: 8px;
  border: 1px solid #2a3544;
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
  min-height: 44px;
  font-family: inherit;
}

.stack-form textarea {
  resize: vertical;
}

.stack-form input:focus,
.stack-form select:focus,
.stack-form textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.65rem 1.1rem;
  border-radius: 8px;
  border: none;
  background: var(--accent);
  color: #0a0e12;
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  text-decoration: none;
  min-height: 44px;
}

.btn:hover {
  background: var(--accent-hover);
  text-decoration: none;
  color: #0a0e12;
}

.btn-secondary {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
}

.btn-secondary:hover {
  background: rgba(61, 156, 245, 0.12);
}

.btn-block {
  width: 100%;
}

.btn-small {
  padding: 0.45rem 0.85rem;
  font-size: 0.9rem;
  min-height: auto;
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid #2a3544;
  font-weight: 500;
}

.btn-ghost:hover {
  color: var(--text);
  border-color: var(--muted);
}

.inline-form {
  display: inline;
  margin: 0;
}

.muted {
  margin-top: 1rem;
  color: var(--muted);
  font-size: 0.9rem;
}

#flash-banner {
  list-style: none;
  padding: 0;
  margin: 0 0 1rem;
}

#flash-banner li {
  padding: 0.65rem 0.85rem;
  border-radius: 8px;
  margin-bottom: 0.5rem;
  font-size: 0.95rem;
}

.flash-error {
  background: rgba(240, 113, 120, 0.15);
  color: var(--danger);
}

.flash-success {
  background: rgba(127, 217, 154, 0.12);
  color: var(--success);
}

.flash-warning {
  background: rgba(255, 204, 102, 0.12);
  color: var(--warning);
}

.flash-info {
  background: rgba(61, 156, 245, 0.12);
  color: var(--accent);
}

.subject-levels {
  margin: 0;
  padding: 0.75rem 0 0;
  border: none;
  border-top: 1px solid #2a3544;
}

.subject-levels-plain {
  border-top: none;
  padding-top: 0;
}

.subject-levels legend {
  padding: 0;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
}

.field-hint {
  margin: 0 0 0.75rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.avatar-editor {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: flex-start;
  margin-bottom: 1rem;
}

.avatar-preview {
  width: 96px;
  height: 96px;
  min-width: 96px;
  border-radius: 24px;
  background: rgba(61, 156, 245, 0.14);
  border: 1px solid #2a3544;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  font-size: 1.75rem;
  background-size: cover;
  background-position: center;
}

.avatar-small {
  width: 44px;
  height: 44px;
  border-radius: 999px;
  background: rgba(61, 156, 245, 0.14);
  border: 1px solid #2a3544;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  font-size: 1rem;
  background-size: cover;
  background-position: center;
}

.avatar-controls {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  flex: 1;
  min-width: 200px;
}

.profile-head {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.subject-row {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

@media (min-width: 420px) {
  .subject-row {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
  }
}

.subject-name {
  font-weight: 600;
  color: var(--text);
  min-width: 5.5rem;
}

.radio-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.radio-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.45rem 0.65rem;
  border-radius: 8px;
  border: 1px solid #2a3544;
  background: var(--bg);
  color: var(--muted);
  font-size: 0.9rem;
  cursor: pointer;
  min-height: 44px;
}

.radio-pill input {
  margin: 0;
  accent-color: var(--accent);
}

.radio-pill input:focus-visible + span,
.radio-pill input:checked + span {
  color: var(--accent);
  font-weight: 600;
}

.level-summary {
  margin-top: 0.5rem;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.container-chat {
  max-width: 36rem;
}

.room-cards {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-top: 1rem;
}

.room-card {
  border: 1px solid #2a3544;
  border-radius: var(--radius);
  padding: 1rem;
  background: var(--bg);
}

.room-card-full {
  opacity: 0.85;
}

.room-card h3 {
  margin: 0 0 0.35rem;
  font-size: 1.1rem;
}

.room-meta {
  margin: 0 0 0.5rem;
  font-size: 0.9rem;
  color: var(--muted);
}

.room-members {
  margin: 0 0 0.75rem;
  padding-left: 1.1rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.chat-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
}

.chat-panel-head h2 {
  margin: 0;
  font-size: 1.15rem;
}

.chat-messages {
  border: 1px solid #2a3544;
  border-radius: 8px;
  background: var(--bg);
  min-height: 220px;
  max-height: 45vh;
  overflow-y: auto;
  padding: 0.75rem;
  margin: 0.75rem 0;
}

.chat-msg {
  margin-bottom: 0.65rem;
  padding: 0.45rem 0.5rem;
  border-radius: 6px;
  background: rgba(42, 53, 68, 0.35);
}

.chat-msg-own {
  border-left: 3px solid var(--accent);
}

.chat-msg-head {
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 0.2rem;
}

.chat-msg-head strong {
  color: var(--text);
}

.chat-msg-time {
  margin-left: 0.35rem;
}

.chat-msg-body {
  font-size: 0.95rem;
  white-space: pre-wrap;
  word-break: break-word;
}

.chat-rating-box {
  display: grid;
  gap: 0.5rem;
  padding: 0.75rem;
  margin-top: 0.75rem;
  border: 1px solid #2a3544;
  border-radius: 8px;
  background: rgba(42, 53, 68, 0.12);
}

.chat-rating-input,
.chat-rating-textarea {
  width: 100%;
  padding: 0.55rem 0.65rem;
  border-radius: 8px;
  border: 1px solid #2a3544;
  background: var(--bg);
  color: var(--text);
}

.chat-rating-textarea {
  min-height: 5rem;
}

.chat-ratings-pro-list {
  list-style: none;
  padding: 0;
  margin: 0 0 0.75rem;
  font-size: 0.95rem;
}

.chat-ratings-pro-list li {
  padding: 0.35rem 0;
  border-bottom: 1px solid #2a3544;
}

.chat-appointment {
  border: 1px solid #2a3544;
  border-radius: 8px;
  padding: 0.75rem;
  margin-bottom: 0.75rem;
  background: rgba(42, 53, 68, 0.12);
}

.chat-appointment-text {
  margin: 0 0 0.5rem;
}

.room-appointment {
  margin: 0.75rem 0 0;
  font-size: 0.95rem;
  color: var(--text);
}

.chat-send {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.chat-send input {
  flex: 1 1 12rem;
  min-width: 0;
  padding: 0.65rem 0.75rem;
  border-radius: 8px;
  border: 1px solid #2a3544;
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
  min-height: 44px;
}

.chat-send input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.chat-send .btn {
  flex: 0 0 auto;
}

.page-title {
  margin: 0 0 1rem;
  font-size: 1.35rem;
}

.card-title {
  margin: 0 0 0.75rem;
  font-size: 1.1rem;
}

.subsection-title {
  margin: 1rem 0 0.5rem;
  font-size: 1rem;
  font-weight: 600;
}

.tabs {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.tab-btn {
  padding: 0.5rem 0.85rem;
  border-radius: 8px;
  border: 1px solid #2a3544;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.95rem;
  cursor: pointer;
  min-height: 44px;
}

.tab-btn.is-active {
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}

.tab-panel.is-active {
  display: block;
}

.mono {
  font-family: ui-monospace, "Cascadia Mono", "Consolas", monospace;
  font-size: 0.95rem;
  color: var(--text);
}

.code-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.code-list li {
  padding: 0.35rem 0;
  border-bottom: 1px solid #2a3544;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.95rem;
  color: var(--muted);
}

.check-row input {
  width: 1.1rem;
  height: 1.1rem;
  accent-color: var(--accent);
}

.shop-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}

.shop-card .shop-price {
  color: var(--success);
  font-weight: 600;
  margin: 0 0 0.75rem;
}

.shop-card .shop-desc {
  color: var(--muted);
  font-size: 0.95rem;
  white-space: pre-wrap;
}

.shop-balance-line {
  font-size: 0.95rem;
}

.shop-actions {
  margin-top: 0.75rem;
}

.shop-points-hint {
  margin: 0.25rem 0 0;
  font-size: 0.9rem;
}

.admin-shop-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  margin-bottom: 1rem;
}

.table-scroll {
  overflow-x: auto;
  margin-top: 0.5rem;
  -webkit-overflow-scrolling: touch;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.admin-table th,
.admin-table td {
  border-bottom: 1px solid #2a3544;
  padding: 0.5rem 0.45rem;
  text-align: left;
  vertical-align: top;
}

.admin-table th {
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
}

.admin-table .admin-points-input {
  width: 5.5rem;
  padding: 0.35rem 0.45rem;
  border-radius: 6px;
  border: 1px solid #2a3544;
  background: var(--bg);
  color: var(--text);
}

.admin-table .admin-note-input {
  min-width: 7rem;
  max-width: 14rem;
  width: 100%;
  padding: 0.35rem 0.45rem;
  border-radius: 6px;
  border: 1px solid #2a3544;
  background: var(--bg);
  color: var(--text);
}

.admin-rating-comment {
  max-width: 18rem;
  word-break: break-word;
}

/* Appointment modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(0, 0, 0, 0.6);
}

.modal-card {
  width: 100%;
  max-width: 30rem;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid #2a3544;
  border-radius: var(--radius);
  padding: 1.25rem 1.25rem 1rem;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
}

.modal-title {
  margin: 0 0 1rem;
}

.modal-field {
  margin-bottom: 1rem;
}

.modal-field label {
  display: block;
  margin-bottom: 0.35rem;
  font-weight: 600;
}

.modal-input {
  width: 100%;
  padding: 0.55rem 0.65rem;
  border-radius: 8px;
  border: 1px solid #2a3544;
  background: var(--bg);
  color: var(--text);
  font: inherit;
}

.modal-input:focus {
  outline: none;
  border-color: var(--accent);
}

.modal-hint {
  margin: 0.35rem 0 0.5rem;
}

.modal-map-wrap {
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid #2a3544;
  background: var(--bg);
  aspect-ratio: 16 / 10;
}

.modal-map {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
}

.modal-map-link {
  display: inline-block;
  margin-top: 0.5rem;
  font-size: 0.9rem;
}

.modal-error {
  color: var(--danger);
  min-height: 1.2em;
  margin: 0 0 0.75rem;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}
