:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --text: #172033;
  --muted: #5f6f89;
  --line: #d9e1ee;
  --primary: #1f5eff;
  --primary-strong: #1747c7;
  --danger: #c62828;
  --success: #147a46;
  --focus: #ffbf47;
  --shadow: 0 10px 30px rgba(23, 32, 51, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

a {
  color: inherit;
}

button,
input,
textarea {
  font: inherit;
}

button,
.button {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  padding: 0.72rem 1rem;
  font-weight: 700;
  cursor: pointer;
}

button:hover,
.button:hover {
  background: var(--primary-strong);
}

button.secondary {
  background: #eaf0ff;
  color: var(--primary-strong);
}

button.secondary:hover {
  background: #dbe6ff;
}

button.danger {
  background: #fee8e8;
  color: var(--danger);
}

button.export {
  background: #e8f7ef;
  color: var(--success);
}

button:focus-visible,
a:focus-visible,
textarea:focus-visible,
input:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 0.78rem 0.85rem;
}

textarea {
  min-height: 170px;
  resize: vertical;
}

label {
  display: block;
  margin: 0.75rem 0 0.35rem;
  font-weight: 700;
}

pre {
  margin: 0;
  max-width: 100%;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  background: #0e1726;
  color: #e9f0fb;
  border-radius: 8px;
  padding: 1rem;
  min-height: 9rem;
}

.skip-link {
  position: absolute;
  left: 1rem;
  top: -4rem;
  z-index: 20;
  background: #fff;
  color: var(--text);
  padding: 0.7rem 1rem;
  border-radius: 8px;
}

.skip-link:focus {
  top: 1rem;
}

.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;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 1rem;
  min-height: 64px;
  padding: 0.75rem 1rem;
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  min-height: 44px;
  font-weight: 800;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
}

.nav-toggle {
  display: none;
  margin-left: auto;
  width: 44px;
  padding: 0;
}

.nav-toggle span[aria-hidden="true"],
.nav-toggle span[aria-hidden="true"]::before,
.nav-toggle span[aria-hidden="true"]::after {
  display: block;
  width: 20px;
  height: 2px;
  margin: auto;
  background: #fff;
  content: "";
}

.nav-toggle span[aria-hidden="true"]::before {
  transform: translateY(-6px);
}

.nav-toggle span[aria-hidden="true"]::after {
  transform: translateY(4px);
}

.primary-nav {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  margin-left: auto;
  overflow-x: auto;
}

.primary-nav a {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  padding: 0.45rem 0.7rem;
  border-radius: 8px;
  color: var(--muted);
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}

.primary-nav a:hover,
.primary-nav a[aria-current="page"] {
  background: #eef3ff;
  color: var(--primary-strong);
}

.app-shell {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 1rem;
}

.page-header {
  margin: 1rem 0 1.2rem;
}

.page-header h1 {
  margin: 0;
  max-width: 780px;
  font-size: clamp(2rem, 5vw, 3.4rem);
  line-height: 1.05;
}

.page-header.compact h1 {
  font-size: clamp(1.75rem, 4vw, 2.5rem);
}

.page-header p {
  max-width: 760px;
  color: var(--muted);
}

.eyebrow {
  margin: 0 0 0.35rem;
  color: var(--primary-strong);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.module-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 1rem;
}

.module-card,
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.module-card {
  display: grid;
  gap: 0.45rem;
  min-height: 160px;
  padding: 1.1rem;
  text-decoration: none;
}

.module-card:hover {
  border-color: #a9bfff;
  transform: translateY(-1px);
}

.module-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: #eef3ff;
  color: var(--primary-strong);
  font-weight: 900;
}

.module-title {
  font-size: 1.05rem;
  font-weight: 800;
}

.module-desc,
.muted {
  color: var(--muted);
}

.workspace {
  display: grid;
  gap: 1rem;
}

.workspace.two-column {
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
}

.workspace.single {
  grid-template-columns: minmax(0, 1fr);
}

.panel {
  padding: 1rem;
}

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

.panel-heading {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 1rem;
}

.panel-heading p {
  margin: 0;
  color: var(--muted);
  font-weight: 700;
}

.mic-area,
.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin: 0.8rem 0;
}

.mic-button {
  min-width: 170px;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.result-grid .wide {
  grid-column: 1 / -1;
}

.section-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.7rem;
}

.section-tabs span,
.check-list li {
  border-radius: 8px;
  background: var(--panel-soft);
  color: var(--muted);
  padding: 0.4rem 0.6rem;
  font-weight: 700;
}

.check-list {
  display: grid;
  gap: 0.5rem;
  padding: 0;
  list-style: none;
}

.settings-list {
  display: grid;
  grid-template-columns: minmax(110px, 180px) 1fr;
  gap: 0.7rem;
}

.settings-list dt {
  color: var(--muted);
  font-weight: 800;
}

.settings-list dd {
  margin: 0;
}

@media (max-width: 900px) {
  .nav-toggle {
    display: inline-grid;
    place-items: center;
  }

  .primary-nav {
    position: absolute;
    left: 0;
    right: 0;
    top: 64px;
    display: none;
    flex-direction: column;
    align-items: stretch;
    max-height: calc(100vh - 64px);
    overflow: auto;
    padding: 0.6rem;
    background: #fff;
    border-bottom: 1px solid var(--line);
  }

  .primary-nav.is-open {
    display: flex;
  }

  .primary-nav a {
    width: 100%;
  }

  .workspace.two-column,
  .result-grid {
    grid-template-columns: 1fr;
  }

  .result-grid .wide {
    grid-column: auto;
  }
}

@media (max-width: 420px) {
  .app-shell,
  .panel,
  .module-card {
    padding: 0.85rem;
  }

  .topbar {
    padding: 0.55rem 0.75rem;
  }

  button {
    width: 100%;
  }

  .settings-list {
    grid-template-columns: 1fr;
  }
}


/* MISSIONAI_PUBLISH_EDIT_V2 */
select.select-input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 0.78rem 0.85rem;
}

.helper-text {
  margin: 0.4rem 0 0.75rem;
  color: var(--muted);
  font-size: 0.93rem;
}

pre,
.publish-output {
  background: #ffffff;
  color: #172033;
  border: 1px solid #d9e1ee;
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(23, 32, 51, 0.08);
  padding: 1.15rem;
  min-height: 9rem;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.02rem;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: normal;
}

.result-panel,
.result-grid .panel {
  background: #ffffff;
}

.missionai-edit-panel {
  margin: 1.2rem 0 2rem;
  padding: 1rem;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
}

.missionai-edit-panel h2 {
  margin-top: 0;
}

.missionai-edit-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.75rem;
}

.missionai-edit-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
}

.missionai-edit-status {
  color: var(--muted);
  font-weight: 700;
}

.missionai-capability-note {
  background: #f8fafc;
  border-left: 4px solid var(--primary);
  padding: 0.8rem 1rem;
  border-radius: 8px;
  color: var(--text);
  font-size: 0.95rem;
}

@media print {
  .topbar,
  .missionai-edit-panel,
  form,
  button,
  .skip-link {
    display: none !important;
  }

  body {
    background: #fff;
  }

  .app-shell {
    width: 100%;
    padding: 0;
  }

  pre,
  .publish-output {
    border: 0;
    box-shadow: none;
    padding: 0;
    font-size: 12pt;
    line-height: 1.55;
  }
}


/* MISSIONAI_GLOBAL_LANGUAGE_V5 */
.global-language-control {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  margin-left: auto;
  margin-right: 0.5rem;
  white-space: nowrap;
}

.global-language-control label {
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 800;
}

.global-language-control select {
  width: auto;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 0.45rem 0.7rem;
  font-weight: 700;
}

@media (max-width: 820px) {
  .global-language-control {
    order: 3;
    width: 100%;
    margin-left: 0;
    margin-right: 0;
    justify-content: flex-start;
  }

  .global-language-control select {
    flex: 1;
  }
}


/* MISSIONAI_UI_I18N_V7 */
html[lang="fi"] .global-language-control label,
html[lang="sw"] .global-language-control label,
html[lang="es"] .global-language-control label {
  letter-spacing: 0;
}

.global-language-control {
  flex-shrink: 0;
}

/* MISSIONAI_TOPBAR_RESTORE_V8B
   Restore the previous clean topbar. Language selector stays functional,
   but does not visually stretch or re-layout the navigation. */
.global-language-control {
  display: inline-flex;
  align-items: center;
  gap: 0;
  margin-left: 0.35rem;
  flex: 0 0 auto;
}

.global-language-control label:not(.sr-only) {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

#missionai-global-language {
  width: auto;
  max-width: 132px;
  min-height: 34px;
  padding: 0.25rem 1.65rem 0.25rem 0.55rem;
  border-radius: 8px;
  font-size: 0.84rem;
  font-weight: 700;
}

.topbar .primary-nav {
  flex: 1 1 auto;
  min-width: 0;
}

.topbar {
  gap: 0.55rem;
}

/* Neutralize earlier language-specific nav shrinking. */
html[lang="fi"] .primary-nav a,
html[lang="sw"] .primary-nav a,
html[lang="es"] .primary-nav a {
  font-size: inherit;
}

/* MISSIONAI_EXACT_NAV_THREE_LINES_V8G
   Exact fix: visible three-line hamburger icon in templates/components/nav.html. */
.nav-toggle-lines {
  display: inline-flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 22px;
  height: 22px;
}

.nav-toggle-lines span {
  display: block;
  width: 22px;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
}

.nav-toggle > span:first-child:not(.nav-toggle-lines) {
  display: none;
}

/* MISSIONAI_HAMBURGER_ONLY_FULL_FI_V8H
   User requested: only the three-line menu in the topbar.
   Hide the horizontal link list until the hamburger opens it. */
.topbar .nav-toggle,
.nav-toggle {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 38px;
  padding: 0;
  border-radius: 10px;
  flex: 0 0 auto;
  z-index: 30;
}

.nav-toggle-lines {
  display: inline-flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 22px;
  height: 22px;
}

.nav-toggle-lines span {
  display: block;
  width: 22px;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
}

.nav-toggle > span:first-child:not(.nav-toggle-lines) {
  display: none !important;
}

.topbar #primary-nav.primary-nav {
  display: none !important;
}

.topbar #primary-nav.primary-nav.is-open,
.topbar #primary-nav.primary-nav.open {
  display: flex !important;
  position: absolute;
  top: calc(100% + 0.45rem);
  left: 1rem;
  right: 1rem;
  z-index: 25;
  flex-direction: column;
  align-items: stretch;
  gap: 0.35rem;
  padding: 0.75rem;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 16px 34px rgba(15, 23, 42, 0.18);
}

.topbar #primary-nav.primary-nav.is-open a,
.topbar #primary-nav.primary-nav.open a {
  display: block;
  width: 100%;
}

.topbar {
  position: sticky;
  overflow: visible;
}

.global-language-control {
  flex: 0 0 auto;
  margin-left: 0.35rem;
}

/* MISSIONAI_UNIVERSAL_VOICE_IO_V9A
   Small speech/attachment controls for every text field and result area. */
.missionai-field-tools,
.missionai-output-tools {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.35rem;
  margin-bottom: 0.55rem;
}

.missionai-icon-button {
  appearance: none;
  border: 1px solid rgba(88, 101, 242, 0.22);
  background: rgba(255, 255, 255, 0.82);
  border-radius: 999px;
  min-width: 2rem;
  height: 2rem;
  padding: 0 0.45rem;
  font-size: 0.95rem;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(22, 28, 45, 0.06);
}

.missionai-icon-button:hover,
.missionai-icon-button:focus {
  border-color: rgba(88, 101, 242, 0.55);
  outline: none;
}

.missionai-icon-button.is-listening {
  box-shadow: 0 0 0 4px rgba(88, 101, 242, 0.15);
}

.missionai-hidden-file-input {
  display: none;
}

@media (max-width: 720px) {
  .missionai-field-tools,
  .missionai-output-tools {
    gap: 0.3rem;
  }

  .missionai-icon-button {
    min-width: 1.9rem;
    height: 1.9rem;
    font-size: 0.9rem;
  }
}
