:root {
  --bg: #f3f1f1;
  --surface: #ffffff;
  --surface-muted: #f7f6f6;
  --border: #e5e2e2;
  --text: #26262b;
  --muted: #77737c;
  --purple: #8b4eef;
  --purple-soft: #f1ebff;
  --teal: #237d78;
  --shadow: 0 8px 28px rgba(27, 24, 29, 0.12);
}

* { box-sizing: border-box; }
body { margin: 0; overflow: hidden; color: var(--text); font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif; letter-spacing: 0; }
button, input, select { font: inherit; letter-spacing: 0; }
button { color: inherit; cursor: pointer; }
.hidden { display: none !important; }

.app-shell { width: 100vw; height: 100vh; position: relative; background: var(--bg); }
.canvas { width: 100%; height: 100%; position: relative; overflow: hidden; background-color: var(--bg); background-image: radial-gradient(#d9d6d6 1.1px, transparent 1.1px); background-size: 20px 20px; }
.project-switcher { position: absolute; top: 20px; left: 17px; height: 40px; display: flex; align-items: center; z-index: 6; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 2px 8px rgba(30, 27, 31, .06); overflow: hidden; }
.project-switcher button { height: 100%; border: 0; background: transparent; padding: 0 13px; }
.brand-button { display: flex; align-items: center; gap: 4px; padding: 0 9px !important; }
.brand-mark { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 8px 3px 8px 3px; color: white; background: linear-gradient(135deg, #8b4eef 0 52%, #28a6a0 52%); font-weight: 800; }
.brand-mark.small { width: 22px; height: 22px; font-size: 12px; }
.chevron, .project-switcher span { color: var(--muted); }
.project-name { max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; border-left: 1px solid var(--border) !important; border-right: 1px solid var(--border) !important; }

.empty-canvas { position: absolute; left: 50%; top: 50%; width: min(1120px, calc(100vw - 110px)); transform: translate(-50%, -45%); text-align: center; }
.empty-canvas > strong { display: block; margin-bottom: 32px; font-size: 18px; }
.starter-grid { display: grid; grid-template-columns: repeat(4, minmax(180px, 1fr)); gap: 24px; }
.starter-grid button { position: relative; height: 105px; display: grid; grid-template-columns: auto 1fr; grid-template-rows: 42px 1fr; align-items: center; gap: 0 11px; padding: 0 18px; overflow: hidden; border: 1px solid rgba(226, 223, 225, .72); border-radius: 18px; background: rgba(255, 255, 255, .94); box-shadow: 0 4px 16px rgba(37, 33, 40, .05); text-align: left; font-weight: 650; }
.starter-grid button::after { content: ""; position: absolute; inset: 52px 0 0; background: linear-gradient(115deg, #ede8e7, #d4ceca 52%, #eeeae8); opacity: .9; }
.starter-grid button:hover { border-color: #cdc4d4; box-shadow: 0 8px 22px rgba(37, 33, 40, .09); }
.starter-icon { position: relative; z-index: 1; font-size: 19px; }
.starter-grid button > span:nth-child(2) { position: relative; z-index: 1; white-space: nowrap; }
.starter-grid b { position: absolute; z-index: 2; right: 12px; bottom: 12px; width: 36px; height: 36px; display: grid; place-items: center; border-radius: 50%; color: white; background: #252428; font-size: 20px; }

.asset-toggle { position: absolute; left: 20px; bottom: 22px; display: flex; gap: 8px; align-items: center; border: 0; background: transparent; color: #4d4a50; }
.canvas-status { position: absolute; left: 230px; bottom: 24px; color: #56525a; }
.canvas-toolbar { position: absolute; left: 50%; bottom: 18px; z-index: 13; transform: translateX(-50%); height: 52px; display: flex; gap: 5px; align-items: center; padding: 6px 9px; background: var(--surface); border: 1px solid #dfdcdc; border-radius: 17px; box-shadow: 0 4px 14px rgba(30, 27, 31, .13); }
.canvas.sidebar-open .canvas-toolbar { left: calc(50% + 164px); }
.canvas-toolbar button { width: 38px; height: 38px; border: 0; border-radius: 9px; background: transparent; font-size: 18px; }
.canvas-toolbar button:hover { background: var(--surface-muted); }
.canvas-toolbar .primary-tool { border-radius: 50%; color: white; background: var(--purple); font-size: 30px; line-height: 1; }
.toolbar-divider { width: 1px; height: 27px; background: var(--border); margin: 0 2px; }

.asset-sidebar { position: absolute; inset: 0 auto 0 0; z-index: 12; width: 328px; background: var(--surface); border-right: 1px solid var(--border); box-shadow: 6px 0 24px rgba(31, 29, 32, .08); }
.sidebar-header { height: 67px; display: flex; align-items: center; justify-content: space-between; padding: 0 15px; border-bottom: 1px solid var(--border); }
.sidebar-project { display: flex; align-items: center; gap: 9px; min-width: 0; }
.sidebar-project strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-header button { border: 0; background: transparent; font-size: 27px; color: var(--muted); }
.sidebar-tabs { height: 52px; display: grid; grid-template-columns: 1fr 1fr; padding: 8px 12px; border-bottom: 1px solid var(--border); }
.sidebar-tabs button { border: 0; border-radius: 6px; background: transparent; color: var(--muted); }
.sidebar-tabs button.active { color: #5530b4; background: var(--purple-soft); font-weight: 650; }
.resource-panel { padding: 13px 12px; }
.resource-tools { display: grid; grid-template-columns: 1fr 38px auto; gap: 7px; }
.search-field { height: 38px; display: flex; align-items: center; gap: 7px; padding: 0 10px; background: var(--surface-muted); border: 1px solid transparent; border-radius: 6px; }
.search-field:focus-within { border-color: #cdbaf4; background: white; }
.search-field input { width: 100%; border: 0; outline: 0; background: transparent; }
.icon-button, .upload-button { height: 38px; border: 1px solid var(--border); border-radius: 6px; background: white; }
.icon-button { position: relative; }
.filter-count { position: absolute; right: -5px; top: -5px; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px; color: white; background: var(--purple); font-size: 10px; line-height: 17px; }
.upload-button { padding: 0 11px; }
.active-filters { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 9px; }
.active-filters button { border: 0; border-radius: 4px; padding: 5px 7px; color: #6038c2; background: var(--purple-soft); font-size: 11px; }
.asset-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-top: 12px; max-height: calc(100vh - 205px); overflow: auto; }
.asset-card { position: relative; min-width: 0; border: 1px solid var(--border); border-radius: 7px; background: white; overflow: hidden; }
.asset-card:hover { border-color: #c9b5f3; box-shadow: 0 3px 12px rgba(65, 42, 103, .1); }
.asset-thumb { width: 100%; aspect-ratio: 1.3; object-fit: cover; display: block; background: #ece9e9; }
.asset-info { padding: 8px; }
.asset-info strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.asset-info span { color: var(--muted); font-size: 10px; }
.asset-menu-button { position: absolute; right: 6px; top: 6px; width: 26px; height: 26px; border: 0; border-radius: 7px; background: rgba(255,255,255,.9); }
.empty-state { height: 280px; display: grid; place-items: center; align-content: center; gap: 10px; color: #96919a; }
.empty-state span { font-size: 50px; }

.filter-popover { position: absolute; left: 274px; top: 128px; z-index: 22; width: 350px; padding: 17px; background: var(--surface); border: 1px solid var(--border); border-radius: 9px; box-shadow: var(--shadow); }
.filter-popover header, .filter-popover footer { display: flex; align-items: center; justify-content: space-between; }
.filter-popover header button { border: 0; background: transparent; font-size: 20px; }
.tag-options { display: flex; gap: 8px; flex-wrap: wrap; margin: 18px 0 27px; }
.tag-options button { padding: 8px 12px; border: 1px solid #d6d1d7; border-radius: 6px; background: white; }
.tag-options button.selected { color: #5c34bd; border-color: #bda7ef; background: var(--purple-soft); }
.text-button { border: 0; background: transparent; color: var(--muted); }
.purple-button { border: 0; border-radius: 6px; padding: 9px 15px; color: white; background: var(--purple); }

.add-menu { position: absolute; left: calc(50% - 260px); bottom: 77px; z-index: 18; width: 242px; max-height: calc(100vh - 96px); padding: 10px; overflow-y: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); }
.add-menu h3 { margin: 4px 8px 9px; font-size: 14px; }
.add-menu > button { display: grid; grid-template-columns: 34px 1fr auto; align-items: center; gap: 10px; width: 100%; min-height: 43px; padding: 4px 8px; border: 0; border-radius: 6px; background: transparent; text-align: left; }
.add-menu button:hover { background: var(--surface-muted); }
.menu-icon { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 9px; color: var(--purple); background: var(--purple-soft); font-size: 15px; font-weight: 650; }
.menu-arrow { color: var(--muted); font-size: 22px; line-height: 1; }
.creative-library-submenu { position: fixed; z-index: 24; width: 164px; padding: 8px; background: var(--surface); border: 1px solid var(--border); border-radius: 9px; box-shadow: var(--shadow); }
.creative-library-submenu.align-left { transform-origin: right top; }
.creative-library-submenu button { display: block; width: 100%; height: 44px; padding: 0 14px; border: 0; border-radius: 6px; background: transparent; text-align: left; }
.creative-library-submenu button:hover { background: var(--surface-muted); }

.modal-backdrop { position: fixed; inset: 0; z-index: 40; padding: 42px 62px; background: rgba(31, 29, 32, .42); backdrop-filter: blur(2px); }
.modal-backdrop.expanded-backdrop { padding: 0; }
.creative-modal { height: 100%; display: grid; grid-template-rows: 72px 58px 1fr; background: white; border: 1px solid #dad7d7; border-radius: 12px; box-shadow: 0 18px 55px rgba(25,22,27,.22); overflow: hidden; }
.creative-modal.expanded { border-radius: 0; }
.creative-header { display: flex; gap: 12px; align-items: center; padding: 13px 18px; border-bottom: 1px solid var(--border); }
.creative-tabs { display: flex; padding: 3px; background: #f2f0f0; border-radius: 7px; }
.creative-tabs button { border: 0; padding: 9px 13px; border-radius: 5px; background: transparent; color: var(--muted); }
.creative-tabs button.active { color: #5933ba; background: white; box-shadow: 0 1px 4px rgba(30,27,31,.09); }
.creative-search { width: min(430px, 38vw); display: flex; gap: 8px; align-items: center; padding: 10px 12px; background: var(--surface-muted); border-radius: 6px; }
.creative-search input { flex: 1; border: 0; outline: 0; background: transparent; }
.creative-header > button { margin-left: auto; width: 36px; height: 36px; border: 0; background: transparent; font-size: 20px; }
.creative-header > button + button { margin-left: 0; }
.creative-filters { display: flex; align-items: center; gap: 12px; padding: 10px 18px; border-bottom: 1px solid var(--border); }
.category-tabs { display: flex; gap: 6px; overflow: auto; flex: 1; }
.category-tabs button { flex: 0 0 auto; border: 0; border-radius: 5px; padding: 8px 10px; background: transparent; color: var(--muted); }
.category-tabs button.active { color: #5933ba; background: var(--purple-soft); }
.commercial-check { white-space: nowrap; color: var(--muted); font-size: 12px; }
.creative-filters select { padding: 8px 28px 8px 10px; border: 1px solid var(--border); border-radius: 6px; background: white; }
.creative-grid { display: grid; grid-template-columns: repeat(5, minmax(150px, 1fr)); gap: 17px; padding: 18px; overflow: auto; align-content: start; }
.creative-card { position: relative; min-width: 0; border-radius: 8px; }
.creative-card.selected .creative-thumb { box-shadow: 0 0 0 3px var(--purple); }
.creative-thumb { width: 100%; aspect-ratio: .82; display: block; object-fit: cover; border-radius: 8px; background: #e8e5e5; }
.creative-card-menu { position: absolute; left: 8px; top: 8px; width: 29px; height: 29px; border: 0; border-radius: 8px; background: rgba(255,255,255,.86); }
.creative-card h4 { margin: 9px 0 4px; font-size: 13px; }
.creative-meta { display: flex; justify-content: space-between; color: var(--muted); font-size: 10px; }
.commercial-badge { position: absolute; right: 7px; bottom: 50px; padding: 4px 6px; border-radius: 4px; color: white; background: rgba(35,125,120,.86); font-size: 9px; }
.creative-empty { display: grid; place-items: center; color: var(--muted); }
.card-menu { position: fixed; z-index: 60; width: 145px; padding: 6px; background: white; border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow); }
.card-menu button { width: 100%; border: 0; background: transparent; padding: 9px; text-align: left; border-radius: 5px; }
.card-menu button:hover { background: var(--surface-muted); }
.toast { position: fixed; left: 50%; bottom: 30px; z-index: 80; transform: translateX(-50%); padding: 10px 14px; border-radius: 7px; color: white; background: #2e2c31; box-shadow: var(--shadow); font-size: 12px; }

@media (max-width: 980px) {
  .empty-canvas { width: min(640px, calc(100vw - 70px)); }
  .starter-grid { grid-template-columns: repeat(2, minmax(180px, 1fr)); }
  .modal-backdrop { padding: 20px; }
  .creative-modal { grid-template-rows: auto 58px 1fr; }
  .creative-grid { grid-template-columns: repeat(3, minmax(130px, 1fr)); }
  .creative-header { position: relative; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 10px; height: auto; padding: 12px 90px 12px 18px; }
  .creative-tabs button { padding: 7px 9px; }
  .creative-search { grid-column: 1 / -1; width: 100%; order: initial; }
  .creative-header > button { position: absolute; top: 13px; margin: 0; }
  #modalExpand { right: 50px; }
  #modalClose { right: 12px; }
  .creative-filters { overflow: hidden; }
  .category-tabs { min-width: 0; }
}
