html {
    scrollbar-gutter: stable; /* Prevent layout shift when scrollbar appears */
}

:root {
    /* Typography */
    --font-sans: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --font-mono: 'JetBrains Mono', 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;

    /* Spacing scale */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 24px;
    --space-6: 32px;

    /* Light theme variables */
    --bg-primary: #f5f5f5;
    --bg-secondary: #ffffff;
    --bg-elevated: #ffffff;
    --text-primary: #1f2328;
    --text-secondary: #3f4754;
    --text-muted: #6a737d;
    --border-color: #e3e6ea;
    --border-strong: #d0d7de;
    --btn-primary: #eaa45d;
    --btn-hover: #dca662;
    --btn-disabled: #adb5bd;
    --btn-secondary-bg: #f0f2f5;
    --btn-secondary-hover: #e3e6ea;
    --shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 1px 3px rgba(15, 23, 42, 0.06);
    --shadow-elevated: 0 4px 12px rgba(15, 23, 42, 0.08);
    --tool-highlight: #fff3bf;
    --tool-highlight-text: #1f2328;
    --log-debug: #8b95a1;
    --log-info: #1f2328;
    --log-warning: #d97706;
    --log-error: #dc2626;
    --stats-header: #f0f2f5;
    --header-height: 150px;
    --header-padding: var(--space-5);
    --header-gap-main: var(--space-5);
    --frame-padding: var(--space-5);
    --border-radius: 6px;
    --border-radius-sm: 4px;
}

[data-theme="dark"] {
    /* Dark theme variables */
    --bg-primary: #1a1a1a;
    --bg-secondary: #2d2d2d;
    --bg-elevated: #262b32;
    --text-primary: #e6edf3;
    --text-secondary: #c9d1d9;
    --text-muted: #8b95a1;
    --border-color: #2d333b;
    --border-strong: #3d444d;
    --btn-primary: #eaa45d;
    --btn-hover: #dca662;
    --btn-disabled: #4a5159;
    --btn-secondary-bg: #2d333b;
    --btn-secondary-hover: #3d444d;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.25), 0 1px 3px rgba(0, 0, 0, 0.35);
    --shadow-elevated: 0 4px 12px rgba(0, 0, 0, 0.45);
    --tool-highlight: #f6c948;
    --tool-highlight-text: #15181c;
    --log-debug: #8b95a1;
    --log-info: #e6edf3;
    --log-warning: #f59e0b;
    --log-error: #f87171;
    --stats-header: #262b32;
}

.news-section {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    padding: var(--space-5);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    margin-bottom: var(--space-4);
}

.news-section h2 {
    margin: 0 0 var(--space-4) 0;
    font-size: 15px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
}

.news-item {
    padding: 20px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    margin-bottom: 15px;
    background: var(--bg-primary);
    position: relative;
}

.news-item a {
    color: var(--text-muted);
    text-decoration: underline;
}

.news-item:last-child {
    margin-bottom: 0;
}

.news-item h3 {
    margin: 0 0 10px 0;
    font-size: 16px;
    color: var(--text-primary);
}

.news-item .date {
    color: var(--text-muted);
    font-size: 13px;
    margin: 0 0 15px 0;
}

.news-item p {
    margin: 10px 0;
    line-height: 1.6;
    color: var(--text-secondary);
}

.news-item ul {
    margin: 10px 0;
    padding-left: 25px;
    color: var(--text-secondary);
}

.news-item ul li {
    margin: 8px 0;
    line-height: 1.5;
}

.news-item strong {
    color: var(--text-primary);
}

.news-mark-read {
    position: absolute;
    top: 20px;
    right: 20px;
}

.news-mark-read-btn {
    background-color: var(--btn-primary);
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    transition: background-color 0.3s ease;
    white-space: nowrap;
}

.news-mark-read-btn:hover {
    background-color: var(--btn-hover);
}

.news-mark-read-btn:disabled {
    background-color: var(--btn-disabled);
    cursor: not-allowed;
}

.news-no-items {
    color: var(--text-muted);
    font-style: italic;
    text-align: center;
    padding: 20px;
}

body {
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    margin: 0;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    transition: background-color 0.3s ease, color 0.3s ease;
}

h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    letter-spacing: -0.005em;
}

code, pre, kbd, samp,
.log-container,
.memory-editor,
.project-path,
.tool-item,
.stat-tool-name,
.execution-name,
.execution-meta,
.last-execution-name,
.config-value-mono {
    font-family: var(--font-mono);
}

#frame {
    max-width: 1600px;
    margin: 0 auto;
    padding: var(--frame-padding);
    padding-top: 0;
    min-width: 1280px;
}

.main {
    padding-top: var(--header-gap-main);
}

.header {
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background-color: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    border-bottom-left-radius: var(--border-radius);
    border-bottom-right-radius: var(--border-radius);
    padding: var(--header-padding);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    z-index: 1000;
    transition: background-color 0.3s ease, border-color 0.3s ease;
    min-height: 90px;
    box-shadow: var(--shadow);
    max-width: 1600px;
    margin: 0 auto;
}

.header-left {
    display: flex;
    gap: 30px;
}

.logo-container {
    height: var(--header-height);
    order: 1;
    flex-shrink: 0;
}

.logo-container img {
    height: calc(var(--header-height) - 20px);
    margin-top: 10px;
    display: block;
}

.header-banner {
    position: relative;
    top: 0;
    left: 0;
    order: 2;
    height: var(--header-height);
    max-height: var(--header-height);
}

.header-nav {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    justify-content: space-between;
    height: 100%;
    flex-shrink: 0;
}

.header-actions {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
}

.header-tabs {
    display: flex;
    align-items: flex-end;
    gap: 0;
}

.header-tab {
    display: flex;
    align-items: center;
    padding: 8px 20px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 15px;
    font-weight: 500;
    border-bottom: 3px solid transparent;
    transition: color 0.2s ease, border-color 0.2s ease;
    white-space: nowrap;
}

.header-tab:hover {
    color: var(--text-primary);
}

.header-tab.active {
    color: var(--btn-primary);
    border-bottom-color: var(--btn-primary);
}

.menu-button {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 8px 14px;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    font-size: 14px;
    font-family: inherit;
    transition: background-color 0.2s ease, border-color 0.2s ease;
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.menu-button:hover {
    background-color: var(--btn-secondary-hover);
    border-color: var(--border-strong);
}

.menu-dropdown {
    position: absolute;
    top: 100%;
    margin-top: 6px;
    right: 0;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    box-shadow: var(--shadow);
    min-width: 200px;
    z-index: 999;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.menu-dropdown a {
    display: block;
    padding: 12px 20px;
    color: var(--text-primary);
    text-decoration: none;
    transition: background-color 0.3s ease;
}

.menu-dropdown a:hover {
    background-color: var(--border-color);
}

.menu-dropdown a.active {
    background-color: var(--btn-primary);
    color: white;
}

.menu-dropdown hr {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 5px 0;
}

.platinum-banner-slide {
    display: none;
    pointer-events: none;
    height: 100%;
}

.platinum-banner-slide.active {
    display: block;
    pointer-events: auto;
}

.banner-image {
    object-fit: contain;
    border-radius: var(--border-radius);
}

.banner-border {
    border: 1px solid var(--border-color);
}

.platinum-banner-slide .banner-image {
    max-height: 100%;
    object-fit: contain;
}

.gold-banners-section {
    margin: 0 auto;
    width: 100%;
    position: relative;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.gold-banner {
    position: relative;
    width: 100%;
    overflow: hidden;
}

.gold-banner-slide {
    display: none;
    pointer-events: none;
}

.gold-banner-slide.active {
    display: block;
    pointer-events: auto;
}

.gold-banner-slide .banner-image {
    max-width: 100%;
    object-fit: contain;
}

/* Banner Arrow Navigation */
.banner-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
    background: rgba(128, 128, 128, 0.15);
    color: var(--text-muted);
    border: none;
    font-size: 18px;
    line-height: 1;
    width: 24px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border-radius: 4px;
    opacity: 0.3;
    transition: opacity 0.2s ease, background-color 0.2s ease, color 0.2s ease;
    padding: 0;
}

.banner-arrow:hover {
    opacity: 0.8;
    background: rgba(128, 128, 128, 0.4);
    color: var(--text-primary);
}

.banner-arrow-left {
    left: 0;
}

.banner-arrow-right {
    right: 0;
}

.page-view {
    /*max-width: 1600px;*/
    margin: 0 auto;
}

/* Overview Page Layout */
.overview-container {
    display: grid;
    grid-template-columns: 1fr 400px;
    gap: var(--space-5);
}

.overview-left {
    min-width: 0;
}

.overview-right {
    min-width: 0;
}

/* Overview Page Styles */
.config-section,
.basic-stats-section,
.projects-section {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: var(--space-5);
    margin-bottom: var(--space-4);
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.config-section h2,
.basic-stats-section h2 {
    margin: 0 0 var(--space-4) 0;
    font-size: 15px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
}

/* Collapsible Headers */
.collapsible-header {
    margin-top: 0;
    margin-bottom: 0;
    font-size: 15px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    cursor: pointer;
    user-select: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.collapsible-header:hover {
    color: var(--text-primary);
}

.toggle-icon {
    transition: transform 0.3s ease;
    font-size: 14px;
}

.toggle-icon.expanded {
    transform: rotate(-180deg);
}

.collapsible-content {
    margin-top: 15px;
    max-height: 400px;
    overflow-y: auto;
}

.config-grid {
    display: grid;
    grid-template-columns: 180px 1fr;
    gap: var(--space-3);
    margin-bottom: var(--space-4);
}

.config-label {
    font-weight: 500;
    color: var(--text-muted);
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    padding-top: 2px;
}

.config-value {
    color: var(--text-primary);
}

.config-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.config-list li {
    padding: 4px 0;
}

.tools-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 8px;
    margin-top: 10px;
}

.tool-item {
    background-color: var(--bg-primary);
    padding: 6px 10px;
    border-radius: 3px;
    font-size: 13px;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: default;
}

/* Projects List */
.project-item {
    padding: 10px 12px;
    margin: 5px 0;
    border-radius: 4px;
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    transition: background-color 0.2s ease;
}

.project-item:hover {
    background-color: var(--border-color);
}

.project-item.active {
    background-color: var(--btn-primary);
    color: white;
    border-color: var(--btn-primary);
}

.project-name {
    font-weight: bold;
    margin-bottom: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.project-path {
    font-size: 11px;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.project-item.active .project-path {
    color: rgba(255, 255, 255, 0.8);
}

/* Generic Item Styles for Tools/Modes/Contexts */
.info-item {
    padding: 8px 12px;
    margin: 5px 0;
    border-radius: 4px;
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    transition: background-color 0.2s ease;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: default;
}

.info-item:hover {
    background-color: var(--border-color);
}

.info-item.active {
    background-color: var(--btn-primary);
    color: white;
    border-color: var(--btn-primary);
    font-weight: bold;
}

/* Basic Stats Styles */
.basic-stats-section {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: var(--space-5);
    margin-bottom: var(--space-4);
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

/* Executions Styles */
.executions-section {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: var(--space-5);
    margin-bottom: var(--space-4);
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.executions-section h2 {
    margin: 0 0 var(--space-4) 0;
    font-size: 15px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
}

.execution-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.execution-item {
    display: flex;
    align-items: center;
    gap: 10px;
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 8px 12px;
    min-height: 40px;
    transition: background-color 0.2s ease, border-color 0.2s ease;
}

.execution-item.running {
    border-color: var(--btn-primary);
    background: linear-gradient(to right, rgba(234, 164, 93, 0.1), var(--bg-primary));
}

.execution-item.cancelled {
    border-color: var(--text-muted);
    background-color: var(--bg-primary);
    opacity: 0.7;
}

.execution-item.abandoned {
    border-color: var(--log-error);
    background: linear-gradient(to right, rgba(255, 0, 0, 0.1), var(--bg-primary));
}

.execution-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid var(--border-color);
    border-top-color: var(--btn-primary);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    flex-shrink: 0;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.execution-name {
    flex: 1;
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-primary);
}

.execution-meta {
    font-size: 11px;
    color: var(--text-muted);
    flex-shrink: 0;
}

.execution-cancel-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 16px;
    cursor: pointer;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.15s ease, color 0.15s ease;
    flex-shrink: 0;
}

.execution-cancel-btn:hover {
    background-color: rgba(255, 0, 0, 0.1);
    color: var(--log-error);
}

.execution-icon {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    flex-shrink: 0;
}

.execution-icon.success {
    background-color: rgba(34, 197, 94, 0.2);
    border: 1px solid rgba(34, 197, 94, 0.6);
    color: #22c55e;
}

.execution-icon.cancelled {
    background-color: var(--border-color);
    border: 1px solid var(--text-muted);
    color: var(--text-muted);
}

.execution-icon.abandoned {
    background-color: rgba(255, 0, 0, 0.2);
    border: 1px solid var(--log-error);
    color: var(--log-error);
}

.execution-icon.error {
    background-color: rgba(255, 0, 0, 0.2);
    border: 1px solid var(--log-error);
    color: var(--log-error);
}

.last-execution-container {
    display: flex;
    align-items: center;
    gap: 12px;
    background: linear-gradient(to right, rgba(34, 197, 94, 0.08), transparent);
    border: 1px solid rgba(34, 197, 94, 0.2);
    border-radius: 8px;
    padding: 12px;
}

.last-execution-container.error {
    background: linear-gradient(to right, rgba(255, 0, 0, 0.08), transparent);
    border-color: rgba(255, 0, 0, 0.2);
}

.last-execution-icon-container {
    width: 28px;
    height: 28px;
    background-color: rgba(34, 197, 94, 0.2);
    border: 1px solid rgba(34, 197, 94, 0.6);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    color: #22c55e;
    flex-shrink: 0;
}

.last-execution-container.error .last-execution-icon-container {
    background-color: rgba(255, 0, 0, 0.2);
    border-color: var(--log-error);
    color: var(--log-error);
}

.last-execution-body {
    flex: 1;
}

.last-execution-status {
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 2px;
}

.last-execution-name {
    font-size: 13px;
    color: var(--text-primary);
}

.stat-bar-container {
    display: flex;
    align-items: center;
    margin: 8px 0;
    gap: 12px;
}

.stat-tool-name {
    min-width: 200px;
    max-width: 200px;
    font-weight: bold;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: default;
}

.bar-wrapper {
    flex: 1;
    height: 24px;
    background-color: var(--border-color);
    border-radius: 3px;
    overflow: hidden;
    position: relative;
}

.bar {
    height: 100%;
    background-color: var(--btn-primary);
    transition: width 0.5s ease;
    border-radius: 3px;
}

.stat-count {
    min-width: 60px;
    text-align: right;
    font-weight: bold;
    color: var(--text-primary);
}

.no-stats-message {
    text-align: center;
    color: var(--text-muted);
    font-style: italic;
    padding: 20px;
}

/* Log Container Styles */
.log-container {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 5px;
    height: calc(100vh - var(--header-height) - 2 * var(--header-padding) - 3 * var(--header-gap-main));
    overflow-y: auto;
    overflow-x: auto;
    padding: 10px;
    white-space: pre-wrap;
    font-size: 14px;
    line-height: 1.4;
    color: var(--text-primary);
    transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease;
}

.controls {
    position: sticky;
    top: 90px;
    z-index: 100;
    background-color: var(--bg-primary);
    padding: 10px 0;
    margin-bottom: 10px;
    text-align: center;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    transition: background-color 0.3s ease;
}

.btn {
    background-color: var(--btn-primary);
    color: #fff;
    border: none;
    padding: 8px 16px;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    font-family: inherit;
    transition: background-color 0.2s ease, transform 0.05s ease;
}

.btn:hover {
    background-color: var(--btn-hover);
}

.btn:active {
    transform: translateY(1px);
}

.btn:disabled {
    background-color: var(--btn-disabled);
    cursor: not-allowed;
    transform: none;
}

.theme-toggle {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    padding: 8px 14px;
    cursor: pointer;
    font-size: 14px;
    font-family: inherit;
    transition: background-color 0.2s ease, border-color 0.2s ease;
}

.theme-toggle:hover {
    background-color: var(--btn-secondary-hover);
    border-color: var(--border-strong);
}

.theme-toggle span {
    line-height: 1;
}

.log-debug {
    color: var(--log-debug);
}

.log-info {
    color: var(--log-info);
}

.log-warning {
    color: var(--log-warning);
}

.log-error {
    color: var(--log-error);
}

.log-default {
    color: var(--log-info);
}

/* Tool name highlighting */
.tool-name {
    background-color: var(--tool-highlight);
    color: var(--tool-highlight-text);
    font-weight: bold;
}

.loading {
    text-align: center;
    color: var(--text-muted);
    font-style: italic;
}

.error-message {
    color: var(--log-error);
    text-align: center;
    margin: 10px 0;
}

/* Advanced Stats Styles */
.charts-container {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    justify-content: space-between;
    max-width: 1400px;
    margin: 0 auto;
}

.chart-group {
    flex: 1;
    min-width: 280px;
    max-width: 320px;
    text-align: center;
}

.chart-wide {
    flex: 0 0 100%;
    min-width: 100%;
    margin-top: 10px;
}

.chart-group h3 {
    margin: 0 0 10px 0;
    color: var(--text-secondary);
}

.stats-summary {
    margin: 0 auto;
    border-collapse: collapse;
    background: var(--bg-secondary);
    border-radius: 5px;
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: background-color 0.3s ease, box-shadow 0.3s ease;
}

.stats-summary th,
.stats-summary td {
    padding: 10px 20px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
    transition: border-color 0.3s ease, color 0.3s ease;
}

.stats-summary th {
    background-color: var(--stats-header);
    font-weight: bold;
    transition: background-color 0.3s ease;
}

.stats-summary tr:last-child td {
    border-bottom: none;
}

@media (max-width: 1024px) {
    .overview-container {
        grid-template-columns: 1fr;
    }

    .overview-right {
        order: -1;
    }
}

@media (max-width: 768px) {
    body {
        padding-top: 140px;
    }

    .header {
        flex-direction: column;
        gap: 10px;
        padding: 10px 15px;
    }

    .logo-container {
        width: 100%;
        text-align: center;
    }

    .logo-container img {
        max-width: 200px;
    }

    .header-nav {
        width: 100%;
        align-items: center;
    }

    .header-tabs {
        justify-content: center;
    }

    .header-actions {
        justify-content: center;
    }

    .charts-container {
        flex-direction: column;
    }

    .chart-group,
    .chart-wide {
        min-width: auto;
        max-width: none;
    }

    .controls {
        flex-direction: column;
        gap: 5px;
    }

    .config-grid {
        grid-template-columns: 1fr;
    }

    .tools-grid {
        grid-template-columns: 1fr;
    }

    .stat-bar-container {
        flex-wrap: wrap;
    }

    .stat-tool-name {
        min-width: 100%;
    }
}

/* Modal Styles */
.modal {
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(2px);
}

.modal-content {
    background-color: var(--bg-elevated);
    margin: 8vh auto;
    padding: var(--space-5);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    width: 90%;
    max-width: 500px;
    box-shadow: var(--shadow-elevated);
    position: relative;
}

.modal-close {
    color: var(--text-muted);
    float: right;
    font-size: 24px;
    font-weight: 400;
    line-height: 1;
    cursor: pointer;
    transition: color 0.2s;
}

.modal-close:hover,
.modal-close:focus {
    color: var(--text-primary);
}

.modal h3 {
    margin-top: 0;
    margin-bottom: var(--space-3);
    color: var(--text-primary);
    font-size: 17px;
    font-weight: 600;
}

/* Shared modal pieces (replace inline styles) */
.modal-info {
    margin: var(--space-3) 0;
    color: var(--text-primary);
    line-height: 1.5;
}

.modal-hint {
    margin: var(--space-3) 0;
    color: var(--text-muted);
    font-size: 13px;
    line-height: 1.5;
}

.modal-field {
    margin: var(--space-4) 0;
}

.modal-field label {
    display: block;
    margin-bottom: var(--space-2);
    font-weight: 500;
    color: var(--text-primary);
}

.modal-input,
.modal-select {
    box-sizing: border-box;
    width: 100%;
    padding: 8px 10px;
    border-radius: var(--border-radius-sm);
    border: 1px solid var(--border-strong);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 14px;
    font-family: var(--font-sans);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.modal-input:focus,
.modal-select:focus {
    outline: none;
    border-color: var(--btn-primary);
    box-shadow: 0 0 0 3px rgba(234, 164, 93, 0.18);
}

.modal-textarea {
    box-sizing: border-box;
    width: 100%;
    padding: var(--space-3);
    border: 1px solid var(--border-strong);
    border-radius: var(--border-radius-sm);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 13px;
    line-height: 1.5;
    resize: vertical;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.modal-textarea:focus {
    outline: none;
    border-color: var(--btn-primary);
    box-shadow: 0 0 0 3px rgba(234, 164, 93, 0.18);
}

.modal-actions {
    display: flex;
    gap: var(--space-2);
    justify-content: flex-end;
    margin-top: var(--space-4);
}

.modal-actions .btn {
    padding: 8px 16px;
}

.modal-prompt {
    margin: var(--space-4) 0;
    color: var(--text-primary);
    line-height: 1.5;
    font-size: 15px;
}

.btn-secondary {
    background-color: var(--btn-secondary-bg);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background-color: var(--btn-secondary-hover);
}

.modal-title-with-meta {
    margin-bottom: var(--space-4);
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex-wrap: wrap;
}

/* Filterable combobox (used in Add Language modal) */
.combobox {
    position: relative;
}

.combobox-input {
    padding-right: 28px;
}

.combobox-caret {
    position: absolute;
    top: 50%;
    right: var(--space-3);
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 12px;
    pointer-events: none;
    transition: transform 0.15s ease, color 0.15s ease;
}

.combobox.open .combobox-caret {
    color: var(--text-primary);
    transform: translateY(-50%) rotate(180deg);
}

.combobox-options {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    margin: 0;
    padding: var(--space-1) 0;
    list-style: none;
    background: var(--bg-elevated);
    border: 1px solid var(--border-strong);
    border-radius: var(--border-radius-sm);
    box-shadow: var(--shadow-elevated);
    max-height: 240px;
    overflow-y: auto;
    z-index: 20;
}

.combobox-options li {
    padding: 6px var(--space-3);
    color: var(--text-primary);
    cursor: pointer;
    font-size: 14px;
    line-height: 1.4;
    transition: background-color 0.1s ease;
}

.combobox-options li.no-match {
    color: var(--text-muted);
    font-style: italic;
    cursor: default;
}

.combobox-options li:hover:not(.no-match),
.combobox-options li.highlighted:not(.no-match) {
    background-color: var(--btn-secondary-hover);
}

.combobox-options li.highlighted:not(.no-match) {
    color: var(--text-primary);
}

.combobox-options li mark {
    background: transparent;
    color: var(--btn-primary);
    font-weight: 600;
}

.combobox-empty {
    margin-top: var(--space-2);
    color: var(--text-muted);
    font-style: italic;
    font-size: 13px;
}

.section-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.section-header-row h2 {
    margin: 0 0 var(--space-4) 0;
}

.stats-summary-block {
    margin-bottom: var(--space-5);
    text-align: center;
}

.estimator-name {
    text-align: center;
    margin-bottom: var(--space-3);
    color: var(--text-muted);
    font-size: 13px;
}

/* Language Badge Styles */
.languages-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.language-badge {
    position: relative;
    display: inline-flex;
    align-items: center;
    padding: 6px 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 500;
}

.language-badge.removable {
    padding-right: 28px;
}

.language-remove {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 68, 68, 0.1);
    border-radius: 3px;
    cursor: pointer;
    color: #ff4444;
    font-size: 14px;
    font-weight: bold;
    line-height: 1;
    transition: all 0.2s;
}

.language-remove:hover {
    background: rgba(255, 68, 68, 0.2);
    transform: scale(1.1);
}

.language-add-btn {
    padding: 6px 12px;
    font-size: 13px;
    font-weight: 500;
    border-radius: 6px;
    border: 1px dashed var(--border-color);
    background: var(--bg-secondary);
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s;
}

.language-add-btn:hover {
    background: var(--border-color);
    border-color: var(--btn-primary);
    color: var(--btn-primary);
}

.memory-add-btn {
    display: inline-flex;
    align-items: center;
    padding: 8px 12px;
    margin: 5px;
    border-radius: 4px;
    border: 1px dashed var(--border-color);
    background: var(--bg-secondary);
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
    font-size: inherit;
    font-weight: inherit;
    line-height: inherit;
}

.memory-add-btn:hover {
    background: var(--border-color);
    border-color: var(--btn-primary);
    color: var(--btn-primary);
}

.language-spinner {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 12px;
}

.spinner {
    width: 16px;
    height: 16px;
    border: 2px solid var(--border-color);
    border-top-color: var(--btn-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Memory Editor Styles */
.modal-content-large {
    max-width: 800px;
    width: 90%;
}

.memory-editor {
    font-family: 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.5;
    tab-size: 4;
    -moz-tab-size: 4;
}

.memory-editor:focus {
    outline: 2px solid var(--btn-primary);
    outline-offset: -1px;
}

/* Memory Item Styles */
.memory-item {
    position: relative;
    display: inline-flex;
    align-items: center;
    padding: 8px 12px;
    margin: 5px;
    border-radius: 4px;
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    transition: background-color 0.2s ease;
    cursor: pointer;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.memory-item:hover {
    background-color: var(--border-color);
    text-decoration: underline;
}

.memory-item.removable {
    padding-right: 28px;
}

.memory-remove {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 68, 68, 0.1);
    border-radius: 3px;
    cursor: pointer;
    color: #ff4444;
    font-size: 14px;
    font-weight: bold;
    line-height: 1;
    transition: all 0.2s;
}

.memory-remove:hover {
    background: rgba(255, 68, 68, 0.2);
    transform: scale(1.1);
    text-decoration: none;
}

.memories-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

/* Memory Rename Styles */
.memory-rename-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    cursor: pointer;
    color: var(--text-muted);
    opacity: 0.5;
    transition: opacity 0.2s ease, background-color 0.2s ease;
}

.memory-rename-btn:hover {
    opacity: 1;
    background-color: var(--border-color);
}

.memory-rename-input {
    font-size: inherit;
    font-weight: inherit;
    font-family: inherit;
    color: var(--text-primary);
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--btn-primary);
    outline: none;
    padding: 0;
    flex: 1;
    min-width: 200px;
    max-width: 80%;
}

/* Log Action Buttons (Save, Copy, Clear) */
.log-action-buttons {
    position: absolute;
    top: 15px;
    right: 20px;
    z-index: 10;
    display: flex;
    gap: 8px;
    align-items: center;
}

.log-action-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-primary);
    cursor: pointer;
    opacity: 0.8;
    transition: opacity 0.2s ease, background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
    font-size: 13px;
    font-weight: 500;
}

.log-action-btn:hover {
    opacity: 1;
    background-color: var(--border-color);
}

.log-action-btn svg {
    flex-shrink: 0;
}

.log-action-btn-text {
    display: none;
    white-space: nowrap;
}

.log-action-btn:hover .log-action-btn-text {
    display: inline;
}

.log-action-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.log-action-btn-danger:hover {
    background-color: var(--border-color);
    border-color: rgba(220, 53, 53, 0.9);
    color: var(--log-error);
}
