/* ============================================================ LeetCode Hot 100 图解 — 公共样式 浅色渐变卡片风格 + 深色主题兼容 ============================================================ */ /* ---------- CSS Variables (Light Theme — Default) ---------- */ :root { /* Light theme vars (used by Style A pages) */ --blue: #3b82f6; --blue-light: #dbeafe; --blue-dark: #1e40af; --green: #16a34a; --green-light: #dcfce7; --green-dark: #166534; --purple: #8b5cf6; --purple-light: #ede9fe; --purple-dark: #5b21b6; --red: #ef4444; --red-light: #fee2e2; --red-dark: #991b1b; --orange: #f59e0b; --orange-light: #fff7ed; --orange-dark: #9a3412; --cyan: #06b6d4; --cyan-light: #cffafe; --bg: #f1f5f9; --card: #ffffff; --border: #e2e8f0; --text: #0f172a; --text-secondary: #475569; --text-muted: #94a3b8; --surface: #ffffff; --surface2: #f1f5f9; --accent: #3b82f6; --accent2: #2563eb; --radius: 12px; --radius-lg: 16px; --shadow: 0 1px 3px rgba(0,0,0,0.06); --shadow-md: 0 4px 12px rgba(0,0,0,0.08); --transition: 0.25s ease; --mono: 'Menlo','Consolas','JetBrains Mono','Fira Code',monospace; --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif; /* Dark theme compatible vars (used by Style B pages) */ --green-dim: rgba(22,163,74,.15); --red-dim: rgba(239,68,68,.15); --orange-dim: rgba(245,158,11,.15); --blue-dim: rgba(59,130,246,.15); --purple-dim: rgba(139,92,246,.15); } *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; } body { font-family: var(--font); background: linear-gradient(135deg, #f5f7fa 0%, #e4e9f2 50%, #dfe6ed 100%); min-height: 100vh; color: var(--text); line-height: 1.6; } /* ---------- Layout ---------- */ .container { max-width: 1440px; margin: 0 auto; padding: 20px; } /* ---------- Typography ---------- */ h1 { font-size: 25px; margin: 0 0 8px; } h2 { font-size: 20px; margin: 0 0 12px; color: #1e293b; } h3 { margin: 0 0 10px; font-size: 16px; } .subtitle { color: var(--text-secondary); margin-bottom: 16px; font-size: 1.1rem; } /* ---------- Badge ---------- */ .badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; margin-left: 8px; vertical-align: middle; } .badge.easy { background: #dcfce7; color: #166534; } .badge.medium { background: #fef3c7; color: #92400e; } .badge.hard { background: #fee2e2; color: #991b1b; } /* ---------- Controls ---------- */ .controls { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 16px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; } .controls label { font-size: .82rem; color: var(--text-secondary); } .controls input, .controls select { padding: 8px 10px; border: 1px solid #cbd5e1; border-radius: 8px; font-family: var(--mono); font-size: 14px; background: #f8fafc; color: var(--text); } .controls input:focus, .controls select:focus { outline: 2px solid var(--blue); outline-offset: -1px; } .controls input[type="text"] { width: 260px; } .controls button { padding: 8px 12px; border: 1px solid #cbd5e1; border-radius: 8px; background: #f8fafc; font-size: 14px; cursor: pointer; color: var(--text); transition: background var(--transition), transform 0.1s; } .controls button:hover { background: #e2e8f0; } .controls button:active { transform: scale(0.97); } .controls button:disabled { opacity: 0.45; cursor: not-allowed; } .controls button.primary { background: var(--blue); color: white; border-color: var(--blue); } .controls button.primary:hover { background: #2563eb; } /* ---------- Pipeline / Step Indicator ---------- */ .pipeline { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; background: #eef2ff; border-radius: var(--radius); padding: 10px 16px; margin-bottom: 12px; font-size: 14px; } .pipe-step { background: white; border: 1px solid #c7d2fe; border-radius: 999px; padding: 4px 10px; color: #3730a3; transition: all var(--transition); } .pipe-step.active { background: #4f46e5; color: white; border-color: #4f46e5; font-weight: 600; box-shadow: 0 0 0 3px rgba(79,70,229,0.2); } .pipeline i { color: var(--text-muted); font-style: normal; } /* Step dots (Style B) */ .step-dot { width: 28px; height: 6px; border-radius: 3px; background: #cbd5e1; display: inline-block; transition: background .2s; cursor: pointer; } .step-dot.done { background: var(--blue); } .step-dot.active { background: var(--orange); } /* ---------- Hint Box ---------- */ .hint { background: var(--orange-light); border-left: 4px solid var(--orange); border-radius: 8px; padding: 10px 16px; margin-bottom: 12px; line-height: 1.7; font-size: 14px; } .hint.info { background: #eff6ff; border-left-color: var(--blue); } .hint.success { background: #f0fdf4; border-left-color: var(--green); } .hint #stepInfo { font-weight: 700; } /* ---------- Cards & Panels ---------- */ .card, .panel { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 20px; margin-bottom: 12px; box-shadow: var(--shadow); } .panel-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; } @media (max-width: 900px) { .panel-grid { grid-template-columns: 1fr; } } .panels { display: flex; flex-direction: column; gap: 16px; } /* ---------- Formula / Code Box ---------- */ .formula-box { background: #f0f9ff; border-radius: var(--radius); padding: 12px 16px; font-size: 15px; line-height: 1.8; margin-bottom: 12px; color: #0c4a6e; } .calc-block { background: #f8fafc; border-radius: var(--radius); padding: 12px 16px; font-size: 15px; line-height: 1.9; margin-bottom: 10px; border: 1px solid var(--border); } code { background: #f1f5f9; padding: 0.15em 0.4em; border-radius: 4px; font-size: 0.9em; color: #7c3aed; font-family: var(--mono); } pre { background: #f8fafc; border: 1px solid var(--border); border-radius: 8px; padding: 1rem; overflow-x: auto; margin: 0.75rem 0; } pre code { background: none; padding: 0; color: var(--text); } /* Code block with highlight */ .code-block { margin: 12px 0; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); } .code-block .lang-label { background: #e2e8f0; padding: 4px 12px; font-size: 12px; color: var(--text-secondary); font-weight: 600; } .code-block pre { margin: 0; border: none; border-radius: 0; } .code-block .hl { background: #fef3c7; display: inline; } .code-line { display: block; padding: 0 1rem; transition: background 0.2s; } .code-line.highlight { background: #fef3c7; border-left: 3px solid var(--orange); } /* ---------- Tables ---------- */ .table-wrap { overflow-x: auto; margin-top: 8px; } table { border-collapse: collapse; width: 100%; font-size: 13px; } th, td { border: 1px solid var(--border); padding: 5px 8px; text-align: center; } th { background: #f8fafc; color: var(--text-secondary); font-weight: 600; } /* ---------- Chips / Array Cells (Style A) ---------- */ .nums-line { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 8px 0; } .chip { display: inline-flex; align-items: center; justify-content: center; min-width: 40px; height: 36px; padding: 4px 10px; border-radius: 10px; font-family: var(--mono); font-weight: 600; font-size: 14px; transition: all var(--transition); } .chip.default { background: #e2e8f0; color: var(--text); } .chip.blue { background: var(--blue-light); color: var(--blue-dark); } .chip.green { background: var(--green-light); color: var(--green-dark); } .chip.red { background: var(--red-light); color: var(--red-dark); } .chip.orange { background: var(--orange-light); color: var(--orange-dark); } .chip.purple { background: var(--purple-light); color: var(--purple-dark); } .chip.cyan { background: var(--cyan-light); color: #155e75; } .chip.active { box-shadow: 0 0 0 3px rgba(59,130,246,0.3); transform: scale(1.08); } .chip.selected { background: #bbf7d0; color: var(--green-dark); box-shadow: 0 0 0 2px var(--green); } .chip.swapped { background: #fef3c7; color: #92400e; } .chip.pointer { border-bottom: 3px solid var(--blue); } .chip.sorted { border-bottom: 3px solid var(--green); } .chip-group { display: inline-flex; flex-direction: column; align-items: center; gap: 2px; } .chip-index { font-size: 11px; color: var(--text-muted); } /* ---------- Array Rendering (Style B) ---------- */ .arr-row { display: flex; align-items: flex-end; gap: 4px; justify-content: center; margin: 8px 0; } .arr-cell { display: flex; flex-direction: column; align-items: center; min-width: 36px; } .arr-val { font-family: var(--mono); font-size: .82rem; padding: 3px 0; color: var(--text); } .arr-bar { width: 30px; border-radius: 4px 4px 0 0; background: var(--blue); transition: all .25s; } .arr-idx { font-family: var(--mono); font-size: .68rem; color: var(--text-secondary); margin-top: 2px; } .arr-bar.min-price { background: var(--green); box-shadow: 0 0 8px var(--green); } .arr-bar.current { background: var(--orange); box-shadow: 0 0 8px var(--orange); } .arr-bar.checking { background: var(--purple); box-shadow: 0 0 6px var(--purple); } .arr-bar.covered { background: var(--blue); opacity: .7; } .arr-bar.best { background: var(--green); box-shadow: 0 0 8px var(--green); } .arr-cell .tag { font-size: .6rem; font-weight: 700; margin-top: 1px; } .tag-green { color: var(--green); } .tag-orange { color: var(--orange); } .tag-blue { color: var(--blue); } /* ---------- Arrows / Pointers ---------- */ .pointer-arrow { display: inline-flex; flex-direction: column; align-items: center; font-size: 11px; color: var(--blue); font-weight: 700; } .pointer-arrow::before { content: '▼'; font-size: 10px; } .pointer-arrow.green { color: var(--green); } .split { font-size: 22px; font-weight: 800; margin: 0 8px; color: var(--text-muted); } /* ---------- Result / Answer Box ---------- */ .current-answer { margin-top: 12px; padding: 10px 16px; background: #ecfdf5; border-radius: 10px; font-size: 16px; } .final-answer { margin-top: 16px; padding: 16px 20px; background: #ecfdf5; border: 2px solid #86efac; border-radius: var(--radius); line-height: 1.9; } .final-answer b { color: var(--green); } /* ---------- Complexity Box ---------- */ .complexity { margin-top: 10px; font-size: 13px; color: var(--text-secondary); padding: 8px 12px; background: #f1f5f9; border-radius: 8px; } /* ---------- Tree / Node Visualization ---------- */ .tree-container { display: flex; justify-content: center; padding: 20px 0; overflow-x: auto; } .tree-node { display: inline-flex; flex-direction: column; align-items: center; position: relative; } .tree-node .node-circle { width: 40px; height: 40px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; background: var(--blue-light); color: var(--blue-dark); border: 2px solid var(--blue); transition: all var(--transition); } .tree-node .node-circle.active { background: #4f46e5; color: white; box-shadow: 0 0 0 4px rgba(79,70,229,0.25); } .tree-node .node-circle.visited { background: var(--green-light); border-color: var(--green); color: var(--green-dark); } .tree-node .node-circle.current { background: #fef3c7; border-color: var(--orange); color: var(--orange-dark); box-shadow: 0 0 0 4px rgba(245,158,11,0.25); } /* ---------- Linked List Visualization ---------- */ .linked-list { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; padding: 16px 0; } .ll-node { display: inline-flex; align-items: center; gap: 0; border: 2px solid var(--blue); border-radius: 8px; overflow: hidden; transition: all var(--transition); } .ll-node .val { min-width: 48px; height: 40px; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; padding: 0 12px; background: var(--blue-light); color: var(--blue-dark); } .ll-node .arrow { width: 28px; height: 40px; display: flex; align-items: center; justify-content: center; background: #f1f5f9; border-left: 1px solid var(--border); font-size: 16px; color: var(--text-muted); } .ll-node.active { border-color: var(--green); box-shadow: 0 0 0 3px rgba(22,163,74,0.2); } .ll-node.active .val { background: var(--green-light); color: var(--green-dark); } .ll-node.current { border-color: var(--orange); box-shadow: 0 0 0 3px rgba(245,158,11,0.2); } .ll-node.current .val { background: #fef3c7; color: var(--orange-dark); } .ll-node.null-node { border-style: dashed; border-color: var(--text-muted); } .ll-node.null-node .val { background: #f1f5f9; color: var(--text-muted); font-style: italic; font-weight: 400; } .ll-arrow { font-size: 18px; color: var(--text-muted); margin: 0 2px; } /* ---------- Grid/Matrix Visualization ---------- */ .grid-viz, .grid-vis { display: inline-grid; gap: 2px; padding: 8px 0; } .grid-cell { width: 40px; height: 40px; display: flex; align-items: center; justify-content: center; border: 1px solid var(--border); border-radius: 6px; font-size: 14px; font-weight: 600; transition: all var(--transition); background: white; } .grid-cell.island { background: var(--blue-light); color: var(--blue-dark); } .grid-cell.water { background: #e0f2fe; color: #0369a1; } .grid-cell.visited { background: var(--green-light); border-color: var(--green); } .grid-cell.current { background: #fef3c7; border-color: var(--orange); box-shadow: 0 0 0 2px rgba(245,158,11,0.3); } .grid-cell.rotten { background: var(--orange-light); border-color: var(--orange); color: var(--orange-dark); } .grid-cell.fresh { background: #dcfce7; border-color: var(--green); } .grid-cell.empty { background: #f1f5f9; color: var(--text-muted); } .grid-cell.wall { background: #1e293b; color: white; } .grid-cell.path { background: #dbeafe; border-color: var(--blue); } /* Style B grid classes */ .grid-cell.highlight { background: var(--blue); color: #fff; border-color: var(--blue); } .grid-cell.computing { background: var(--orange-light); border-color: var(--orange); } .grid-cell.origin { background: var(--purple-light); border-color: var(--purple); } /* String rendering (Style B) */ .str-row { display: flex; gap: 2px; justify-content: center; margin: 8px 0; flex-wrap: wrap; } /* ---------- Stack / Queue Visualization ---------- */ .stack-container, .queue-container { display: flex; flex-direction: column; align-items: center; gap: 2px; min-height: 200px; padding: 8px; background: #f8fafc; border: 2px dashed var(--border); border-radius: var(--radius); } .stack-item, .queue-item { min-width: 80px; padding: 8px 16px; text-align: center; font-weight: 600; border-radius: 8px; font-size: 14px; transition: all var(--transition); background: var(--blue-light); color: var(--blue-dark); border: 1px solid var(--blue); } .stack-item.top, .queue-item.front { background: #4f46e5; color: white; border-color: #4f46e5; } .stack-item.popped { background: var(--red-light); color: var(--red-dark); border-color: var(--red); opacity: 0.5; } /* ---------- Step Controls ---------- */ .step-controls { display: flex; gap: 8px; align-items: center; justify-content: center; margin: 16px 0; flex-wrap: wrap; } .step-controls button { padding: 10px 16px; border: 1px solid #cbd5e1; border-radius: 8px; background: #f8fafc; font-size: 14px; cursor: pointer; transition: all var(--transition); } .step-controls button:hover { background: #e2e8f0; } .step-controls button:disabled { opacity: .45; cursor: not-allowed; } .step-controls button.primary { background: var(--blue); color: white; border-color: var(--blue); } .step-controls button.primary:hover { background: #2563eb; } .step-counter { font-size: 14px; color: var(--text-secondary); min-width: 100px; text-align: center; } /* ---------- Vis Area ---------- */ .vis-area { min-height: 120px; padding: 16px 0; position: relative; } .vis-area svg { display: block; margin: 0 auto; max-width: 100%; } /* ---------- Animation Helpers ---------- */ @keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } } @keyframes pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.05); } } @keyframes slideIn { from { opacity: 0; transform: translateX(-12px); } to { opacity: 1; transform: none; } } .animate-fade { animation: fadeIn 0.3s ease; } .animate-pulse { animation: pulse 1s infinite; } .animate-slide { animation: slideIn 0.3s ease; } /* ---------- Footer ---------- */ footer { margin-top: 3rem; text-align: center; color: var(--text-muted); font-size: 0.85rem; padding: 16px 0; } /* ---------- Responsive ---------- */ @media (max-width: 768px) { .container { padding: 12px; } h1 { font-size: 20px; } .controls { padding: 8px 10px; } .controls input[type="text"] { width: 100%; } .panel { padding: 12px; } .chip { min-width: 32px; height: 30px; font-size: 12px; padding: 2px 6px; } .grid-cell { width: 32px; height: 32px; font-size: 12px; } } /* ---------- Print ---------- */ @media print { body { background: white; } .controls, .step-controls { display: none; } .card, .panel { box-shadow: none; border: 1px solid #ccc; } } /* ---------- Nav page styles ---------- */ .hero { text-align: center; padding: 3rem 1rem; } .hero h1 { font-size: 2.5rem; margin-bottom: .5rem; justify-content: center; } .hero p { color: var(--text-secondary); font-size: 1.1rem; } .stats { display: flex; gap: 1rem; justify-content: center; margin-top: 1.5rem; flex-wrap: wrap; } .stat-card { background: white; border: 1px solid var(--border); border-radius: 12px; padding: 1rem 1.5rem; text-align: center; box-shadow: var(--shadow); min-width: 100px; } .stat-card .num { font-size: 2rem; font-weight: 800; } .stat-card .label { font-size: .85rem; color: var(--text-secondary); } .category { margin-bottom: 2rem; } .category h2 { font-size: 1.3rem; margin-bottom: .75rem; padding-bottom: .5rem; border-bottom: 2px solid var(--border); } .grid { display: grid; grid-template-columns: repeat(auto-fill,minmax(240px,1fr)); gap: 10px; } .card-link { display: block; background: white; border: 1px solid var(--border); border-radius: 10px; padding: 12px 16px; text-decoration: none; color: var(--text); transition: all .2s; box-shadow: 0 1px 2px rgba(0,0,0,.04); } .card-link:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--blue); } .card-link .id { font-size: .8rem; color: var(--text-muted); } .card-link .title { font-weight: 600; font-size: .95rem; margin-top: 2px; } /* ---------- Misc Helpers ---------- */ .processed { opacity: .85; } .dim { opacity: .3; } .best-diff { font-weight: 800; color: var(--green); } .nearest-val { color: var(--green); font-weight: 700; } .sign-plus { color: var(--green); font-weight: 800; } .sign-minus { color: var(--red); font-weight: 800; }