/* Quest design — mock layout. Gold comes from the AHQ/Mud primary; everything else is mock chrome. */
.mud-layout:has(.qd) {
    background: #000 !important;
}

.qd {
    --qd-primary: var(--mud-palette-primary, #ffb500);
    --qd-primary-dark: var(--mud-palette-primary-darken, #c98f00);
    --qd-bg: #1a1a1a;
    --qd-surface: #2a2a2a;
    --qd-surface-2: #333;
    --qd-border: #444;
    --qd-text: #f2f2f2;
    --qd-muted: #b0b0b0;
    --qd-ok: #4caf50;
    --qd-warn: #ff9800;
    --qd-danger: #e53935;
    --qd-info: #29b6f6;
    --qd-magic: #ce93d8;
    min-height: 100vh;
    background: var(--qd-bg);
    color: var(--qd-text);
    font-family: 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.qd *,
.qd *::before,
.qd *::after {
    box-sizing: border-box;
}

.qd .appbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--qd-primary);
    color: #111;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .4);
    flex-wrap: wrap;
}

.qd .appbar .brand {
    font-weight: 700;
    margin-right: 0.35rem;
}

.qd .appbar .spacer {
    flex: 1;
}

.qd .btn,
.qd .appbar button {
    border: 1px solid var(--qd-border);
    background: var(--qd-surface-2);
    color: var(--qd-text);
    border-radius: 6px;
    padding: 0.45rem 0.85rem;
    cursor: pointer;
    font-size: 0.88rem;
    font-weight: 600;
    font-family: inherit;
}

.qd .appbar button {
    background: rgba(0, 0, 0, .08);
    border-color: rgba(0, 0, 0, .2);
    color: #111;
}

.qd .appbar button:hover:not(:disabled) {
    background: rgba(0, 0, 0, .15);
}

.qd .appbar button.active {
    outline: 2px solid #111;
    background: rgba(0, 0, 0, .2);
}

.qd .appbar button:disabled,
.qd .btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    filter: grayscale(.3);
}

.qd .btn.primary {
    background: var(--qd-primary);
    color: #111;
    border-color: var(--qd-primary-dark);
}

.qd .btn.primary:hover:not(:disabled) {
    filter: brightness(1.05);
}

.qd .btn.ghost {
    background: transparent;
}

.qd .btn.danger {
    background: #5a1f1f;
    border-color: #8a3030;
    color: #ffcdd2;
}

.qd .btn.sm {
    font-size: 0.8rem;
    padding: 0.3rem 0.65rem;
}

.qd .layout {
    max-width: 1100px;
    margin: 0 auto;
    padding: 1rem;
}

.qd:has(.layout-fullwidth) {
    width: 100% !important;
    max-width: 100% !important;
}

.qd .layout.layout-fullwidth {
    max-width: 100% !important;
    width: 100% !important;
    padding: 0.5rem 1rem !important;
    margin: 0 !important;
}

.qd .panel {
    background: var(--qd-surface);
    border: 1px solid var(--qd-border);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
}

.qd h1,
.qd h2,
.qd h3,
.qd h4 {
    margin: 0 0 0.5rem;
    color: var(--qd-primary);
    font-family: 'Cinzel', serif !important;
    font-weight: 700;
    letter-spacing: 0.04em;
}

.qd h1 {
    font-size: 1.35rem;
}

.qd h2 {
    font-size: 1.05rem;
}

.qd h3 {
    font-size: 0.92rem;
    color: var(--qd-text);
}

.qd .muted {
    color: var(--qd-muted);
    font-size: 0.88rem;
    line-height: 1.5;
}

.qd .badge {
    display: inline-block;
    padding: 0.12rem 0.45rem;
    border-radius: 4px;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.qd .badge.ok {
    background: rgba(76, 175, 80, .2);
    color: var(--qd-ok);
}

.qd .badge.warn {
    background: rgba(255, 152, 0, .2);
    color: var(--qd-warn);
}

.qd .badge.danger {
    background: rgba(229, 57, 53, .2);
    color: var(--qd-danger);
}

.qd .badge.info {
    background: rgba(41, 182, 246, .2);
    color: var(--qd-info);
}

.qd .badge.magic {
    background: rgba(206, 147, 216, .2);
    color: var(--qd-magic);
}

.qd .badge.neutral {
    background: rgba(255, 255, 255, .08);
    color: var(--qd-muted);
}

.qd .crumb {
    font-size: 0.82rem;
    color: var(--qd-muted);
    margin-bottom: 0.75rem;
}

.qd .crumb a,
.qd .crumb button.link {
    color: var(--qd-primary);
    cursor: pointer;
    text-decoration: none;
    background: none;
    border: none;
    padding: 0;
    font: inherit;
}

.qd .crumb a:hover,
.qd .crumb button.link:hover {
    text-decoration: underline;
}

.qd .row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

.qd .between {
    justify-content: space-between;
}

.qd label.field {
    display: block;
    font-size: 0.78rem;
    color: var(--qd-muted);
    font-weight: 600;
    margin: 0.7rem 0 0.3rem;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.qd input[type=text],
.qd input[type=number],
.qd input[type=search],
.qd textarea,
.qd select {
    width: 100%;
    background: #1e1e1e;
    border: 1px solid var(--qd-border);
    color: var(--qd-text);
    border-radius: 6px;
    padding: 0.5rem 0.65rem;
    font: inherit;
}

.qd textarea {
    min-height: 8.5rem;
    resize: vertical;
    line-height: 1.45;
}

.qd input:focus,
.qd textarea:focus,
.qd select:focus {
    outline: 2px solid var(--qd-primary);
    border-color: var(--qd-primary);
}

.qd input[type=number] {
    max-width: 8rem;
}

.qd .chip-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.qd .select-chip {
    border: 1px solid var(--qd-border);
    background: var(--qd-surface-2);
    color: var(--qd-text);
    border-radius: 6px;
    padding: 0.4rem 0.65rem;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    font-family: inherit;
}

.qd .select-chip:hover {
    border-color: var(--qd-primary);
}

.qd .select-chip.selected {
    background: var(--qd-primary);
    color: #111;
    border-color: var(--qd-primary-dark);
}

.qd .card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 0.75rem;
}

.qd .camp-card,
.qd .quest-row,
.qd .dungeon-card,
.qd .pick-card {
    border: 1px solid var(--qd-border);
    border-radius: 8px;
    background: var(--qd-surface-2);
    padding: 0.85rem;
}

.qd .camp-card {
    cursor: pointer;
    text-align: left;
    width: 100%;
    color: inherit;
    font: inherit;
}

.qd .camp-card:hover,
.qd .dungeon-card.selected {
    border-color: var(--qd-primary);
}

.qd .camp-card h3 {
    color: var(--qd-primary);
    margin-bottom: 0.35rem;
}

.qd .quest-row {
    display: grid;
    grid-template-columns: 2.2rem 1fr auto;
    gap: 0.65rem;
    align-items: start;
    margin-bottom: 0.55rem;
}

.qd .seq {
    width: 2.2rem;
    height: 2.2rem;
    border-radius: 6px;
    background: rgba(255, 181, 0, .15);
    color: var(--qd-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
}

.qd .pick-card {
    cursor: pointer;
    text-align: left;
    width: 100%;
    color: inherit;
    font: inherit;
}

.qd .pick-card:hover,
.qd .pick-card.selected {
    border-color: var(--qd-primary);
    background: #3a3428;
}

.qd .code {
    font-family: ui-monospace, Consolas, monospace;
    font-size: 0.75rem;
    color: var(--qd-info);
}

.qd .dungeon-card {
    margin-bottom: 0.55rem;
}

.qd .dungeon-card .title {
    font-weight: 700;
    font-size: 1rem;
    margin-bottom: 0.25rem;
    color: var(--qd-text);
}

.qd .overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .7);
    z-index: 100;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.qd .overlay.open {
    display: flex;
}

.qd .dialog {
    background: var(--qd-surface);
    border: 1px solid var(--qd-border);
    border-radius: 10px;
    max-width: 640px;
    width: 100%;
    padding: 1.25rem;
    max-height: 90vh;
    overflow: auto;
}

.qd .dialog.wide {
    max-width: 860px;
}

.qd .sticky-actions {
    position: sticky;
    bottom: 0;
    background: linear-gradient(transparent, var(--qd-bg) 18%);
    padding: 1rem 0 0.25rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.qd .tree {
    margin: 0;
    padding-left: 1.1rem;
}

.qd .tree li {
    margin: 0.25rem 0;
}

.qd .empty {
    border: 1px dashed var(--qd-border);
    border-radius: 8px;
    padding: 1rem;
    text-align: center;
    color: var(--qd-muted);
}

.qd .warn-box {
    background: rgba(255, 152, 0, .1);
    border: 1px solid rgba(255, 152, 0, .35);
    border-radius: 6px;
    padding: 0.55rem 0.7rem;
    font-size: 0.82rem;
    color: #ffcc80;
    margin: 0.4rem 0;
}

.qd .ok-box {
    background: rgba(76, 175, 80, .1);
    border: 1px solid rgba(76, 175, 80, .35);
    border-radius: 6px;
    padding: 0.55rem 0.7rem;
    font-size: 0.82rem;
    color: #a5d6a7;
    margin: 0.4rem 0;
}

.qd .quest-grid {
    display: grid;
    grid-template-columns: minmax(280px, 38%) 1fr;
    gap: 1rem;
}

@media (max-width: 900px) {
    .qd .quest-grid {
        grid-template-columns: 1fr;
    }
}

.qd .check {
    display: flex;
    gap: 0.45rem;
    align-items: center;
    font-size: 0.88rem;
    margin: 0.4rem 0;
}

.qd .map-view {
    display: flex;
    position: fixed;
    inset: 0;
    z-index: 80;
    background: #111;
    flex-direction: column;
}

.qd .map-bar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    padding: 0.45rem 0.75rem;
    background: var(--qd-primary);
    color: #111;
}

.qd .map-bar strong {
    font-size: 0.95rem;
}

.qd .map-bar .muted {
    color: #111;
    opacity: .7;
    font-size: 0.78rem;
}

.qd .map-bar button {
    background: rgba(0, 0, 0, .08);
    border-color: rgba(0, 0, 0, .2);
    color: #111;
}

.qd .map-bar .btn.primary {
    background: #111;
    color: var(--qd-primary);
    border-color: #111;
}

.qd .map-body {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-columns: 220px minmax(0, 1fr) 200px;
    grid-template-rows: minmax(0, 1fr);
}

@media (max-width: 900px) {
    .qd .map-body {
        grid-template-columns: 160px 1fr 140px;
    }
}

.qd .map-side {
    overflow: auto;
    background: #1b1b1b;
    border-right: 1px solid var(--qd-border);
    padding: 0.7rem;
    min-height: 0;
}

.qd .map-side.right {
    border-right: 0;
    border-left: 1px solid var(--qd-border);
    display: flex;
    flex-direction: column;
    padding: 0;
}

.qd .map-side h3 {
    margin: 0 0 0.45rem;
    font-size: 0.78rem;
    color: var(--qd-primary);
    text-transform: uppercase;
    letter-spacing: .04em;
}

.qd .map-hint {
    font-size: 0.75rem;
    color: var(--qd-muted);
    line-height: 1.4;
    margin: 0.65rem 0 0;
}

.qd .map-canvas-wrap {
    position: relative;
    overflow: hidden;
    background: #0e0e0e;
    min-width: 0;
    min-height: 0;
    height: 100%;
}

.qd .map-canvas-wrap canvas {
    display: block;
    width: 100%;
    height: 100%;
    touch-action: none;
}

.qd .kbd {
    display: inline-block;
    background: #333;
    border: 1px solid #555;
    border-radius: 3px;
    padding: 0 4px;
    font-size: 0.7rem;
}

.qd .map-disabled {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-top: 0.45rem;
}

.qd .loot-list {
    list-style: none;
    margin: 0.35rem 0 0;
    padding: 0;
}

.qd .loot-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0;
    border-bottom: 1px solid var(--qd-border);
    font-size: 0.85rem;
}

.qd .loot-list.edit li input[type=number] {
    width: 4.2rem;
    padding: 0.25rem 0.4rem;
}

.qd .gold-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin: 0.35rem 0 0.5rem;
}

.qd .item-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 0.55rem;
    margin-top: 0.7rem;
}

.qd .item-card {
    border: 1px solid var(--qd-border);
    border-radius: 8px;
    background: var(--qd-surface-2);
    padding: 0.65rem;
    font-size: 0.82rem;
}

.qd .item-card.selected {
    border-color: var(--qd-primary);
    background: #3a3428;
}

.qd .item-card .row {
    justify-content: space-between;
}

.qd .map-author-overlay .check {
    margin: 0.55rem 0;
}

.qd .map-place-root {
    display: flex;
    flex-direction: column;
    min-height: 0;
    height: 100%;
}

.qd .map-place-pane,
.qd .map-monster-pane {
    min-height: 0;
    overflow: auto;
    padding: 0.7rem;
}

.qd .map-place-pane {
    flex: 1 1 50%;
}

.qd .map-monster-pane {
    flex: 1 1 50%;
    border-top: 1px solid var(--qd-border);
}

.qd .map-cat-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
    margin-bottom: 0.55rem;
}

.qd .map-cat-tab {
    border: 1px solid var(--qd-border);
    background: var(--qd-surface-2);
    color: var(--qd-text);
    border-radius: 6px;
    padding: 0.35rem 0.25rem;
    cursor: pointer;
    font-size: 0.72rem;
    font-weight: 700;
    font-family: inherit;
}

.qd .map-cat-tab:hover {
    border-color: var(--qd-primary);
}

.qd .map-cat-tab.active {
    background: var(--qd-primary);
    color: #111;
    border-color: var(--qd-primary-dark);
}

.qd .map-monster-card {
    position: fixed;
    z-index: 160;
    width: 280px;
    background: #1e1e1e;
    border: 1px solid var(--qd-primary);
    border-radius: 8px;
    padding: 0.55rem 0.65rem;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .45);
    font-size: 0.75rem;
    color: var(--qd-text);
}

.qd .map-monster-card-head {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    margin-bottom: 0.4rem;
}

.qd .map-stat-table {
    width: 100%;
    border-collapse: collapse;
    margin: 0.3rem 0;
    font-size: 0.7rem;
}

.qd .map-stat-table th,
.qd .map-stat-table td {
    border: 1px solid var(--qd-border);
    padding: 0.12rem 0.2rem;
    text-align: center;
}

.qd .map-stat-table th {
    color: var(--qd-muted);
    font-weight: 700;
}

.qd .map-tools {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
}

.qd .map-tool {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    background: #222;
    border: 1px solid var(--qd-border);
    border-radius: 6px;
    padding: 6px 4px;
    cursor: pointer;
    color: var(--qd-muted);
    font-size: 0.68rem;
    font-weight: 700;
    font-family: inherit;
}

.qd .map-tool img {
    width: 100%;
    max-height: 72px;
    object-fit: contain;
    background: #0e0e0e;
    border-radius: 4px;
}

.qd .map-tool:hover {
    border-color: var(--qd-primary);
}

.qd .map-tool.selected {
    outline: 2px solid var(--qd-primary);
    background: #3a3428;
    color: var(--qd-primary);
}

.qd .map-tool-wide {
    grid-column: 1 / -1;
    min-height: 2.2rem;
    justify-content: center;
}

.qd .map-tool-swatch {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 36px;
    border-radius: 4px;
    color: #fff;
    font-weight: 800;
    font-size: 0.85rem;
    letter-spacing: 0.02em;
}

.qd .map-filter {
    width: 100%;
    margin: 0 0 0.45rem;
}

.qd .map-side h4 {
    margin: 0.7rem 0 0.35rem;
    font-size: 0.72rem;
    color: var(--qd-muted);
    text-transform: uppercase;
    letter-spacing: .04em;
}

.qd .map-contents {
    margin: 0 0 0.75rem;
    padding: 0 0 0.65rem;
    border-bottom: 1px solid var(--qd-border);
}

.qd .map-contents-list {
    list-style: none;
    margin: 0 0 0.5rem;
    padding: 0;
}

.qd .map-contents-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.75rem;
    margin: 0.25rem 0;
    color: var(--qd-text);
}

.qd .map-contents-list button {
    font-size: 0.68rem;
    padding: 0.15rem 0.4rem;
}

.qd .map-contents-add {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.qd .map-contents-add input {
    width: 100%;
}

.qd .hint {
    background: rgba(255, 181, 0, .08);
    border: 1px dashed rgba(255, 181, 0, .4);
    border-radius: 8px;
    padding: 0.7rem 0.85rem;
    margin-bottom: 1rem;
    font-size: 0.86rem;
    color: var(--qd-muted);
}

.qd .hint strong {
    color: var(--qd-primary);
}

.qd.play-map {
    height: 70vh;
    min-height: 70vh;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--qd-border);
    border-radius: 6px;
    overflow: hidden;
}

.qd.play-map .map-body {
    flex: 1;
    min-height: 0;
}

.qd .map-body.map-body--view {
    grid-template-columns: minmax(0, 1fr);
}

.qd.play-map-overlay {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    background: #111;
}

.qd.play-map-overlay .map-body {
    flex: 1;
    min-height: 0;
}

