/* ============================================================
   FAC — Ficha Automática
   Consumes shared tokens from assets/css/tokens.css (colors,
   spacing, radius, type scale, motion, z-index). This file owns
   layout + component styling specific to the character sheet.
   ============================================================ */

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: var(--fs-base)/1.5 var(--font-ui);
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; }
button, .file-button, .import-button, .avatar-upload, .mestre-button { cursor: pointer; }

/* ---------- Buttons ---------- */
button, .file-button, .import-button, .mestre-button, .manual-link {
  border: 0;
  border-radius: var(--r-sm);
  background: var(--panel2);
  color: var(--text);
  font-weight: 700;
  padding: var(--sp-2) var(--sp-4);
  transition: background var(--dur-fast) var(--ease-out-expo), transform var(--dur-fast) var(--ease-out-expo), filter var(--dur-fast) var(--ease-out-expo);
}
button:hover, .file-button:hover, .import-button:hover, .mestre-button:hover, .manual-link:hover {
  background: var(--surface-3);
  transform: translateY(-1px);
}
button:active, .file-button:active, .import-button:active, .mestre-button:active {
  transform: translateY(0);
}
button:disabled { opacity: .35; cursor: not-allowed; transform: none; }
.hidden { display: none !important; }

.secondary { background: var(--panel2); color: var(--text); }
.danger { background: var(--bad); color: var(--bg); }
.magic-button { background: var(--arcane2); color: var(--text); }
.mestre-button {
  display: inline-flex; align-items: center; justify-content: center;
  text-decoration: none; background: var(--bronze2); color: var(--text);
}
.manual-link {
  display: inline-flex; align-items: center; justify-content: center;
  margin-top: var(--sp-2); text-decoration: none; background: var(--red); color: var(--bg);
}

/* Primary action = whichever button carries page intent; export/submit buttons read
   as primary via the red accent so the eye lands on the one action that matters. */
#exportButton, button[type="submit"] { background: var(--red); color: #fff; }
#exportButton:hover, button[type="submit"]:hover { background: var(--red2); }

/* ---------- Inputs ---------- */
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--panel2);
  color: var(--text);
  padding: var(--sp-2) var(--sp-3);
  transition: border-color var(--dur-fast) var(--ease-out-expo);
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--red);
  box-shadow: 0 0 0 3px color-mix(in oklch, var(--red) 25%, transparent);
}
textarea { min-height: 110px; resize: vertical; }
.invalid { border-color: var(--bad) !important; box-shadow: 0 0 0 1px var(--bad); }

/* ---------- Profile screen ---------- */
.profile-screen {
  min-height: 100vh;
  background: radial-gradient(circle at 50% 15%, color-mix(in oklch, var(--red) 22%, var(--bg)) 0, var(--bg) 45%);
}
.profile-header { height: 86px; display: flex; align-items: center; justify-content: space-between; padding: 0 5vw; }
.brand { font-family: var(--font-display); font-size: 34px; font-weight: 700; letter-spacing: -0.02em; color: var(--red); }
.version { color: var(--muted); font-size: var(--fs-sm); }
.profile-main { max-width: 1200px; margin: 5vh auto; padding: var(--sp-5); text-align: center; }
.profile-main h1 { font-family: var(--font-display); font-size: clamp(2.1rem, 5vw, 3.6rem); margin: 0; text-wrap: balance; }
.profile-main > p { color: var(--muted); font-size: var(--fs-md); }
.profile-list { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--sp-6); margin: var(--sp-7) 0; }
.profile-card { width: 170px; background: none; color: var(--text); padding: var(--sp-1); }
.profile-card:hover { filter: none; }
.profile-avatar {
  width: 150px; height: 150px; margin: auto; background: var(--panel2) center/cover;
  border-radius: var(--r-md); display: grid; place-items: center; font-size: 52px; color: var(--muted);
  border: 3px solid transparent; transition: border-color var(--dur-base) var(--ease-out-expo);
}
.profile-card:hover .profile-avatar { border-color: var(--text); }
.profile-card strong { display: block; margin-top: var(--sp-2); font-size: var(--fs-md); }
.profile-card small { color: var(--muted); }
.new-profile { max-width: 620px; margin: var(--sp-6) auto; display: grid; grid-template-columns: 1fr auto auto; gap: var(--sp-2); }

/* ---------- Topbar / nav ---------- */
.topbar {
  position: sticky; top: 0; z-index: var(--z-sticky); min-height: 70px;
  background: linear-gradient(var(--bg), color-mix(in oklch, var(--bg) 96%, transparent));
  backdrop-filter: blur(8px);
  display: flex; align-items: center; gap: var(--sp-4); padding: var(--sp-2) var(--sp-5);
  border-bottom: 1px solid var(--line);
}
.profile-chip { display: flex; align-items: center; gap: var(--sp-2); background: transparent; color: var(--text); text-align: left; padding: 4px; }
.profile-chip small { display: block; color: var(--muted); }
.mini-avatar { width: 42px; height: 42px; border-radius: var(--r-sm); background: var(--panel2) center/cover; display: grid; place-items: center; }

.tabs { display: flex; gap: 2px; flex: 1; align-items: center; overflow-x: auto; }
.tab {
  position: relative; white-space: nowrap; background: transparent; color: var(--muted);
  padding: var(--sp-2) var(--sp-4) var(--sp-2) 38px; border-radius: var(--r-sm);
  font-weight: 600; font-size: var(--fs-sm); border-bottom: 2px solid transparent;
  transition: color var(--dur-fast) var(--ease-out-expo), background var(--dur-fast) var(--ease-out-expo), border-color var(--dur-fast) var(--ease-out-expo);
}
.tab::before {
  content: ""; position: absolute; left: 14px; top: 50%; translate: 0 -50%;
  width: 16px; height: 16px; background: currentColor;
  -webkit-mask: var(--tab-icon) center / contain no-repeat;
  mask: var(--tab-icon) center / contain no-repeat;
  opacity: .65; transition: opacity var(--dur-fast) var(--ease-out-expo);
}
.tab:hover { color: var(--text); background: var(--panel2); }
.tab.active { color: var(--text); background: var(--panel2); border-bottom-color: var(--gold); }
.tab.active::before { opacity: 1; }
.tab[data-tab="ficha"]      { --tab-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='7' r='3.4'/%3E%3Cpath d='M5 20a7 7 0 0 1 14 0'/%3E%3C/svg%3E"); }
.tab[data-tab="construcao"] { --tab-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='4' y='13' width='7' height='7'/%3E%3Crect x='13' y='13' width='7' height='7'/%3E%3Crect x='8.5' y='4' width='7' height='7'/%3E%3C/svg%3E"); }
.tab[data-tab="combate"]    { --tab-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cline x1='4' y1='4' x2='20' y2='20'/%3E%3Cline x1='20' y1='4' x2='4' y2='20'/%3E%3Ccircle cx='12' cy='12' r='2.2'/%3E%3C/svg%3E"); }
.tab[data-tab="inventario"] { --tab-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='5' y='8' width='14' height='13' rx='2'/%3E%3Cpath d='M9 8V6a3 3 0 0 1 6 0v2'/%3E%3C/svg%3E"); }
.tab[data-tab="grimorio"]   { --tab-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='4' y='5' width='16' height='14' rx='1'/%3E%3Cline x1='12' y1='5' x2='12' y2='19'/%3E%3C/svg%3E"); }
.tab[data-tab="notas"]      { --tab-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cline x1='6' y1='7' x2='18' y2='7'/%3E%3Cline x1='6' y1='12' x2='18' y2='12'/%3E%3Cline x1='6' y1='17' x2='14' y2='17'/%3E%3C/svg%3E"); }

.top-actions { display: flex; gap: var(--sp-2); }

.sub-tabs { display: flex; gap: 0; border-bottom: 1px solid var(--line); margin-bottom: var(--sp-5); }
.sub-tab {
  background: transparent; color: var(--muted); padding: var(--sp-2) var(--sp-5); font-size: var(--fs-sm);
  font-weight: 600; border-radius: var(--r-sm) var(--r-sm) 0 0; border-bottom: 2px solid transparent;
  margin-bottom: -1px; transition: color var(--dur-fast) var(--ease-out-expo), border-color var(--dur-fast) var(--ease-out-expo), background var(--dur-fast) var(--ease-out-expo);
}
.sub-tab:hover { color: var(--text); background: var(--panel); }
.sub-tab.active { color: var(--text); border-bottom-color: var(--gold); }
.sub-panel { display: none; }
.sub-panel.active { display: block; animation: panel-in var(--dur-base) var(--ease-out-expo); }

@keyframes panel-in { from { opacity: 0; translate: 0 4px; } to { opacity: 1; translate: 0 0; } }

/* ---------- Workspace / sidebar ---------- */
.workspace { max-width: 1600px; margin: auto; display: grid; grid-template-columns: 300px 1fr; gap: var(--sp-5); padding: var(--sp-5); }
.sidebar { position: sticky; top: 92px; align-self: start; display: grid; gap: var(--sp-3); }

.hero-card, .card, .validation-panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-lg); padding: var(--sp-4);
}
.hero-card { text-align: center; }
.hero-avatar {
  width: 110px; height: 110px; border-radius: var(--r-md); background: var(--panel2) center/cover;
  margin: auto; display: grid; place-items: center; font-size: 38px;
}
.avatar-upload { display: block; color: var(--muted); font-size: var(--fs-xs); margin: var(--sp-2); }
.hero-card h2 { font-family: var(--font-display); margin: var(--sp-2) 0; font-size: var(--fs-lg); }
.level-control { display: grid; grid-template-columns: 38px 1fr 38px; gap: var(--sp-1); align-items: end; }
.level-control label { text-align: left; color: var(--muted); font-size: var(--fs-xs); }
.level-control input { text-align: center; padding: var(--sp-2); }

/* Hero stat grid — HP/MP/AD/RM/etc read at a glance, the sheet's central hierarchy */
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-2); }
.stat {
  background: var(--panel2); border: 1px solid var(--line); border-radius: var(--r-md); padding: var(--sp-3);
  transition: border-color var(--dur-fast) var(--ease-out-expo), transform var(--dur-fast) var(--ease-out-expo);
}
.stat:hover { border-color: var(--line-strong); transform: translateY(-1px); }
.stat span { display: block; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .04em; }
.stat strong { display: block; font-family: var(--font-display); font-size: var(--fs-xl); font-weight: 600; margin-top: 2px; }
.stat-grid .stat:nth-child(1) strong { color: var(--red); }
.stat-grid .stat:nth-child(2) strong { color: var(--arcane); }
.stat-grid .stat:nth-child(8) strong { color: var(--gold); }

.validation-panel { font-size: var(--fs-sm); }
.validation-panel h3 { margin: 0 0 var(--sp-2); font-family: var(--font-display); font-weight: 600; }
.validation-item { padding: var(--sp-2) 0; border-top: 1px solid var(--line); color: var(--muted); }
.validation-item.ok { color: var(--ok); }
.validation-item.bad { color: var(--bad); }

.content { min-width: 0; }
.panel { display: none; }
.panel.active { display: block; animation: panel-in var(--dur-base) var(--ease-out-expo); }
.panel-title { display: flex; justify-content: space-between; align-items: end; gap: var(--sp-5); margin-bottom: var(--sp-4); }
.panel-title h1 { font-family: var(--font-display); margin: 0; font-size: var(--fs-2xl); text-wrap: balance; }
.panel-title p { margin: var(--sp-1) 0; color: var(--muted); }

.grid { display: grid; gap: var(--sp-3); }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.card { transition: border-color var(--dur-fast) var(--ease-out-expo); }
.card h2, .card h3 { margin-top: 0; font-family: var(--font-display); font-weight: 600; }
.field { display: grid; gap: 5px; margin-bottom: var(--sp-2); }
.field label, .field-label { color: var(--muted); font-size: var(--fs-xs); font-weight: 700; }

.inline { display: flex; gap: var(--sp-2); align-items: center; }
.resource-bar { height: 8px; background: var(--line); border-radius: var(--r-pill); overflow: hidden; }
.resource-bar i { display: block; height: 100%; background: var(--red); transition: width var(--dur-slow) var(--ease-out-expo); }
.resource-bar-hp i { background: var(--red); }
.resource-bar-mp i { background: var(--arcane); }

.attribute-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--sp-2); }
.attribute { background: var(--panel2); border: 1px solid var(--line); border-radius: var(--r-md); padding: var(--sp-3); }
.attribute-head { display: flex; justify-content: space-between; gap: var(--sp-2); }
.stepper { display: grid; grid-template-columns: 32px 40px 32px; gap: var(--sp-1); align-items: center; margin-top: var(--sp-2); }
.stepper button { padding: var(--sp-1); }
.stepper strong { text-align: center; font-family: var(--font-display); font-size: var(--fs-md); }

.budget { display: flex; gap: var(--sp-2); flex-wrap: wrap; }
.badge { border-radius: var(--r-pill); background: var(--panel2); padding: 5px var(--sp-2); color: var(--text); font-size: var(--fs-xs); }
.badge.ok { background: color-mix(in oklch, var(--ok) 22%, var(--bg)); color: var(--ok); }
.badge.bad { background: color-mix(in oklch, var(--bad) 22%, var(--bg)); color: var(--bad); }

.skill-toolbar, .market-toolbar { display: grid; grid-template-columns: 1fr 220px auto; gap: var(--sp-2); margin-bottom: var(--sp-4); }
.skill-groups { display: grid; gap: var(--sp-4); }
.skill-attribute summary { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); cursor: pointer; }
.skill-attribute summary h2 { margin: 0; }
.skill-row {
  display: grid; grid-template-columns: minmax(170px, 1fr) 118px 150px minmax(210px, 1.1fr);
  gap: var(--sp-2); align-items: start; padding: var(--sp-2); border-top: 1px solid var(--line);
}
.skill-row:first-child { border-top: 0; }
.skill-stepper { margin-top: 0; }
.skill-name strong { display: block; }
.skill-name small { color: var(--muted); }

.skill-effects summary, .trained-skill summary, .faith-list summary { cursor: pointer; color: var(--text); font-weight: 700; }
.skill-effects p, .trained-skill p, .faith-list p { margin: var(--sp-2) 0; color: var(--muted); }

.prestige-grid, .condition-grid, .market-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: var(--sp-3); }
.select-card {
  background: var(--panel2); border: 1px solid var(--line); border-radius: var(--r-md); padding: var(--sp-3);
  transition: border-color var(--dur-fast) var(--ease-out-expo);
}
.select-card.selected { border-color: var(--gold); box-shadow: inset 0 0 0 1px var(--gold); }
.select-card h3 { margin: 0 0 5px; font-family: var(--font-display); }
.select-card p { color: var(--muted); min-height: 62px; }
.condition-card { display: grid; grid-template-columns: 1fr 112px; gap: var(--sp-2); align-items: center; }
.condition-card.active { border-color: var(--warn); }
.condition-card .stepper { margin-top: 0; }

.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: var(--sp-2); border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-size: var(--fs-xs); }

.money { font-family: var(--font-display); font-size: var(--fs-xl); color: var(--gold); }
.market-card { display: flex; flex-direction: column; }
.market-card .buy { margin-top: auto; background: var(--red); color: #fff; }
.market-discount { display: flex; align-items: end; gap: var(--sp-3); flex-wrap: wrap; margin-bottom: var(--sp-4); }
.market-discount .field { width: 190px; margin: 0; }

.lore-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-4); }
.lore-grid .wide { grid-column: 1 / -1; }
.rule-note {
  border: 1px solid var(--line); border-radius: var(--r-md);
  background: color-mix(in oklch, var(--arcane) 8%, var(--panel));
  padding: var(--sp-2) var(--sp-3); margin: var(--sp-2) 0;
}
.rule-note.warn { background: color-mix(in oklch, var(--warn) 10%, var(--panel)); }

.compact-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: var(--sp-2); }
.roll-chip {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2);
  background: var(--panel2); color: var(--text); border: 1px solid var(--line); border-radius: var(--r-sm);
}
.roll-chip strong { color: var(--gold); }

.trained-skill { border-top: 1px solid var(--line); padding: var(--sp-2) 0; }
.trained-skill summary { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); }
.trained-skill summary button, .item-action button { padding: 6px 9px; }

.inventory-line, .roll-log { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); border-top: 1px solid var(--line); padding: var(--sp-2) 0; }
.inventory-line small, .roll-log small { color: var(--muted); }
.roll-log { display: grid; align-items: start; }
.related-skills { margin-top: var(--sp-2); }
.related-skills p { margin: 6px 0; color: var(--muted); font-size: var(--fs-xs); }
.item-action { margin-top: 6px; justify-content: flex-start; flex-wrap: wrap; }

.faith-box { display: grid; gap: var(--sp-2); margin: var(--sp-2) 0; }
.faith-list { max-height: 320px; overflow: auto; border: 1px solid var(--line); border-radius: var(--r-sm); padding: var(--sp-2); }
.faith-list h4 { margin: var(--sp-2) 0 4px; }
.faith-choice-grid { display: grid; gap: var(--sp-2); }
.faith-choice {
  display: grid; grid-template-columns: auto 1fr; gap: var(--sp-2); align-items: start;
  border: 1px solid var(--line); border-radius: var(--r-sm); padding: var(--sp-2); background: var(--panel2);
}
.faith-choice.selected { border-color: var(--gold); }
.faith-choice input { width: auto; margin-top: 3px; }
.faith-choice small, .faith-passive small { display: block; color: var(--muted); margin-top: 5px; }

.prestige-summary { display: grid; gap: var(--sp-2); }
.prestige-summary p { margin: 0; color: var(--muted); }
.prestige-summary small { display: block; color: var(--muted); }
.prestige-summary-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); }
.prestige-meter { height: 7px; background: var(--line); border-radius: var(--r-pill); overflow: hidden; }
.prestige-meter i { display: block; height: 100%; background: var(--gold); transition: width var(--dur-slow) var(--ease-out-expo); }
.prestige-tools { display: grid; gap: var(--sp-2); margin-top: var(--sp-3); }
.prestige-notes { display: grid; gap: var(--sp-2); }
.prestige-notes textarea { min-height: 72px; }
.academic-essence-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: var(--sp-2); }
.academic-group { max-height: none; }
.item-defense { margin-top: 5px; }
.market-extra { display: grid; gap: var(--sp-2); margin: var(--sp-2) 0; }
.market-extra .field { margin: 0; }
.companion-sheet { border-color: var(--gold); display: grid; gap: 6px; }
.companion-sheet p { margin: 0; color: var(--text); }

/* ---------- Grimoire (native) ---------- */
.grimoire-native { display: grid; gap: var(--sp-4); }
.grimoire-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--sp-2); }
.grimoire-note { color: var(--muted); margin-bottom: 0; }
.grimoire-palette { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: var(--sp-3); margin: var(--sp-2) 0 var(--sp-4); }
.grimoire-group { border: 1px solid var(--line); border-radius: var(--r-md); background: var(--panel2); padding: var(--sp-2); }
.grimoire-group h3 { margin: 0 0 var(--sp-2); color: var(--hemis-accent, var(--arcane)); font-family: var(--font-display); }
.grimoire-essence-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(86px, 1fr)); gap: 7px; }
.grimoire-essence { display: grid; gap: 2px; min-height: 58px; padding: var(--sp-2); background: var(--panel); color: var(--muted); border: 1px solid var(--line); border-radius: var(--r-sm); }
.grimoire-essence.available {
  color: var(--text);
  background: color-mix(in oklch, var(--ess-accent, var(--arcane)) 14%, var(--panel2));
  border-color: color-mix(in oklch, var(--ess-accent, var(--arcane)) 45%, var(--line-strong));
}
.grimoire-essence strong { color: var(--ess-accent, var(--arcane)); }
.grimoire-essence small { font-size: 11px; color: var(--muted); }
.grimoire-draft {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3);
  border: 1px solid var(--line); border-radius: var(--r-md); background: var(--panel2); padding: var(--sp-3); margin: var(--sp-2) 0;
}
.grimoire-draft strong { font-family: var(--font-display); font-size: var(--fs-xl); color: var(--arcane); }
.chip-button { border: 0; padding: 5px 9px; color: var(--ok); background: transparent; }
.spell-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: var(--sp-3); }
.spell-card p { min-height: auto; }
.spell-head { display: flex; align-items: start; justify-content: space-between; gap: var(--sp-2); }
.spell-head h3 { margin: 0; }

.empty { padding: var(--sp-7) var(--sp-4); text-align: center; color: var(--muted); }

#linkFileButton[data-linked="1"] {
  background: color-mix(in oklch, var(--arcane) 30%, var(--bg)); color: var(--arcane);
  max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.78rem;
}

.profile-list { display: block !important; margin: var(--sp-7) 0; }
.profile-cards-grid { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--sp-6); }
.profile-manage-bar { display: flex; gap: var(--sp-2); justify-content: center; margin-bottom: var(--sp-5); }
label.profile-card { display: inline-flex; flex-direction: column; align-items: center; position: relative; cursor: pointer; padding: var(--sp-1); width: 170px; background: none; color: var(--text); }
label.profile-card:hover .profile-avatar { border-color: var(--text); }
label.profile-card.selected .profile-avatar { border-color: var(--red); box-shadow: 0 0 0 2px var(--red); }
.profile-select { position: absolute; top: 8px; right: 8px; width: 18px; height: 18px; cursor: pointer; accent-color: var(--red); z-index: 1; }

.tooltip {
  position: fixed; z-index: var(--z-tooltip); max-width: 340px; padding: var(--sp-2) var(--sp-3);
  border: 1px solid var(--line-strong); border-radius: var(--r-sm); background: var(--text); color: var(--bg);
  box-shadow: 0 12px 35px rgba(0, 0, 0, .6); pointer-events: none; opacity: 0; transform: translateY(4px);
  transition: opacity var(--dur-fast) var(--ease-out-expo), transform var(--dur-fast) var(--ease-out-expo);
}
.tooltip.visible { opacity: 1; transform: none; }
.toast {
  position: fixed; right: 20px; bottom: 20px; z-index: var(--z-toast); background: var(--text); color: var(--bg);
  border-radius: var(--r-sm); padding: var(--sp-3) var(--sp-4); box-shadow: 0 8px 25px rgba(0, 0, 0, .6);
  opacity: 0; transform: translateY(15px); transition: opacity var(--dur-base) var(--ease-out-expo), transform var(--dur-base) var(--ease-out-expo);
  pointer-events: none;
}
.toast.show { opacity: 1; transform: none; }

/* ---------- Responsive ---------- */
@media (max-width: 1080px) {
  .workspace { grid-template-columns: 1fr; }
  .sidebar { position: static; grid-template-columns: 240px 1fr 1fr; }
  .topbar { flex-wrap: wrap; }
  .tabs { order: 3; width: 100%; }
  .attribute-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 600px) {
  .profile-header { padding: 15px; }
  .version { display: none; }
  .new-profile { grid-template-columns: 1fr; }
  .workspace { padding: var(--sp-2); }
  .sidebar { grid-template-columns: 1fr; }
  .grid.two, .grid.three, .lore-grid { grid-template-columns: 1fr; }
  .lore-grid .wide { grid-column: auto; }
  .attribute-grid { grid-template-columns: 1fr; }
  .skill-toolbar, .market-toolbar { grid-template-columns: 1fr; }
  .skill-row { grid-template-columns: 1fr 118px; }
  .skill-row .skill-effects { grid-column: 1 / -1; }
  .skill-row .skill-cost { display: none; }
  .top-actions { width: 100%; }
  .top-actions > * { flex: 1; }
  .profile-list { gap: var(--sp-3); }
  .profile-card { width: 135px; }
  .profile-avatar { width: 120px; height: 120px; }
  .grimoire-stats { grid-template-columns: 1fr 1fr; }
  .grimoire-draft { align-items: flex-start; flex-direction: column; }
  .tab { padding-left: 34px; }
}
