* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, sans-serif;
  color: #222;
}

a {
  color: #7a1f1f;
}

.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1.5rem;
  background: #1f1f1f;
  color: #fff;
}

.navbar a {
  color: #fff;
  text-decoration: none;
}

.navbar-middle ul {
  display: flex;
  gap: 1rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

.navbar-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.navbar-logout {
  margin: 0;
}

.inline-form {
  display: inline;
  margin-left: 0.5rem;
}

.navbar-logout button {
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
  font: inherit;
  padding: 0;
}

.page {
  display: flex;
  min-height: calc(100vh - 6rem);
}

.page aside {
  width: 220px;
  padding: 1rem;
  background: #f5f5f5;
  border-right: 1px solid #ddd;
}

.content {
  flex: 1;
  /* Without this, a flex item defaults to min-width:auto - it won't shrink below its
     content's intrinsic width, so one wide child (e.g. a data table) stretches the whole
     page horizontally instead of scrolling within itself. */
  min-width: 0;
  padding: 1.5rem;
}

.app-footer {
  display: flex;
  justify-content: space-between;
  padding: 0.75rem 1.5rem;
  background: #1f1f1f;
  color: #ccc;
  font-size: 0.85rem;
}

.center {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 6rem);
}

.auth {
  width: 100%;
  max-width: 360px;
  padding: 1.5rem;
}

.auth form p {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

/* Forms (dictionary create/edit, etc.) */

input[type="text"],
input[type="number"],
input[type="email"],
input[type="password"],
select,
textarea {
  font: inherit;
  color: inherit;
  padding: 0.4rem 0.6rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  background: #fff;
}

input[type="text"]:focus,
input[type="number"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: #7a1f1f;
  box-shadow: 0 0 0 2px rgba(122, 31, 31, 0.15);
}

textarea {
  min-height: 6rem;
  resize: vertical;
}

button,
input[type="submit"],
.button-link {
  /* font: inherit; */
  cursor: pointer;
  display: inline-block;
  padding: 0.25rem 0.25rem;
  border: none;
  border-radius: 4px;
  background: #7a1f1f;
  color: #fff;
  text-decoration: none;
}

button:hover,
input[type="submit"]:hover,
.button-link:hover {
  background: #5e1717;
}

.errorlist {
  color: #b3261e;
  list-style: none;
  padding: 0;
  margin: 0.25rem 0;
  font-size: 0.85rem;
}

.helptext {
  display: block;
  color: #666;
  font-size: 0.8rem;
  margin-top: 0.2rem;
}

form table {
  width: 100%;
  max-width: 40rem;
  table-layout: fixed;
  border-collapse: collapse;
  margin-bottom: 1rem;
}

form table th {
  width: 30%;
  text-align: right;
  vertical-align: top;
  padding: 0.5rem 1rem 0.5rem 0;
  font-weight: 600;
}

form table td {
  width: 70%;
  padding: 0.5rem 0;
}

form table input,
form table select,
form table textarea,
form table .ts-wrapper {
  width: 100%;
  max-width: 28rem;
}

/* Tom Select (multi-select fields) */

.ts-wrapper.focus .ts-control {
  border-color: #7a1f1f;
  box-shadow: 0 0 0 2px rgba(122, 31, 31, 0.15);
}

.ts-control .item {
  background: #7a1f1f;
  color: #fff;
  border-radius: 3px;
}

.ts-dropdown .active {
  background: #f3e6e6;
  color: #222;
}

/* Dictionary list filters */

.dictionary-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 1rem;
  margin: 1rem 0;
  padding: 0.75rem 1rem;
  background: #f5f5f5;
  border-radius: 4px;
}

.dictionary-filters label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.85rem;
  font-weight: 600;
}

.dictionary-filters input[type="text"],
.dictionary-filters select {
  font-weight: normal;
}

/* Data tables (dictionary lists, etc.) */

.data-table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
}

.data-table th,
.data-table td {
  padding: 0.5rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid #e5e5e5;
}

.data-table th {
  background: #f5f5f5;
  font-weight: 600;
}

.data-table tbody tr:hover {
  background: #faf5f5;
}

.data-table .member-portrait {
  display: block;
  width: 2.5rem;
  height: 2.5rem;
  object-fit: cover;
  border-radius: 4px;
}

.content nav {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 1rem;
}

/* Sidebar dictionary submenu */

.page aside h2 {
  font-size: 1rem;
  margin: 0 0 0.5rem;
}

.page aside ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.page aside li a {
  display: block;
  padding: 0.35rem 0.5rem;
  border-radius: 4px;
  color: #222;
  text-decoration: none;
}

.page aside li a:hover {
  background: #ebebeb;
}

.page aside li.active a {
  background: #7a1f1f;
  color: #fff;
  font-weight: 600;
}

/* Party page ambitions list (character sheet itself uses static/css/character_sheet_classic.css) */

.ambition-list {
  margin: 0 0 0.75rem;
  padding-left: 1.25rem;
}

.ambition-list .achieved {
  text-decoration: line-through;
  color: #888;
}

/* Site-wide Django messages (django.contrib.messages) */

.messages {
  list-style: none;
  padding: 0;
  margin: 0 0 1rem;
}

.messages li {
  padding: 0.5rem 0.75rem;
  margin-bottom: 0.5rem;
  border-radius: 4px;
}

.messages li.success {
  background: #dff0d8;
  color: #3c763d;
}

.messages li.error {
  background: #f2dede;
  color: #a94442;
}

/* Mobile: .page aside is included on every page (partials/sidebar.html) and reserves its
   220px + padding even when empty (no sidebar_menu on this page) - fine on desktop, but on a
   narrow viewport that's a fixed chunk of the screen gone for nothing. Stack instead of
   side-by-side below the breakpoint. */
@media (max-width: 768px) {
  .page {
    flex-direction: column;
  }
  .page aside {
    width: 100%;
    box-sizing: border-box;
    border-right: none;
    border-bottom: 1px solid #ddd;
  }
}

/* Character/Party note form - textarea + a markdown cheat sheet alongside it */

.note-form-row {
  display: flex;
  gap: 1.5rem;
  align-items: flex-start;
  margin-bottom: 1rem;
}

.note-form-field {
  flex: 1 1 auto;
}

.note-form-field textarea {
  width: 100%;
  min-height: 12rem;
  box-sizing: border-box;
}

.note-form-help {
  flex: 0 0 16rem;
  padding: 0.75rem 1rem;
  background: #f5f5f5;
  border: 1px solid #ddd;
  border-radius: 4px;
}

.note-form-help h2 {
  margin: 0 0 0.5rem;
  font-size: 0.95rem;
}

.note-form-help pre {
  margin: 0;
  white-space: pre-wrap;
  font-size: 0.85rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.draft-badge {
  display: inline-block;
  margin-left: 0.6rem;
  padding: 0.1rem 0.5rem;
  font-size: 80%;
  font-weight: bold;
  color: #076;
  border: 1px solid #076;
  border-radius: 999px;
}
