/* ==========================================================================
   Joshua AI — owner controls modal (centered popup, site theme)
   Loaded only on /m/ai — matches mobile shell tokens (--m-*)
   ========================================================================== */

/* Open buttons */
.m-ai-topmeta-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
}

.m-ai-reset,
.m-ai-ctrl-btn {
  border: 1px solid var(--m-border, #2a3328);
  background: rgba(0, 0, 0, 0.35);
  color: var(--m-muted, #9aaa90);
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  padding: 0.35rem 0.6rem;
  border-radius: 6px;
  font-family: var(--m-mono, ui-monospace, monospace);
  min-height: 32px;
  cursor: pointer;
}

.m-ai-ctrl-btn {
  color: var(--m-green-bright, #81b64c);
  border-color: rgba(129, 182, 76, 0.5);
  background: linear-gradient(180deg, rgba(40, 55, 28, 0.9), rgba(20, 28, 16, 0.95));
  font-weight: 700;
  box-shadow: 0 0 12px rgba(129, 182, 76, 0.15);
}

.m-ai-ctrl-btn:active {
  transform: scale(0.97);
  border-color: var(--m-green-bright, #81b64c);
}

/* Composer row secondary control */
.m-ai-sheet-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.55rem;
  justify-content: flex-end;
  flex-wrap: wrap;
  align-items: center;
}

.m-ai-sheet-actions .m-ai-ctrl-btn {
  margin-right: auto; /* left side of action row */
}

/* ---- Centered modal ---- */
.m-ai-owner-modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(0.75rem, env(safe-area-inset-top)) 0.75rem
    max(0.75rem, env(safe-area-inset-bottom));
  box-sizing: border-box;
}

.m-ai-owner-modal[hidden] {
  display: none !important;
}

.m-ai-owner-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.m-ai-owner-modal__card {
  position: relative;
  z-index: 1;
  width: min(100%, 420px);
  max-height: min(86dvh, 680px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  border-radius: 14px;
  border: 1px solid rgba(129, 182, 76, 0.45);
  background:
    radial-gradient(ellipse at 50% 0%, rgba(98, 153, 36, 0.14), transparent 55%),
    linear-gradient(165deg, #1a2216 0%, #0c0b09 55%, #0a0a08 100%);
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.4),
    0 18px 48px rgba(0, 0, 0, 0.65),
    0 0 32px rgba(129, 182, 76, 0.12);
}

.m-ai-owner-modal__head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.75rem 0.9rem;
  border-bottom: 1px solid rgba(129, 182, 76, 0.22);
  background: rgba(0, 0, 0, 0.35);
}

.m-ai-owner-modal__title {
  margin: 0;
  font-family: var(--m-mono, ui-monospace, monospace);
  font-size: 0.82rem;
  letter-spacing: 0.08em;
  color: var(--m-green-bright, #81b64c);
  text-shadow: 0 0 10px rgba(129, 182, 76, 0.35);
}

.m-ai-owner-modal__close {
  border: 1px solid rgba(129, 182, 76, 0.35);
  background: transparent;
  color: var(--m-green-bright, #81b64c);
  font-family: var(--m-mono, monospace);
  font-size: 0.72rem;
  letter-spacing: 0.05em;
  padding: 0.4rem 0.7rem;
  border-radius: 8px;
  min-height: 36px;
  cursor: pointer;
}

.m-ai-owner-modal__body {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0.85rem 0.9rem 0.5rem;
}

.m-ai-owner-hint {
  margin: 0 0 0.75rem;
  padding: 0.55rem 0.65rem;
  border-radius: 8px;
  border: 1px solid var(--m-border, #2a3328);
  background: rgba(0, 0, 0, 0.35);
  font-size: 0.72rem;
  line-height: 1.4;
  color: var(--m-muted, #9aaa90);
  font-family: var(--m-mono, monospace);
}

.m-ai-owner-hint.is-ok {
  color: var(--m-green-bright, #81b64c);
  border-color: rgba(129, 182, 76, 0.35);
}

.m-ai-owner-hint.is-err {
  color: #e0a06a;
  border-color: rgba(224, 160, 106, 0.4);
}

.m-ai-owner-field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin-bottom: 0.65rem;
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--m-muted, #9aaa90);
  font-family: var(--m-mono, monospace);
}

.m-ai-owner-row2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
}

.m-ai-owner-select {
  width: 100%;
  min-height: 44px;
  border-radius: 10px;
  border: 1px solid var(--m-border, #2a3328);
  background: #0a0c09;
  color: var(--m-text, #e8f0e4);
  padding: 0.5rem 0.7rem;
  font-size: 16px;
  font-family: var(--m-font, system-ui, sans-serif);
  text-transform: none;
  letter-spacing: normal;
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, #81b64c 50%),
    linear-gradient(135deg, #81b64c 50%, transparent 50%);
  background-position: calc(100% - 16px) calc(50% - 2px), calc(100% - 11px) calc(50% - 2px);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

.m-ai-owner-select:focus {
  outline: none;
  border-color: var(--m-green-bright, #81b64c);
  box-shadow: 0 0 0 2px rgba(129, 182, 76, 0.2);
}

.m-ai-owner-checks {
  margin: 0.35rem 0 0.5rem;
  padding: 0.55rem 0.65rem;
  border-radius: 10px;
  border: 1px solid var(--m-border, #2a3328);
  background: rgba(0, 0, 0, 0.28);
}

.m-ai-owner-check {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  margin: 0.45rem 0;
  font-size: 0.88rem;
  line-height: 1.35;
  color: var(--m-text, #e8f0e4);
  font-family: var(--m-font, system-ui, sans-serif);
  text-transform: none;
  letter-spacing: normal;
  cursor: pointer;
}

.m-ai-owner-check input {
  margin-top: 0.15rem;
  width: 1.15rem;
  height: 1.15rem;
  flex-shrink: 0;
  accent-color: var(--m-green-bright, #81b64c);
}

.m-ai-owner-modal__foot {
  flex: 0 0 auto;
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  flex-wrap: wrap;
  padding: 0.75rem 0.9rem;
  border-top: 1px solid rgba(129, 182, 76, 0.2);
  background: rgba(0, 0, 0, 0.4);
}

.m-ai-owner-modal__foot .m-ai-btn-send,
.m-ai-owner-modal__foot .m-ai-btn-ghost {
  min-height: 44px;
  padding: 0.55rem 1rem;
  border-radius: 10px;
  font-family: var(--m-mono, monospace);
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  font-weight: 700;
  cursor: pointer;
}

.m-ai-owner-modal__foot .m-ai-btn-ghost {
  background: transparent;
  border: 1px solid var(--m-border, #2a3328);
  color: var(--m-muted, #9aaa90);
}

.m-ai-owner-modal__foot .m-ai-btn-send {
  background: linear-gradient(180deg, #6a9a3a, #4a7228);
  border: 1px solid rgba(129, 182, 76, 0.7);
  color: #0a0c09;
  box-shadow: 0 0 16px rgba(129, 182, 76, 0.25);
}

body.m-ai-owner-open {
  overflow: hidden;
}

body.m-ai-owner-open .m-ai-orb {
  opacity: 0.25;
  pointer-events: none;
}

/* Brain sleep strip inside owner modal */
.m-ai-sleep {
  margin-top: 0.85rem;
  padding-top: 0.75rem;
  border-top: 1px dashed rgba(100, 160, 200, 0.35);
}
.m-ai-sleep__title {
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  color: #7ab8d8;
  font-family: var(--m-mono, monospace);
  font-weight: 700;
  margin-bottom: 0.25rem;
}
.m-ai-sleep__hint {
  font-size: 0.72rem;
  color: var(--m-muted, #9aaa90);
  margin: 0 0 0.5rem;
  line-height: 1.35;
}
.m-ai-sleep__actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
}
.m-ai-sleep__out {
  margin: 0.55rem 0 0;
  padding: 0.5rem 0.6rem;
  max-height: 140px;
  overflow: auto;
  font-size: 0.65rem;
  line-height: 1.35;
  white-space: pre-wrap;
  word-break: break-word;
  background: rgba(0, 12, 20, 0.55);
  border: 1px solid rgba(80, 140, 180, 0.3);
  border-radius: 8px;
  color: #b0d0e0;
  font-family: var(--m-mono, monospace);
}
.m-ai-sleep__out.is-err {
  color: #e8a090;
  border-color: rgba(200, 90, 70, 0.4);
}
