/* rise4-realm — heraldic cloth and an envoy ledger, using the realm's paper/ink tokens. */
.rise3d .r3-panel[data-view="realm.diplomacy"] { width: min(660px, calc(100% - 246px)); background: #221f1a; }
.rise3d .r3-panel[data-view="realm.diplomacy"] > .r3-panel-header { background: #221f1a; }
.theme-light .rise3d .r3-panel[data-view="realm.diplomacy"] { background: var(--r3-paper); }
.theme-light .rise3d .r3-panel[data-view="realm.diplomacy"] > .r3-panel-header { background: var(--r3-paper); }
.r3-realm-body { min-width: 0; }
.r3-envoy-heading { display: flex; align-items: start; gap: 18px; justify-content: space-between; margin-bottom: 10px; }
.r3-envoy-heading p { margin: 0; line-height: 1.6; max-width: 44ch; }
.r3-envoy-heading select { max-width: 190px; }
.r3-envoy-tabs { display: flex; gap: 15px; border-bottom: 1px solid var(--r3-line); margin-bottom: 10px; overflow-x: auto; }
.rise3d .r3-envoy-tabs button { padding: 12px 2px; flex-shrink: 0; border: 0; border-bottom: 2px solid transparent; background: transparent; border-radius: 6px 6px 0 0; }
.rise3d .r3-envoy-tabs button[aria-pressed="true"] { color: var(--r3-gold); border-bottom-color: var(--r3-gold); }
.r3-envoy-count { color: var(--r3-gold); margin-left: 5px; }
.r3-envoy-row, .r3-envoy-offer { border-bottom: 1px solid var(--r3-line); padding: 9px 0; }
.rise3d button.r3-envoy-summary { display: grid; grid-template-columns: 48px minmax(0,1fr) auto; gap: 14px; width: 100%; background: transparent; border: 0; text-align: left; padding: 9px 2px; align-items: center; }
.rise3d button.r3-envoy-summary:hover, .rise3d button.r3-envoy-summary[aria-expanded="true"] { background: var(--r3-control); }
.r3-envoy-name { display: grid; gap: 4px; min-width: 0; }
.r3-envoy-name strong { font-size: 16px; overflow-wrap: anywhere; }
.r3-envoy-name small { font-size: 11px; }
.r3-stance { font-size: 12px; color: var(--r3-muted); font-weight: 600; }
.r3-stance-war, .r3-oath { color: #efa18d; }
.r3-stance-alliance { color: #a6d3a6; }
.r3-stance-nap { color: var(--r3-gold); }
.theme-light .r3-stance-war, .theme-light .r3-oath { color: #9c3025; }
.theme-light .r3-stance-alliance { color: #326b3c; }
.r3-envoy-actions { display: flex; flex-wrap: wrap; gap: 7px; margin: 12px 0; }
.rise3d .r3-envoy-actions button { min-height: 42px; font-size: 12px; }
.r3-envoy-compose { padding: 12px 0; }
.r3-envoy-compose > button { margin: 6px 8px 0 0; }
.r3-envoy-resources { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; }
.r3-envoy-resources input { width: 100%; min-width: 0; }
.r3-envoy-letter { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.6; border-left: 2px solid var(--r3-gold); padding-left: 12px; }
.r3-envoy-event { display: grid; grid-template-columns: 36px minmax(0,1fr); gap: 13px; padding: 14px 0; border-bottom: 1px solid var(--r3-line); }
.r3-envoy-event p { margin: 0 0 7px; line-height: 1.55; }
.r3-envoy-event time { display: block; margin-top: 6px; font-size: 11px; }
.r3-envoy-rally { display: flex; align-items: center; gap: 10px; margin: 8px 0; }
.r3-envoy-rally input { width: 65px; }
.r3-flag-icon { display: inline-flex; width: 28px; height: 21px; flex-shrink: 0; vertical-align: middle; margin-right: 6px; }
.r3-flag-icon svg { width: 100%; height: 100%; display: block; }
.r3-envoy-summary > .r3-flag-icon { width: 48px; height: 34px; }
.r3-envoy-offer h3 { display: flex; align-items: center; gap: 8px; }
.r3-portrait > .r3-flag-icon { position: absolute; inset: 7px; width: calc(100% - 14px); height: 30px; margin: 0; z-index: 2; }
.r3-flag-preview { display: grid; grid-template-columns: 1fr 160px; align-items: center; gap: 20px; margin: 18px 0; padding: 16px 0; }
.r3-flag-large { width: min(100%, 265px); filter: drop-shadow(3px 6px 1px rgba(0,0,0,.18)); justify-self: center; }
.r3-flag-large svg { width: 100%; height: auto; display: block; }
.r3-flag-tower svg { width: 150px; height: 132px; display: block; }
.r3-flag-group { min-width: 0; border: 0; padding: 0; margin: 12px 0 20px; }
.r3-flag-group legend { font-size: 12px; font-weight: 600; color: var(--r3-gold); padding: 0 0 8px; }
.r3-flag-options { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 6px; }
.rise3d .r3-flag-choice { display: flex; align-items: center; gap: 6px; font-size: 10px; line-height: 1.25; text-align: left; padding: 7px 6px; min-height: 44px; background: transparent; }
.rise3d .r3-flag-choice[aria-pressed="true"] { border-color: var(--r3-gold); background: var(--r3-control); }
.r3-flag-choice .r3-flag-icon { width: 26px; height: 21px; margin: 0; }
.r3-flag-colours { display: flex; flex-wrap: wrap; gap: 7px; }
.rise3d .r3-flag-swatch { width: 30px; height: 30px; min-height: 30px; padding: 0; border-radius: 6px; border: 2px solid transparent; box-shadow: inset 0 0 0 1px rgba(255,255,255,.15); }
.rise3d .r3-flag-swatch[aria-pressed="true"] { outline: 2px solid var(--r3-gold); outline-offset: 2px; }
.r3-flag-advanced { margin: 8px 0 14px; }
.r3-flag-advanced summary, .r3-founding-banner > summary { color: var(--r3-gold); cursor: pointer; padding: 8px 0; }
.r3-flag-contrast { font-size: 12px; }
.rise3d .r3-flag-random { margin: 8px 0 16px; }
.r3-founding-banner { max-width: 100%; margin: 4px 0 10px; text-align: left; }
.r3-founding:has(.r3-founding-banner[open]) { max-height: calc(100% - 100px); overflow: auto; }
.r3-founding .r3-flag-preview { grid-template-columns: 1fr 100px; gap: 5px; }
.r3-founding .r3-flag-tower svg { width: 100px; }
.r3-founding .r3-flag-options { grid-template-columns: repeat(3,minmax(0,1fr)); }
@container (max-width: 960px) { .rise3d .r3-panel[data-view="realm.diplomacy"] { width: calc(100% - 28px); } }
.rise3d.is-phone .r3-panel[data-view="realm.diplomacy"] { width: auto; }
.rise3d.is-phone .r3-envoy-heading { display: block; }
.rise3d.is-phone .r3-envoy-heading select { max-width: 100%; width: 100%; margin-top: 8px; }
.rise3d.is-phone .r3-envoy-tabs { gap: 12px; }
.rise3d.is-phone .r3-envoy-tabs button { font-size: 12px; }
.rise3d.is-phone .r3-envoy-summary { grid-template-columns: 40px minmax(0,1fr) auto; gap: 9px; }
.rise3d.is-phone .r3-envoy-summary > .r3-flag-icon { width: 38px; height: 28px; }
.rise3d.is-phone .r3-flag-preview { grid-template-columns: 1fr 112px; gap: 8px; }
.rise3d.is-phone .r3-flag-tower svg { width: 112px; }
.rise3d.is-phone .r3-flag-options { grid-template-columns: repeat(3,minmax(0,1fr)); }
.rise3d.is-phone .r3-flag-swatch { width: 36px; height: 36px; min-height: 36px; }
@media (prefers-reduced-motion: reduce) { .r3-flag-editor * { transition: none; animation: none; } }
.rise3d .r3-flag-custom { display: grid; grid-template-columns: minmax(0,1fr) 48px 108px; align-items: center; gap: 8px; margin-top: 10px; font-size: 12px; }
.rise3d .r3-flag-custom input { width: 100%; min-width: 0; }
.rise3d .r3-flag-custom input[type=color] { padding: 3px; cursor: pointer; height: 44px; }
.rise3d .r3-flag-options { max-height: 260px; overflow-y: auto; overscroll-behavior: contain; }
.rise3d.is-phone .r3-flag-options { max-height: none; overflow: visible; }
.rise3d.is-phone .r3-flag-colours { gap: 8px; }
.rise3d.is-phone .r3-flag-swatch { min-width: 44px; min-height: 44px; }
