/* Local font declarations (copied from website) */
@font-face {
    font-family: 'ROBOTECHGPRegular';
    src: url('../fonts/ROBOTECHGPRegular.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'TitilliumText';
    src: url('../fonts/TitilliumTextRegular.otf') format('opentype');
    font-weight: 100 500;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'TitilliumText';
    src: url('../fonts/TitilliumTextBold.ttf') format('truetype');
    font-weight: 600 900;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Cubellan';
    src: url('../fonts/CubellanRegular.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Ezarion';
    src: url('../fonts/EzarionRegular.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Dosis';
    src: url('../fonts/DosisBook.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

:root {
    --fg: #f8fafc;
    --bg: #0f172a;
    --surface: #1e293b;
    --surface-light: #334155;
    --muted: #94a3b8;
    --ok: #10b981;
    --warn: #f59e0b;
    --warn2: #0b3ef5;
    --err: #44c7ef;
    --brand: #3b82f6;
    --brand-dark: #1e40af;
    --border: #334155;
    --border2: #4d617b;

    --nt-fg-92: rgba(248, 250, 252, 0.92);
    --nt-fg-78: rgba(226, 232, 240, 0.78);
    --nt-font-mono: var(--font-mono);
    --nt-top-site-bg: linear-gradient(180deg, rgba(51, 65, 85, 0.40) 0%, rgba(30, 41, 59, 0.32) 100%);
    --nt-top-site-border: rgba(148, 163, 184, 0.14);
    --nt-top-site-hover-bg: linear-gradient(180deg, rgba(4, 177, 225, 0.16) 0%, rgba(4, 177, 225, 0.08) 100%);
    --nt-top-site-hover-border: rgba(4, 177, 225, 0.30);
    --nt-top-site-hover-shadow: 0 8px 20px rgba(0, 0, 0, 0.28);
    --nt-input-focus-border: rgba(4, 177, 225, 0.55);
    --nt-focus-ring: 0 0 0 2px rgba(4, 177, 225, 0.35);


    /* Typography (match website vibe) */
    --font-display: var(--kp-font-display, 'ROBOTECHGPRegular', 'TitilliumText', system-ui, sans-serif);
    --font-heading: var(--kp-font-heading, 'Cubellan', 'TitilliumText', system-ui, sans-serif);
    --font-body: var(--kp-font-body, 'Ezarion', 'Dosis', system-ui, sans-serif);
    --font-mono: var(--kp-font-mono, 'Dosis', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace);
}

html,
body {
    margin: 0;
    padding: 0;
    font: 13px/1.4 var(--kp-font-ui, var(--font-body));
    color: var(--kp-color-fg, var(--fg));
    background: var(--kp-panel-bg, var(--bg));
    min-width: 320px;
}

.wrap {
    padding: 12px;
    background: var(--surface);

}

.wrap-hub {
    width: 520px;
    box-sizing: border-box;
    padding: 0;
    background: var(--kp-panel-bg, #232323);
    border: var(--kp-panel-border, 1px solid #111);
    box-shadow: var(--kp-panel-shadow, none);
    color: var(--kp-color-fg, #ddd);
}

header {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.header-action {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.hotkey-hint {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 3px 8px;
    border: 1px solid var(--border2);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.04);
    color: rgba(255, 255, 255, 0.88);
    font-family: var(--font-mono);
    font-size: 10px;
    line-height: 1;
    white-space: nowrap;
}

.hotkey-hint kbd {
    font-family: var(--font-mono);
    font-size: 10px;
    padding: 1px 5px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-bottom-color: rgba(0, 0, 0, 0.55);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.95);
}

h1 {
    font-size: 18px;
    font-weight: 700;
    margin: 0;
    font-family: var(--font-display);
    background: linear-gradient(135deg, var(--brand) 0%, var(--brand-dark) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    display: inline-block;
}

.version {
    font-size: 10px;
    /* Tiny font size */
    font-weight: 400;
    /* Normal weight (not bold) */
    opacity: 0.7;
    /* Subtle appearance */
    margin-left: -20pt;
    display: inline;
    color: white;
    font-family: var(--font-mono);
}

/* Keyboard Layout */
.keyboard-container {
    margin-top: 16px;
    /* padding: 16px; */
    /* border: 3px solid var(--border); */
    border-radius: 12px;
    position: relative;
    /* box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.1); */
    background: var(--surface);
}

.keyboard-container::before {
    content: '';
    position: absolute;
    top: -3px;
    left: -3px;
    right: -3px;
    bottom: -3px;
    background: linear-gradient(135deg, var(--brand) 0%, var(--brand-dark) 100%);
    border-radius: 15px;
    z-index: -1;
    opacity: 0.4;
}

/* SVG Keyboard Styles */
.keyboard-svg {
    width: 100%;
    height: auto;
    max-width: 100%;
    display: block;
    filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.3));
    border-radius: 8px;
    overflow: hidden;
}

/* Fallback content for when SVG fails to load */
.keyboard-fallback {
    padding: 20px;
    text-align: center;
    color: var(--muted);
    font-size: 14px;
    background: var(--surface-light);
    border-radius: 8px;
    border: 1px solid var(--border);
}

.keyboard-fallback p {
    margin: 0;
    font-style: italic;
}

/* Responsive SVG behavior */
@media (max-width: 400px) {
    .keyboard-container {
        padding: 8px;
    }

    .keyboard-svg {
        filter: drop-shadow(0 1px 4px rgba(0, 0, 0, 0.3));
    }

    .keyboard-fallback {
        padding: 16px;
        font-size: 13px;
    }
}

.pill {
    padding: 3px 10px;
    font-size: 11px;
    font-weight: 600;
    border: 1px solid var(--border);
}

.pill.ok {
    color: white;
    background: var(--ok);
}

.pill.warn {
    color: white;
    background: var(--warn);
}

.pill.err {
    color: white;
    background: var(--err);
}

.pill.unavailable {
    color: white;
    background: var(--muted);
    opacity: 0.8;
}

button.pill {
    border-radius: 999px;
    background: var(--surface-light);
    color: var(--fg);
    cursor: pointer;
}

button.pill:hover {
    filter: brightness(1.06);
}

button.pill:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

footer {
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
    color: var(--muted);
    text-align: center;
}

.wrap-hub footer {
    margin: 0;
    padding: 8px 14px 10px;
    border-top: 1px solid var(--kp-color-panel-edge-dark, #111);
    color: var(--kp-color-fg-mute, #777);
    font-size: 11px;
}

/* Toggle Switch Styles */
.toggle-container {
    display: flex;
    align-items: center;
    gap: 6px;
}

.toggle-container #status {
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 18px;
    padding: 0 8px;
    font-size: 10px;
    line-height: 1;
    border-radius: 3px;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 36px;
    height: 18px;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.4));
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, var(--surface-light) 0%, #2a3749 100%);
    transition: all 0.3s ease;
    border-radius: 3px;
    border: 1px solid var(--border);
    box-shadow:
        0 1px 3px rgba(0, 0, 0, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.2),
        inset 0 -1px 0 rgba(0, 0, 0, 0.3);
}

.toggle-slider:hover {
    box-shadow:
        0 2px 6px rgba(0, 0, 0, 0.5),
        inset 0 1px 0 rgba(255, 255, 255, 0.3),
        inset 0 -1px 0 rgba(0, 0, 0, 0.4);
}

.toggle-slider:active {
    box-shadow:
        0 1px 2px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(0, 0, 0, 0.4),
        inset 0 -1px 0 rgba(255, 255, 255, 0.1);
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 12px;
    width: 12px;
    left: 2px;
    bottom: 2px;
    background: linear-gradient(135deg, var(--fg) 0%, #cbd5e1 100%);
    transition: all 0.3s ease;
    border-radius: 2px;
    box-shadow:
        0 1px 2px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.3),
        inset 0 -1px 0 rgba(0, 0, 0, 0.3);
}

input:checked+.toggle-slider {
    background: linear-gradient(135deg, var(--ok) 0%, #059669 100%);
    border-color: var(--ok);
    box-shadow:
        0 1px 3px rgba(16, 185, 129, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.3),
        inset 0 -1px 0 rgba(0, 0, 0, 0.3);
}

input:checked+.toggle-slider:hover {
    box-shadow:
        0 2px 6px rgba(16, 185, 129, 0.5),
        inset 0 1px 0 rgba(255, 255, 255, 0.4),
        inset 0 -1px 0 rgba(0, 0, 0, 0.3);
}

input:checked+.toggle-slider:before {
    transform: translateX(18px);
    background: linear-gradient(135deg, white 0%, #f0fdf4 100%);
    box-shadow:
        0 1px 2px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.4),
        inset 0 -1px 0 rgba(0, 0, 0, 0.2);
}

input:disabled+.toggle-slider {
    opacity: 0.6;
    cursor: not-allowed;
    filter: grayscale(50%);
}

.unavailable-message {
    display: flex;
    align-items: center;
    gap: 8px;
}

.keyboard-container.unavailable {
    opacity: 0.5;
    filter: grayscale(70%);
    pointer-events: none;
}

.keyboard-container.unavailable .keyboard-svg {
    filter: grayscale(70%) drop-shadow(0 2px 8px rgba(0, 0, 0, 0.3));
}

.hub-grid.unavailable {
    opacity: 0.5;
    filter: grayscale(70%);
    pointer-events: none;
}

.hub-grid.unavailable .hub-card {
    cursor: not-allowed;
}


/* Legend panel */
.legend-panel{
  margin-top: 16px;
}

.legend-panel h2{
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  margin: 0 0 8px 0;
}

.legend-table{
  display: grid;
  width: 100%;
  font-size: 12px;
}

.legend-table thead,
.legend-table tbody{
  display: grid;
  grid-template-columns: 1fr 1fr;
  column-gap: 20px;
}

.legend-table tr{
  display: grid;
  grid-template-columns: minmax(4.5em, 34%) minmax(0, 1fr);
  align-items: baseline;
}

.legend-table th,
.legend-table td{
  text-align: left;
  padding: 6px 8px;
  border-bottom: 1px solid #a1b6de !important;
  min-width: 0;
}

.legend-table th{
  color: var(--muted);
  font-weight: 600;
}

.legend-table td:first-child{
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

@media (max-width: 420px) {
  .legend-table thead,
  .legend-table tbody{
    grid-template-columns: 1fr;
  }

  .legend-table thead tr[aria-hidden]{
    display: none;
  }
}

/* Hub popup — Top Sites NCT tiles */
.hub-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
    grid-auto-rows: 80px;
    gap: 12px;
    padding: 10px 14px 14px;
    align-items: start;
    align-content: start;
}

.wrap-hub header {
    margin: 0;
    padding: 0 10px 0 12px;
    min-height: 28px;
    gap: 8px;
    flex-wrap: nowrap;
    border-bottom: var(--kp-titlebar-border, 1px solid #111);
    background: var(--kp-titlebar-bg, linear-gradient(180deg, #4c4c4c 0%, #353535 45%, #252525 100%));
    box-shadow: var(--kp-titlebar-shadow, none);
}

.wrap-hub h1 {
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.02em;
    font-family: var(--kp-font-heading, var(--font-heading));
    background: none;
    -webkit-background-clip: unset;
    background-clip: unset;
    -webkit-text-fill-color: unset;
    color: var(--kp-color-fg, #e8e8e8);
}

.wrap-hub .version {
    margin-left: auto;
    color: var(--kp-color-fg-mute, #777);
}

.wrap-hub .header-controls {
    flex-shrink: 0;
    margin-left: 2px;
}
