/* Keep tool styles inside the shared article layout. */
#article-container > main { min-width: 0; }

#article-main.openwrt-emulator {
    --fg: #1c2530;
    --muted: #5b6673;
    --accent: #0a6cc2;
    --accent-fg: #ffffff;
    --border: #d5dae1;
    --term-bg: #101418;
    color-scheme: light;
    padding: 24px 20px 28px;
    color: var(--fg);
    font-family: system-ui, -apple-system, "Segoe UI", "Hiragino Sans", "Noto Sans JP", sans-serif;
    line-height: 1.6;
}

#article-main.openwrt-emulator * { box-sizing: border-box; }

#article-main.openwrt-emulator h1 {
    margin: 0 0 8px;
    font-size: 1.5rem;
    line-height: 1.3;
}

#article-main.openwrt-emulator .tag {
    display: inline-block;
    padding: 1px 8px;
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--muted);
    font-size: 0.75rem;
    font-weight: normal;
    vertical-align: middle;
}

#article-main.openwrt-emulator p {
    margin: 0 0 16px;
    color: var(--muted);
    font-size: 1rem;
    line-height: 1.7;
}

#article-main.openwrt-emulator p.hint {
    margin: 12px 0 0;
    font-size: 0.875rem;
}

#article-main.openwrt-emulator .toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 12px;
    margin-bottom: 8px;
}

#article-main.openwrt-emulator button {
    padding: 6px 16px;
    border: 1px solid var(--accent);
    border-radius: 6px;
    background: var(--accent);
    color: var(--accent-fg);
    font: inherit;
    cursor: pointer;
}

#article-main.openwrt-emulator button.icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
}

#article-main.openwrt-emulator button.icon-button svg {
    width: 22px;
    height: 22px;
}

#article-main.openwrt-emulator button:focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: 2px;
}

#article-main.openwrt-emulator .icon-exit,
#article-main.openwrt-emulator .console.is-fullscreen .icon-enter { display: none; }

#article-main.openwrt-emulator .console.is-fullscreen .icon-exit { display: block; }

/* Full screen: the toolbar stays on top and the terminal takes the rest. The
   class is set for both the Fullscreen API and the CSS-only fallback. */
#article-main.openwrt-emulator .console.is-fullscreen {
    --fg: #e4e8ee;
    --accent: #4aa3f0;
    --accent-fg: #0b1220;
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    padding: 10px;
    background: #171b21;
}

#article-main.openwrt-emulator .console.is-fullscreen .terminal-frame {
    flex: 1;
    height: auto;
    min-height: 0;
}

#article-main.openwrt-emulator button.secondary {
    background: transparent;
    color: var(--accent);
}

#article-main.openwrt-emulator button:disabled {
    opacity: 0.45;
    cursor: default;
}

#article-main.openwrt-emulator #status {
    color: var(--fg);
    font-size: 0.875rem;
}

#article-main.openwrt-emulator progress {
    display: block;
    width: 100%;
    height: 6px;
    margin-bottom: 8px;
}

#article-main.openwrt-emulator progress[hidden] { display: none; }

/* The padding lives on the frame: xterm's fit addon sizes the terminal to the
   inner box of #terminal's parent. */
#article-main.openwrt-emulator .terminal-frame {
    height: min(62vh, 560px);
    min-height: 300px;
    padding: 8px;
    border-radius: 8px;
    background: var(--term-bg);
}

#article-main.openwrt-emulator #terminal {
    height: 100%;
    overflow: hidden;
}

#article-main.openwrt-emulator code {
    padding: 1px 4px;
    border-radius: 4px;
    background: color-mix(in srgb, var(--fg) 10%, transparent);
    color: inherit;
    font-size: 0.9em;
}

#article-main.openwrt-emulator a { color: var(--accent); }

/* Licence notices below the emulator. */
#article-main.openwrt-emulator .licenses {
    margin-top: 32px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

#article-main.openwrt-emulator .licenses h2,
#article-main.openwrt-emulator .licenses h3 {
    margin: 24px 0 8px;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--fg);
    font-size: 1.05rem;
    line-height: 1.4;
}

#article-main.openwrt-emulator .licenses h2 {
    margin-top: 0;
    font-size: 1.25rem;
}

#article-main.openwrt-emulator .licenses p,
#article-main.openwrt-emulator .licenses li,
#article-main.openwrt-emulator .licenses table {
    color: var(--fg);
    font-size: 0.9rem;
    line-height: 1.7;
}

#article-main.openwrt-emulator .licenses p { margin: 0 0 12px; }

#article-main.openwrt-emulator .licenses ul {
    margin: 0 0 12px;
    padding-left: 1.4em;
}

#article-main.openwrt-emulator .licenses code { overflow-wrap: anywhere; }

#article-main.openwrt-emulator .table-wrap {
    margin-bottom: 12px;
    overflow-x: auto;
}

/* On narrow screens the table keeps readable columns and scrolls sideways. */
#article-main.openwrt-emulator .licenses table {
    width: 100%;
    min-width: 640px;
    border-collapse: collapse;
}

#article-main.openwrt-emulator .licenses th,
#article-main.openwrt-emulator .licenses td {
    padding: 8px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: top;
}
