:root {
	--bg: #f4f5f7; --surface: #ffffff; --text: #1d2330; --muted: #5d6677;
	--border: #d9dde5; --accent: #2f5d50; --accent-text: #ffffff; --danger: #b3261e;
	--radius: 10px; --shadow: 0 1px 3px rgba(20, 30, 50, .12);
}
@media (prefers-color-scheme: dark) {
	:root {
		--bg: #14181f; --surface: #1d232d; --text: #e8ebf0; --muted: #98a1b2;
		--border: #333c4b; --accent: #5fa58f; --accent-text: #0c1512; --danger: #f2b8b5;
		--shadow: 0 1px 3px rgba(0, 0, 0, .5);
	}
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
h1, h2, h3, h4, p { margin: 0; }
h2 { font-size: 1.25rem; margin-bottom: .35rem; }
h3 { font-size: 1.05rem; margin: 1.25rem 0 .5rem; }
h4 { font-size: .95rem; margin: 1rem 0 .4rem; color: var(--muted); }

.app-header { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .9rem 1.25rem; background: var(--surface); border-bottom: 1px solid var(--border); }
.brand h1 { font-size: 1.35rem; }
.brand p { color: var(--muted); font-size: .85rem; }

.layout { display: grid; grid-template-columns: 320px 1fr; gap: 1.25rem; padding: 1.25rem; max-width: 1400px; margin: 0 auto; }
@media (max-width: 860px) { .layout { grid-template-columns: 1fr; padding: .75rem; } }
.sidebar { display: flex; flex-direction: column; gap: 1rem; align-self: start; }
.panel, .content { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; box-shadow: var(--shadow); }
.panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: .6rem; }
.panel-head h2, .panel-head h3 { margin: 0; font-size: 1rem; }

.field-label { display: block; margin: .8rem 0 .3rem; font-weight: 600; font-size: .85rem; }
.input { width: 100%; padding: .5rem .6rem; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); color: var(--text); font: inherit; }
.input-sm { width: auto; padding: .3rem .5rem; }
input[type=range] { width: 100%; accent-color: var(--accent); }
.hint, .empty { color: var(--muted); font-size: .85rem; margin: .3rem 0; }
.empty { padding: 2rem 0; text-align: center; }

.btn { padding: .5rem .9rem; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); font: inherit; cursor: pointer; }
.btn:hover { border-color: var(--accent); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
.link-btn { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; font: inherit; font-size: .85rem; }
.link-btn:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.pills { display: flex; flex-wrap: wrap; gap: .4rem; }
.pill { padding: .25rem .7rem; border: 1px solid var(--border); border-radius: 999px; background: var(--bg); color: var(--text); font: inherit; font-size: .85rem; cursor: pointer; }
.pill.is-active { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }

.collection { list-style: none; margin: .4rem 0 0; padding: 0; display: flex; flex-direction: column; gap: .4rem; max-height: 320px; overflow: auto; }
.collection li { display: flex; align-items: center; gap: .6rem; padding: .3rem; border: 1px solid var(--border); border-radius: 8px; }
.collection .dot { width: 28px; height: 28px; border-radius: 6px; border: 1px solid rgba(0,0,0,.2); flex: none; }
.collection .meta { flex: 1; min-width: 0; font-size: .8rem; }
.collection .meta strong, .collection .meta span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.collection .meta span { color: var(--muted); }
.icon-btn { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 1.1rem; line-height: 1; padding: .2rem .4rem; }
.icon-btn:hover { color: var(--danger); }

.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--border); margin: -.25rem 0 1rem; overflow-x: auto; }
.tab { padding: .6rem 1rem; border: 0; border-bottom: 3px solid transparent; background: none; color: var(--muted); font: inherit; cursor: pointer; white-space: nowrap; }
.tab.is-active { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }

.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: .9rem; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: .9rem; }
.card { position: relative; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--surface); cursor: pointer; text-align: left; padding: 0; font: inherit; color: inherit; }
.card:hover { box-shadow: var(--shadow); border-color: var(--accent); }
.card .sw { height: 90px; }
.card .body { padding: .55rem .7rem .7rem; font-size: .85rem; }
.card .code { font-weight: 700; }
.card .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card .sub { color: var(--muted); font-size: .78rem; }
.card .add { position: absolute; top: .4rem; right: .4rem; width: 28px; height: 28px; border-radius: 50%; border: 0; background: rgba(255,255,255,.92); color: #1d2330; font-size: 1.2rem; line-height: 1; cursor: pointer; box-shadow: var(--shadow); }
.card .add:hover { background: var(--accent); color: var(--accent-text); }

.base-picker { display: flex; align-items: center; gap: .6rem; margin: 1rem 0; flex-wrap: wrap; }
.base-picker input[type=color], .mixer input[type=color] { width: 44px; height: 36px; padding: 0; border: 1px solid var(--border); border-radius: 8px; background: none; cursor: pointer; }
.strip { display: flex; flex-wrap: wrap; gap: .5rem; }
.chip { position: relative; width: 92px; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--surface); }
.chip button.chip-sw { display: block; width: 100%; height: 56px; border: 0; cursor: pointer; }
.chip .chip-hex { padding: .25rem .4rem; font-size: .75rem; font-family: ui-monospace, Menlo, Consolas, monospace; text-align: center; }
.chip .chip-lbl { position: absolute; top: 3px; left: 5px; font-size: .65rem; font-weight: 700; }
.chip .chip-add { position: absolute; top: 3px; right: 3px; width: 20px; height: 20px; border-radius: 50%; border: 0; background: rgba(255,255,255,.9); color: #1d2330; cursor: pointer; line-height: 1; }
.harmony { margin-bottom: .9rem; }
.harmony h4 { margin: .6rem 0 .3rem; color: var(--text); }

.mixer { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1rem; align-items: start; margin: 1rem 0; }
@media (max-width: 700px) { .mixer { grid-template-columns: 1fr; } }
.mix-side { display: flex; flex-direction: column; gap: .5rem; }
.mix-center { padding-top: .2rem; }
.mix-swatch { height: 70px; border-radius: 8px; border: 1px solid var(--border); }
.mix-swatch-lg { width: 140px; height: 100px; flex: none; }
.mix-result { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; padding: 1rem; border: 1px solid var(--border); border-radius: var(--radius); }
.mix-result p { margin-bottom: .3rem; }
.mix-result span { color: var(--muted); margin-left: .4rem; }

.modal { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; padding: 1rem; background: rgba(10, 15, 25, .55); z-index: 50; }
.modal-box { position: relative; width: 100%; max-width: 460px; max-height: 92vh; overflow: auto; background: var(--surface); border-radius: 14px; padding: 1.25rem; box-shadow: 0 10px 40px rgba(0,0,0,.35); }
.modal-close { position: absolute; top: .5rem; right: .7rem; background: none; border: 0; font-size: 1.6rem; line-height: 1; color: var(--muted); cursor: pointer; }
.detail-swatch { height: 110px; border-radius: 10px; border: 1px solid var(--border); margin-bottom: .8rem; }
.detail-code { color: var(--muted); font-weight: 700; }
.modal-box h3 { margin: .1rem 0 .1rem; font-size: 1.3rem; }
.detail-system { color: var(--muted); margin-bottom: .6rem; }
.detail-values { display: grid; grid-template-columns: 60px 1fr; gap: .2rem .6rem; margin: 0 0 .5rem; }
.detail-values dt { color: var(--muted); font-weight: 600; }
.detail-values dd { margin: 0; font-family: ui-monospace, Menlo, Consolas, monospace; }
.equiv { list-style: none; padding: 0; margin: 0 0 1rem; display: flex; flex-direction: column; gap: .35rem; }
.equiv li { display: flex; align-items: center; gap: .6rem; font-size: .85rem; }
.equiv .dot { width: 22px; height: 22px; border-radius: 5px; border: 1px solid rgba(0,0,0,.2); flex: none; }
.equiv .tag { margin-left: auto; font-size: .72rem; color: var(--muted); }
.modal-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.export-options { display: flex; flex-direction: column; gap: .5rem; margin-top: .8rem; }
.export-opt { text-align: left; padding: .7rem .9rem; border: 1px solid var(--border); border-radius: 10px; background: var(--bg); color: var(--text); font: inherit; cursor: pointer; }
.export-opt:hover { border-color: var(--accent); }
.export-opt strong, .export-opt span { display: block; }
.export-opt span { color: var(--muted); font-size: .82rem; }
.png-preview { margin-top: 1rem; }
.png-preview canvas { max-width: 100%; border: 1px solid var(--border); border-radius: 8px; }

.toast { position: fixed; left: 50%; bottom: 1.5rem; transform: translateX(-50%); padding: .6rem 1.1rem; border-radius: 8px; background: var(--text); color: var(--bg); box-shadow: var(--shadow); z-index: 80; }
.toast.is-error { background: var(--danger); color: #fff; }
