@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@400;500;600&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@400;600&family=Playfair+Display:ital,wght@0,400;0,600;1,400&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

#awsheet-app {
  --bg-body: #0d0d0d;
  --bg-sheet: rgba(23, 23, 23, 0.3);
  --border-color: #2e2e2e;
  --text-main: #e0e0e0;
  --text-muted: #888888;
  --accent-blue: #3b82f6;
  --accent-purple: #8b5cf6;
  --accent-red: #ef4444;
  --font-main: 'Inter', sans-serif;
  
  background-color: transparent;
  color: var(--text-main);
  font-family: var(--font-main);
  line-height: 1.5;
  min-height: 100vh;
}

/* Hide number input spinners globally for the sheet */
#awsheet-app input[type="number"]::-webkit-outer-spin-button,
#awsheet-app input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
#awsheet-app input[type="number"] {
  -moz-appearance: textfield;
}

#awsheet-app .awsheet-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 40px 20px;
}

#awsheet-app .awsheet {
  background: var(--bg-sheet);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 50px;
  box-shadow: 0 20px 40px rgba(0,0,0,0.4);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

/* Firefox performance fix: backdrop-filter is very slow in Mozilla */
@-moz-document url-prefix() {
  #awsheet-app .awsheet {
    backdrop-filter: none;
    background: rgba(23, 23, 23, 0.75);
  }
  #avatar-menu-modal {
    backdrop-filter: none !important;
  }
}

#awsheet-app .awsheet-header {
  text-align: center;
  margin-bottom: 20px;
}
#awsheet-app .awsheet-header h1 {
  font-size: 3.5rem;
  font-weight: 700;
  letter-spacing: 3px;
  text-transform: uppercase;
  margin: 0;
  
  background: linear-gradient(to right, #8b5cf6 0%, #e879f9 30%, #fdf3d1 70%, #a88143 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  filter: drop-shadow(0 0 20px rgba(139, 92, 246, 0.3)); /* Soft atmospheric glow */
}

#awsheet-app .sheet-top {
  display: grid;
  grid-template-columns: 1fr 260px 1fr;
  align-items: stretch;
  gap: 20px;
  margin-bottom: 45px;
}
#awsheet-app .left-panel,
#awsheet-app .avatar-block,
#awsheet-app .right-panel {
  min-height: 0;
  height: 100%;
}
#awsheet-app .sheet-bottom {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 25px;
  margin-bottom: 30px;
}
@media (max-width: 1100px) {
  #awsheet-app .sheet-bottom { grid-template-columns: repeat(2, 1fr); }
  #awsheet-app .sheet-top { grid-template-columns: 1fr 1fr; }
  #awsheet-app .avatar-block { grid-column: 1 / -1; }
}
@media (max-width: 768px) {
  #awsheet-app .sheet-top, #awsheet-app .sheet-bottom { grid-template-columns: 1fr; }
  #awsheet-app .sheet-top { display: flex; flex-direction: column; gap: 15px; }
  #awsheet-app .left-panel { display: contents; }
  
  #awsheet-app .mobile-order-1 { order: 1; }
  #awsheet-app .mobile-order-2 { order: 2; }
  #awsheet-app .mobile-order-3 { order: 3; }
  #awsheet-app .avatar-block { order: 99; margin: 15px 0; min-height: 400px; }
  #awsheet-app .mobile-order-4 { order: 4; }
  #awsheet-app .mobile-order-5 { order: 5; }
  #awsheet-app .mobile-order-6 { order: 6; }
  
  #awsheet-app .right-panel { order: 7; }
  
  #awsheet-app .awsheet { padding: 20px; }
}

#awsheet-app .panel {
  background: transparent;
  border: none;
  padding: 0;
  box-shadow: none;
}
#awsheet-app .panel-title {
  font-size: 1.1rem;
  font-weight: 900;
  color: #fff;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 15px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

#awsheet-app .field { margin-bottom: 8px; }
#awsheet-app .field-row { display: flex; gap: 15px; margin-bottom: 8px; }

/* --- Mode Toggle --- */
.mode-toggle {
  display: flex;
  background: #111;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
}
.mode-option {
  padding: 8px 16px;
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  transition: 0.2s;
}
.mode-option.active {
  color: #fff;
  background: var(--accent-blue);
}

#awsheet-app .field label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 2px;
  font-weight: 500;
}

#awsheet-app .input-styled {
  width: 100%;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 4px 0;
  font-family: var(--font-main);
  font-size: 0.95rem;
  transition: border-color 0.2s ease;
  border-radius: 0;
}
#awsheet-app .input-styled:focus {
  outline: none;
  border-bottom-color: #d1b5b8;
}

#awsheet-app textarea.input-styled {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 8px;
  min-height: 80px;
  resize: none;
  overflow: hidden;
  line-height: 1.5;
}
#awsheet-app .restricted-ta {
  resize: none;
  overflow: hidden;
  min-height: 96px;
  height: 96px;
}
#awsheet-app textarea#char-competences,
#awsheet-app textarea#char-info {
  min-height: 140px;
}
#awsheet-app textarea.restricted-ta {
  padding: 8px 8px 0 8px;
}
#awsheet-app textarea.single-line-ta {
  min-height: 0;
  padding: 4px 0;
  border-radius: 0;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border-color);
}
#awsheet-app textarea.input-styled:focus {
  border-color: #d1b5b8;
}

/* Principle Checkboxes Block */
#awsheet-app .principle-checkboxes-block {
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.03);
  border-radius: 6px;
  padding: 8px 12px;
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.5);
  margin-bottom: 5px;
}

#awsheet-app .avatar-frame {
  width: 100%;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.2s;
}
#awsheet-app .avatar-frame:hover { border-color: var(--text-muted); }
#awsheet-app .avatar-frame img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 25%;
  display: none;
}
#awsheet-app .avatar-placeholder {
  color: var(--text-muted);
  text-align: center;
  font-size: 0.85rem;
}

#awsheet-app .principle-group { margin-bottom: 12px; }
#awsheet-app .principle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}
#awsheet-app .principle-label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-main);
  cursor: help;
  transition: all 0.2s ease;
}
#awsheet-app .principle-label:hover {
  color: #fff !important;
  text-shadow: 0 0 5px rgba(255, 255, 255, 0.4);
}

/* Competency rows */
#awsheet-app .competency-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
#awsheet-app .competency-row input[type="text"] { flex: 1; }
#awsheet-app .competency-row .btn-remove { flex-shrink: 0; }

/* Points bar */
#awsheet-app.view-mode #points-bar { display: none !important; }
#awsheet-app.view-mode #btn-add-competency { display: none !important; }
#awsheet-app.view-mode .competency-row .btn-remove { display: none !important; }
#awsheet-app .principle-boxes {
  display: flex;
  gap: 8px;
}
#awsheet-app .principle-cb {
  appearance: none;
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border: 1px solid var(--border-color);
  background: transparent;
  border-radius: 3px;
  cursor: pointer;
  position: relative;
  transition: all 0.15s;
}
#awsheet-app .principle-cb:hover { border-color: var(--text-muted); }
#awsheet-app .principle-cb:checked::before {
  content: "";
  position: absolute;
  top: 3px; left: 3px; right: 3px; bottom: 3px;
  border-radius: 1px;
}
#awsheet-app .principle-row.evolution .principle-cb:nth-child(1):checked { border-color: #486a57; }
#awsheet-app .principle-row.evolution .principle-cb:nth-child(1):checked::before { background: #486a57; }
#awsheet-app .principle-row.evolution .principle-cb:nth-child(2):checked { border-color: #729382; }
#awsheet-app .principle-row.evolution .principle-cb:nth-child(2):checked::before { background: #729382; }
#awsheet-app .principle-row.evolution .principle-cb:nth-child(3):checked { border-color: #9dbcad; }
#awsheet-app .principle-row.evolution .principle-cb:nth-child(3):checked::before { background: #9dbcad; }
#awsheet-app .principle-row.evolution .principle-cb:nth-child(4):checked { border-color: #c8e6d8; }
#awsheet-app .principle-row.evolution .principle-cb:nth-child(4):checked::before { background: #c8e6d8; }

#awsheet-app .principle-row.metamorph .principle-cb:nth-child(1):checked { border-color: #6c4b4e; }
#awsheet-app .principle-row.metamorph .principle-cb:nth-child(1):checked::before { background: #6c4b4e; }
#awsheet-app .principle-row.metamorph .principle-cb:nth-child(2):checked { border-color: #957578; }
#awsheet-app .principle-row.metamorph .principle-cb:nth-child(2):checked::before { background: #957578; }
#awsheet-app .principle-row.metamorph .principle-cb:nth-child(3):checked { border-color: #bea0a3; }
#awsheet-app .principle-row.metamorph .principle-cb:nth-child(3):checked::before { background: #bea0a3; }
#awsheet-app .principle-row.metamorph .principle-cb:nth-child(4):checked { border-color: #e7cbce; }
#awsheet-app .principle-row.metamorph .principle-cb:nth-child(4):checked::before { background: #e7cbce; }

#awsheet-app .skill-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 10px;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border-color);
  border-radius: 0;
  margin-bottom: 0;
}
#awsheet-app .skill-name {
  font-size: 0.95rem;
  color: var(--text-main);
}
#awsheet-app .skill-cost {
  color: var(--text-muted);
  font-size: 0.8rem;
}
#awsheet-app .skill-row.highlighted {
  border: 1px solid rgba(114, 147, 130, 0.4);
  border-radius: 4px;
  background: transparent;
  margin-bottom: 2px;
}
#awsheet-app .skill-row.highlighted .skill-name { color: var(--text-main); }
#awsheet-app .skill-row.error {
  border: 1px solid rgba(239, 68, 68, 0.9);
  border-radius: 4px;
  background: rgba(239, 68, 68, 0.18);
  margin-bottom: 2px;
}
#awsheet-app .skill-row.error .skill-name { color: #ef4444; font-weight: bold; }

/* --- View Mode Overrides --- */
#awsheet-app.view-mode .help-icon,
#awsheet-app.view-mode .btn-add,
#awsheet-app.view-mode .btn-remove,
#awsheet-app.view-mode .image-placeholder,
#awsheet-app.view-mode button[id^="btn-add-"],
#awsheet-app.view-mode #skills-dropdown,
#awsheet-app.view-mode .panel-title input[type="number"],
#awsheet-app.view-mode .cost-item:has(input:placeholder-shown) {
  display: none !important;
}

#awsheet-app.view-mode input[type="text"],
#awsheet-app.view-mode input[type="number"],
#awsheet-app.view-mode textarea,
#awsheet-app.view-mode select {
  border-color: transparent !important;
  background: transparent !important;
  pointer-events: none;
  box-shadow: none !important;
  color: var(--text-main);
}
#awsheet-app.view-mode input::placeholder,
#awsheet-app.view-mode textarea::placeholder {
  color: transparent !important;
}

#awsheet-app.view-mode .avatar-frame {
  cursor: default !important;
  border-color: transparent !important;
}

#awsheet-app.view-mode .token {
  pointer-events: none;
}
#awsheet-app.view-mode .token:not(.active) {
  opacity: 0;
}

#awsheet-app .cost-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
#awsheet-app .cost-item {
  display: flex;
  align-items: center;
  gap: 10px;
}
#awsheet-app .cost-item input[type="text"] { flex: 1; }
#awsheet-app .cost-item input[type="number"] {
  width: 50px;
  text-align: center;
}
#awsheet-app .btn-remove {
  background: transparent;
  color: var(--text-muted);
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0 5px;
}
#awsheet-app .btn-remove:hover { color: var(--accent-red); }

#awsheet-app .tokens-grid-container {
  display: flex;
  flex-direction: column;
  gap: 20px;
}
#awsheet-app .token-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
#awsheet-app .token-group label {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  font-weight: 500;
  letter-spacing: 0.5px;
}
#awsheet-app .token-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
#awsheet-app .token-box {
  width: 18px;
  height: 18px;
  border: 1px solid var(--border-color);
  background: transparent;
  border-radius: 3px;
  cursor: pointer;
  position: relative;
  transition: all 0.15s;
  flex-shrink: 0;
}
#awsheet-app .token-box:hover { border-color: var(--text-muted); }
#awsheet-app .token-box.active::before {
  content: "";
  position: absolute;
  top: 3px; left: 3px; right: 3px; bottom: 3px;
  border-radius: 1px;
}
#awsheet-app #tokens-effort {
  display: grid;
  grid-template-columns: repeat(5, 18px);
  gap: 8px;
}
/* Effort tokens progressive left-to-right gold gradient (light to dark) */
#awsheet-app #tokens-effort .token-box:nth-child(1).active,
#awsheet-app #tokens-effort .token-box:nth-child(6).active { border-color: #f5cb9e; }
#awsheet-app #tokens-effort .token-box:nth-child(1).active::before,
#awsheet-app #tokens-effort .token-box:nth-child(6).active::before { background: #f5cb9e; }

#awsheet-app #tokens-effort .token-box:nth-child(2).active,
#awsheet-app #tokens-effort .token-box:nth-child(7).active { border-color: #e5b07c; }
#awsheet-app #tokens-effort .token-box:nth-child(2).active::before,
#awsheet-app #tokens-effort .token-box:nth-child(7).active::before { background: #e5b07c; }

#awsheet-app #tokens-effort .token-box:nth-child(3).active,
#awsheet-app #tokens-effort .token-box:nth-child(8).active { border-color: #d19665; }
#awsheet-app #tokens-effort .token-box:nth-child(3).active::before,
#awsheet-app #tokens-effort .token-box:nth-child(8).active::before { background: #d19665; }

#awsheet-app #tokens-effort .token-box:nth-child(4).active,
#awsheet-app #tokens-effort .token-box:nth-child(9).active { border-color: #b87e53; }
#awsheet-app #tokens-effort .token-box:nth-child(4).active::before,
#awsheet-app #tokens-effort .token-box:nth-child(9).active::before { background: #b87e53; }

#awsheet-app #tokens-effort .token-box:nth-child(5).active,
#awsheet-app #tokens-effort .token-box:nth-child(10).active { border-color: #9a6845; }
#awsheet-app #tokens-effort .token-box:nth-child(5).active::before,
#awsheet-app #tokens-effort .token-box:nth-child(10).active::before { background: #9a6845; }

#awsheet-app .gold-gradient-label {
  background: linear-gradient(to right, #9a6845 0%, #e0b4a4 50%, #fcead9 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  letter-spacing: 0.5px;
}

/* Sanity (Blue) tokens progressive left-to-right gradient (light to dark) */
#awsheet-app #tokens-sanity .token-box:nth-child(1).active { border-color: #aecdff; }
#awsheet-app #tokens-sanity .token-box:nth-child(1).active::before { background: #aecdff; }
#awsheet-app #tokens-sanity .token-box:nth-child(2).active { border-color: #94bcff; }
#awsheet-app #tokens-sanity .token-box:nth-child(2).active::before { background: #94bcff; }
#awsheet-app #tokens-sanity .token-box:nth-child(3).active { border-color: #7caeff; }
#awsheet-app #tokens-sanity .token-box:nth-child(3).active::before { background: #7caeff; }
#awsheet-app #tokens-sanity .token-box:nth-child(4).active { border-color: #5a99ff; }
#awsheet-app #tokens-sanity .token-box:nth-child(4).active::before { background: #5a99ff; }

#awsheet-app .blue-gradient-label {
  background: linear-gradient(to right, #5a99ff 0%, #7caeff 50%, #aecdff 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  letter-spacing: 0.5px;
}

/* Flesh (Pink) tokens progressive left-to-right gradient (light to dark) */
#awsheet-app #tokens-luck .token-box:nth-child(1).active { border-color: #ffb6c2; }
#awsheet-app #tokens-luck .token-box:nth-child(1).active::before { background: #ffb6c2; }
#awsheet-app #tokens-luck .token-box:nth-child(2).active { border-color: #ffa0af; }
#awsheet-app #tokens-luck .token-box:nth-child(2).active::before { background: #ffa0af; }
#awsheet-app #tokens-luck .token-box:nth-child(3).active { border-color: #ff7e93; }
#awsheet-app #tokens-luck .token-box:nth-child(3).active::before { background: #ff7e93; }
#awsheet-app #tokens-luck .token-box:nth-child(4).active { border-color: #ff5a75; }
#awsheet-app #tokens-luck .token-box:nth-child(4).active::before { background: #ff5a75; }

#awsheet-app .pink-gradient-label {
  background: linear-gradient(to right, #ff5a75 0%, #ff7e93 50%, #ffb6c2 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  letter-spacing: 0.5px;
}

/* Stress (Red) tokens progressive left-to-right gradient */
#awsheet-app #tokens-stress .token-box:nth-child(1).active { border-color: #ff2116; }
#awsheet-app #tokens-stress .token-box:nth-child(1).active::before { background: #ff2116; }
#awsheet-app #tokens-stress .token-box:nth-child(2).active { border-color: #ff3f36; }
#awsheet-app #tokens-stress .token-box:nth-child(2).active::before { background: #ff3f36; }
#awsheet-app #tokens-stress .token-box:nth-child(3).active { border-color: #fd564d; }
#awsheet-app #tokens-stress .token-box:nth-child(3).active::before { background: #fd564d; }
#awsheet-app #tokens-stress .token-box:nth-child(4).active { border-color: #ff736c; }
#awsheet-app #tokens-stress .token-box:nth-child(4).active::before { background: #ff736c; }

#awsheet-app .red-gradient-label {
  background: linear-gradient(to right, #ff736c 0%, #fd564d 50%, #ff2116 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  letter-spacing: 0.5px;
}

#awsheet-app .token-box.active { background: transparent; }

#awsheet-app .exp-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 15px;
  text-align: center;
}
#awsheet-app .exp-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 5px;
}
#awsheet-app .exp-grid input {
  width: 100%;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border-color);
  color: #fff;
  font-size: 1.1rem;
  text-align: center;
  font-family: var(--font-main);
  padding: 2px 0;
}

#awsheet-app .btn-primary,
.modal-overlay .btn-primary {
  width: 100%;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  padding: 8px 15px;
  border-radius: 4px;
  font-family: var(--font-main);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  margin-top: 10px;
}
#awsheet-app .btn-primary:hover,
.modal-overlay .btn-primary:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--text-muted);
}
#awsheet-app .controls {
  display: flex;
  gap: 15px;
  width: 100%;
  max-width: 600px;
  margin: 0 auto 30px;
  justify-content: center;
  padding-top: 20px;
}
#awsheet-app .controls .btn-primary { margin-top: 0; flex: 1; padding: 10px 10px; }

#awsheet-app #context-menu {
  position: absolute;
  display: none;
  background: var(--bg-sheet);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 8px 15px;
  font-size: 0.85rem;
  color: var(--text-main);
  cursor: pointer;
  z-index: 1000;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}
#awsheet-app #context-menu:hover { background: rgba(255, 255, 255, 0.05); }

/* --- View Mode Overrides --- */
#awsheet-app.view-mode .help-icon,
#awsheet-app.view-mode .btn-add,
#awsheet-app.view-mode .btn-remove,
#awsheet-app.view-mode .image-placeholder,
#awsheet-app.view-mode button[id^="btn-add-"],
#awsheet-app.view-mode #skills-dropdown,
#awsheet-app.view-mode .panel-title input[type="number"],
#awsheet-app.view-mode .cost-item:has(input:placeholder-shown) {
  display: none !important;
}

#awsheet-app.view-mode input[type="text"],
#awsheet-app.view-mode input[type="number"],
#awsheet-app.view-mode textarea,
#awsheet-app.view-mode select {
  border-color: transparent !important;
  background: transparent !important;
  pointer-events: none;
  box-shadow: none !important;
  color: var(--text-main);
}
#awsheet-app.view-mode input::placeholder,
#awsheet-app.view-mode textarea::placeholder {
  color: transparent !important;
}

#awsheet-app.view-mode .left-panel,
#awsheet-app.view-mode .right-panel {
  justify-content: flex-start !important;
  gap: 15px !important;
}

#awsheet-app.view-mode .avatar-frame {
  cursor: default !important;
  border-color: transparent !important;
}

#awsheet-app.view-mode .token {
  pointer-events: none;
}
#awsheet-app.view-mode .token:not(.active) {
  opacity: 0;
}

#tooltip-modal {
  position: fixed;
  top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0,0,0,0.7);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}
#tooltip-modal .modal-content {
  background: #171717;
  border: 1px solid #2e2e2e;
  padding: 30px;
  border-radius: 8px;
  max-width: 400px;
  width: 90%;
  text-align: center;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}
#tooltip-modal .modal-content h2 {
  font-size: 1.2rem;
  color: #fff;
  margin-top: 0;
  margin-bottom: 15px;
  font-weight: 900;
}
#tooltip-modal .modal-content p {
  color: #e0e0e0;
  font-size: 0.95rem;
  margin-bottom: 25px;
}

@media (min-width: 769px) {
  #awsheet-app .left-panel {
    text-align: right;
  }
  #awsheet-app .left-panel .input-styled {
    text-align: right;
  }
}

@media (min-width: 1101px) {
  #awsheet-app .left-panel .field label {
    background: linear-gradient(to left, rgba(255, 255, 255, 0.08) 0%, transparent 100%);
    padding: 2px 10px 2px 0;
  }
  
  #awsheet-app .right-panel .field label {
    background: linear-gradient(to right, rgba(255, 255, 255, 0.08) 0%, transparent 100%);
    padding: 2px 0 2px 10px;
    display: block;
  }
  
  #awsheet-app .right-panel .evolution .principle-label {
    background: linear-gradient(to right, #c8e6d8 0%, #486a57 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
  }
  
  #awsheet-app .right-panel .metamorph .principle-label {
    background: linear-gradient(to right, #e7cbce 0%, #6c4b4e 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
  }
}

#awsheet-app.view-mode .restricted-ta {
  min-height: 0 !important;
}

/* --- Hint Icons --- */
#awsheet-app .hint-icon {
  display: inline-block;
  margin-left: 6px;
  width: 16px;
  height: 16px;
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-muted);
  border-radius: 50%;
  font-size: 11px;
  line-height: 16px;
  text-align: center;
  font-style: normal;
  font-family: monospace;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s, background 0.2s, color 0.2s;
  vertical-align: middle;
}

#awsheet-app .field:hover .hint-icon,
#awsheet-app .panel:hover .hint-icon,
#awsheet-app .principle-row:hover .hint-icon,
#awsheet-app .xp-box:hover .hint-icon,
#awsheet-app .panel-title:hover .hint-icon,
#awsheet-app .token-label:hover .hint-icon {
  opacity: 1;
}

#awsheet-app .hint-icon:hover {
  background: var(--accent-purple);
  color: #fff;
}



/* HINT HIGHLIGHTING */
#awsheet-app .hint-clickable {
  cursor: help;
  transition: all 0.2s ease;
}

#awsheet-app .hint-clickable:hover {
  color: #fff !important;
  text-shadow: 0 0 5px rgba(255, 255, 255, 0.3);
}

@media (min-width: 1101px) {
  #awsheet-app .left-panel .field label.hint-clickable:hover {
    background: linear-gradient(to left, rgba(255, 255, 255, 0.15) 0%, transparent 100%);
  }
  #awsheet-app .right-panel .field label.hint-clickable:hover {
    background: linear-gradient(to right, rgba(255, 255, 255, 0.15) 0%, transparent 100%);
  }
}

/* SECTION TITLES */
#awsheet-app .section-title {
  cursor: help;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-family: 'Montserrat', sans-serif;
  font-size: 1.8rem;
  line-height: 0.8;
  font-weight: 900;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 20px;
  padding-left: 0.4em;
  
  opacity: 0.6;
}

#awsheet-app .section-title::before,
#awsheet-app .section-title::after {
  display: none;
  flex: 1;
  height: 1px;
  margin: 0 15px;
}

#awsheet-app .chaos-title { 
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.7), rgba(232, 121, 249, 0.7), rgba(139, 92, 246, 0.7));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  color: #a855f7;
  margin-top: 12px !important;
  margin-bottom: 8px !important;
  cursor: help;
  transition: all 0.3s ease;
}
#awsheet-app .chaos-title:hover {
  background: none !important;
  -webkit-background-clip: unset !important;
  -webkit-text-fill-color: #ffffff !important;
  color: #ffffff !important;
  opacity: 1 !important;
  text-shadow: 0 0 8px #a855f7, 0 0 18px #e879f9, 0 0 30px #a855f7 !important;
}

#awsheet-app .order-title { 
  background: linear-gradient(135deg, rgba(185, 100, 60, 0.8), rgba(250, 220, 170, 0.9), rgba(155, 80, 45, 0.8));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  color: #b8643c;
  margin-top: 12px !important;
  margin-bottom: 8px !important;
  cursor: help;
  transition: all 0.3s ease;
}
#awsheet-app .order-title:hover {
  background: none !important;
  -webkit-background-clip: unset !important;
  -webkit-text-fill-color: #ffffff !important;
  color: #ffffff !important;
  opacity: 1 !important;
  text-shadow: 0 0 8px #fadeaa, 0 0 18px #b8643c, 0 0 30px #fadeaa !important;
}

/* THEMED FRAMES (JS POSITIONED) */
#awsheet-app .left-panel,
#awsheet-app .right-panel {
  position: relative;
  padding-bottom: 0;
}
#awsheet-app .themed-frame {
  position: absolute;
  left: -15px;
  right: -15px;
  border-radius: 8px 8px 0 0;
  background: rgba(0, 0, 0, 0.15);
  z-index: 0;
  pointer-events: none;
  -webkit-mask-image: linear-gradient(to bottom, black 100px, transparent 220px);
  mask-image: linear-gradient(to bottom, black 100px, transparent 220px);
}
#awsheet-app .themed-frame::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 8px 8px 0 0;
  padding: 1px 1px 0 1px;
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
          mask-composite: exclude;
  /* Opacity removed! Alpha is baked into colors to fix the mask anti-aliasing bug */
}
#awsheet-app .chaos-frame::before {
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.7), rgba(232, 121, 249, 0.7), rgba(139, 92, 246, 0.7));
}
#awsheet-app .order-frame::before {
  background: linear-gradient(135deg, rgba(185, 100, 60, 0.8), rgba(250, 220, 170, 0.9), rgba(155, 80, 45, 0.8));
}
#awsheet-app .left-panel .field,
#awsheet-app .right-panel .field {
  position: relative;
  z-index: 1; /* Sit above the frame */
}

/* Fix Avatar picture length to align with frames */
#awsheet-app .avatar-block {
  padding-bottom: 0 !important;
}
#awsheet-app .avatar-block .avatar-frame {
  height: 100% !important;
}

/* CUSTOM FOCUS COLORS */
#awsheet-app .input-styled:focus {
  outline: none !important;
  border-bottom-color: #a1a1aa !important;
}
#awsheet-app textarea.input-styled:focus {
  border-color: #a1a1aa !important;
}
#awsheet-app #char-brand:focus,
#awsheet-app #char-temptations:focus,
#awsheet-app #char-vulnerabilities:focus {
  border-color: #9c7fc2 !important;
  border-bottom-color: #9c7fc2 !important;
}
#awsheet-app .principle-group .input-styled:focus,
#awsheet-app #char-aspirations:focus {
  border-color: #dac9a0 !important;
  border-bottom-color: #dac9a0 !important;
}

#awsheet-app .principle-group .input-styled::selection,
#awsheet-app #char-aspirations::selection {
  background-color: rgba(218, 201, 160, 0.3) !important;
  color: #ffffff !important;
}

/* Styles for reset checkboxes to match the 4th checkboxes */
#awsheet-app .principle-row.evolution .principle-reset-cb:checked { border-color: #c8e6d8 !important; }
#awsheet-app .principle-row.evolution .principle-reset-cb:checked::before {
  content: ""; position: absolute; top: 3px; left: 3px; right: 3px; bottom: 3px; background: #c8e6d8 !important; border-radius: 1px;
}
#awsheet-app .principle-row.metamorph .principle-reset-cb:checked { border-color: #e7cbce !important; }
#awsheet-app .principle-row.metamorph .principle-reset-cb:checked::before {
  content: ""; position: absolute; top: 3px; left: 3px; right: 3px; bottom: 3px; background: #e7cbce !important; border-radius: 1px;
}
/* Skills Modal Styles */
.skill-modal-item {
  padding: 10px;
  border: 1px solid transparent;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08) !important;
  cursor: pointer;
  color: var(--text-main);
  transition: all 0.2s ease;
  border-radius: 4px;
}
.skill-modal-item:hover {
  background: rgba(255, 255, 255, 0.05);
}
.skill-modal-item.selected {
  background: rgba(218, 201, 160, 0.15);
  border-color: #dac9a0 !important;
  color: #dac9a0 !important;
  font-weight: bold;
}
.skill-modal-item.trait-adv {
  color: #8cba76;
}
.skill-modal-item.trait-dis {
  color: #d9534f;
}
.skill-modal-item.trait-adv.selected {
  background: rgba(140, 186, 118, 0.15);
  border-color: #8cba76 !important;
  color: #8cba76 !important;
}
.skill-modal-item.trait-dis.selected {
  background: rgba(217, 83, 79, 0.15);
  border-color: #d9534f !important;
  color: #d9534f !important;
}

/* Custom Number Input Controls */
.number-control {
  display: flex;
  align-items: center;
  gap: 5px;
}
.number-control button {
  background: var(--bg-body);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  width: 24px;
  height: 24px;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  transition: all 0.2s ease;
}
.number-control button:hover {
  background: var(--accent-purple);
  color: white;
  border-color: var(--accent-purple);
}
.number-control .val-display {
  font-family: var(--font-main);
  font-size: 0.95rem;
  min-width: 20px;
  text-align: center;
}



/* Modal Desktop Specific Layout */
@media (min-width: 480px) {
  #skills-modal-left {
    flex: 0 0 240px !important;
  }
  #skills-modal-right {
    flex: 1 !important;
  }
}
/* View mode custom value spans */
.view-mode-value {
    display: none;
    color: var(--text-main);
    font-size: 1rem;
    font-weight: bold;
    margin-left: 5px;
    margin-right: 5px;
}

#awsheet-app.view-mode .cost-item input[type="number"],
#awsheet-app.view-mode .skill-row input[type="number"] {
    display: none !important;
}

#awsheet-app.view-mode .view-mode-value {
    display: inline-block;
}

/* Skill row styling (Edit mode vs View mode) */
#awsheet-app .skill-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 8px;
    border-radius: 4px;
    border: 1px solid transparent;
    transition: all 0.2s ease;
}

/* Single highlighted skill >= 7 (when count <= 4): soft evolution sage green border (#729382) with subtle matching green tint background */
#awsheet-app:not(.view-mode) .skill-row.highlighted {
    border: 1px solid rgba(114, 147, 130, 0.5) !important;
    background: rgba(114, 147, 130, 0.12) !important;
}
#awsheet-app:not(.view-mode) .skill-row.highlighted .skill-name {
    color: var(--text-main) !important;
}

/* Thin divider lines for skills in EDIT mode */
#awsheet-app:not(.view-mode) #skills-list .skill-row:not(.highlighted):not(.error) {
    border-bottom: 1px solid rgba(255, 255, 255, 0.1) !important;
}

/* Error state (>4 skills >= 7): clear transparent-red border outline in edit mode */
#awsheet-app:not(.view-mode) .skill-row.error {
    border: 1px solid rgba(239, 68, 68, 0.7) !important;
    background: rgba(239, 68, 68, 0.1) !important;
    box-shadow: 0 0 6px rgba(239, 68, 68, 0.25);
}

/* Warning banner above skills when >4 skills exceed level 6 */
#skills-limit-warning {
    display: none;
    margin-bottom: 10px;
    padding: 8px 12px;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.5);
    border-radius: 4px;
    color: #f87171;
    font-size: 0.78rem;
    line-height: 1.35;
    text-align: left;
}

#awsheet-app:not(.view-mode) #skills-limit-warning.active {
    display: block;
}

#awsheet-app.view-mode .skill-row {
    border-color: transparent !important;
    background: transparent !important;
    padding: 4px 0 !important;
}

/* Thin divider lines between skills in view mode */
#awsheet-app.view-mode #skills-list .skill-row {
    border-bottom: 1px solid rgba(255, 255, 255, 0.1) !important;
}

/* Fully hide highlighted/error borders in view mode */
#awsheet-app.view-mode .skill-row.highlighted,
#awsheet-app.view-mode .skill-row.error {
    border: none !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1) !important;
    background: transparent !important;
    margin-bottom: 0 !important;
    box-shadow: none !important;
}

/* Hide cost-item & competency-row elements in view mode if text input is empty */
#awsheet-app.view-mode .cost-item.empty-in-view,
#awsheet-app.view-mode .competency-row.empty-in-view {
    display: none !important;
}

#skills-modal-points::-webkit-inner-spin-button, #skills-modal-points::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }

/* Modal Controls Styling (Grey Box Style) */
#skills-modal-btn-minus,
#skills-modal-btn-plus,
#btn-modal-add-skill {
  background: rgba(255, 255, 255, 0.05) !important;
  border: 1px solid rgba(255, 255, 255, 0.1) !important;
  border-radius: 4px !important;
  color: var(--text-main) !important;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: var(--font-main);
  text-transform: uppercase;
}

#skills-modal-btn-minus:hover,
#skills-modal-btn-plus:hover,
#btn-modal-add-skill:not(:disabled):hover {
  background: rgba(255, 255, 255, 0.1) !important;
  border-color: rgba(255, 255, 255, 0.3) !important;
}

#btn-modal-add-skill:disabled {
  opacity: 0.3 !important;
  cursor: not-allowed !important;
}

#skills-modal-points {
  background: transparent !important;
  border: none !important;
  color: var(--text-main) !important;
  font-family: var(--font-main);
  font-size: 1.4rem !important;
  transition: all 0.2s ease;
}

#skills-modal-points:focus {
  outline: none !important;
}

/* Reset text color in view mode */
#awsheet-app.view-mode .skill-row.highlighted .skill-name,
#awsheet-app.view-mode .skill-row.error .skill-name {
    color: var(--text-main) !important;
}

/* Override height for Brand box */
#awsheet-app textarea#char-brand {
    min-height: 0;
    resize: none;
}

/* Match font size of skills-points counter to panel title */
#awsheet-app #skills-points {
    font-size: 1rem;
    font-family: var(--font-main);
    display: none; /* Hidden: duplicates the points bar above */
}

/* Points bar labels: override global section-title opacity so they're clearly readable */
#awsheet-app #points-bar .section-title {
    opacity: 1;
    color: var(--text-muted);
    font-size: 0.75rem;
    letter-spacing: 1.5px;
    margin-bottom: 0;
    white-space: nowrap;
}

/* Keep Distribute XP button compact */
#awsheet-app #btn-distribute-exp {
    flex-shrink: 0;
    width: auto !important;
    white-space: nowrap;
    padding: 6px 12px !important;
    font-size: 0.7rem !important;
    align-self: center;
}

/* Modal detail input styling matching site dark theme */
#bodymind-modal-detail-input {
  background: rgba(0, 0, 0, 0.4) !important;
  border: 1px solid var(--border-color) !important;
  border-radius: 4px !important;
  color: var(--text-main) !important;
  padding: 8px 12px !important;
  font-family: var(--font-main) !important;
  font-size: 0.9rem !important;
  box-sizing: border-box !important;
  transition: border-color 0.2s ease, box-shadow 0.2s ease !important;
}

#bodymind-modal-detail-input:focus {
  outline: none !important;
  border-color: rgba(218, 201, 160, 0.6) !important;
  box-shadow: 0 0 8px rgba(218, 201, 160, 0.15) !important;
}

#bodymind-modal-detail-input::placeholder {
  color: var(--text-muted) !important;
  opacity: 0.7 !important;
}

/* ==========================================================================
   Clean Structured Layout Classes (Refactored from inline styles)
   ========================================================================== */

#awsheet-app .controls {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin: 15px auto 10px auto;
  max-width: 1000px;
  padding: 0 20px;
}
#awsheet-app .controls .btn-primary {
  flex: 1;
  margin: 0;
  padding: 6px 4px;
  font-size: 0.75rem;
  height: auto;
  min-height: 32px;
  letter-spacing: 0.5px;
}
#awsheet-app .controls label.btn-primary {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  cursor: pointer;
  box-sizing: border-box;
}

#awsheet-app .mode-toggle-wrapper {
  display: flex;
  justify-content: center;
  margin-bottom: 10px;
}

#awsheet-app .sheet-top {
  position: relative;
}

#awsheet-app .left-panel,
#awsheet-app .right-panel {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 100%;
  min-height: 0;
}

#awsheet-app #char-brand {
  min-height: 0;
}

#awsheet-app .field.mobile-order-5,
#awsheet-app .field.mobile-order-6 {
  display: flex;
  flex-direction: column;
  flex: 1;
}
#awsheet-app .field.mobile-order-5 #char-temptations,
#awsheet-app .field.mobile-order-6 #char-vulnerabilities {
  flex: 1;
  min-height: 80px;
}
#awsheet-app .field.mobile-order-6 {
  margin-bottom: 0;
}

#awsheet-app .avatar-block {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 100%;
  min-height: 0;
  gap: 15px;
}

#awsheet-app .avatar-frame {
  cursor: pointer;
  width: 100%;
  flex: 1;
  min-height: 180px;
}
#awsheet-app .avatar-placeholder {
  padding: 20px;
  line-height: 1.4;
}

#awsheet-app .tokens-grid-container {
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.03);
  border-radius: 6px;
  padding: 12px;
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.5);
  flex-shrink: 0;
}
#awsheet-app .tokens-wrapper {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
#awsheet-app .token-group {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
  width: 100%;
}
#awsheet-app .token-group label {
  margin: 0;
  font-size: 0.8rem;
  font-weight: 600;
}
#awsheet-app .token-group-effort {
  border-top: 1px solid var(--border-color);
  padding-top: 8px;
  margin-top: 2px;
}

#awsheet-app #species-age-row .field:last-child {
  flex: 0.5;
}

#awsheet-app .principle-group {
  margin-bottom: 10px;
}
#awsheet-app .principle-group:last-child {
  margin-bottom: 0;
}
#awsheet-app .principle-group .input-styled {
  margin-bottom: 5px;
}
#awsheet-app .principle-row-label {
  display: flex;
  align-items: center;
  gap: 8px;
}

#awsheet-app .aspirations-field {
  display: flex;
  flex-direction: column;
  margin-bottom: 0;
}
#awsheet-app #char-aspirations {
  min-height: 100px;
  padding: 8px;
  resize: none;
}

#awsheet-app #points-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 16px;
  padding: 10px 20px;
  margin: 24px 0;
  background: rgba(255, 255, 255, 0.02);
  border-top: 1px solid var(--border-color);
  border-bottom: 1px solid var(--border-color);
}
#awsheet-app #points-bar .point-item {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
#awsheet-app #points-bar input[type="number"] {
  width: 36px;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border-color);
  color: #dac9a0;
  text-align: center;
  font-family: var(--font-main);
  font-size: 0.9rem;
}

#awsheet-app .skills-header-counter {
  display: flex;
  align-items: center;
  gap: 10px;
}
#awsheet-app .add-skill-field {
  margin-bottom: 10px;
}

#awsheet-app .col-flex-container {
  display: flex;
  flex-direction: column;
  gap: 30px;
}
#awsheet-app .col-flex-container-full {
  height: 100%;
}
#awsheet-app .panel-info-flex {
  flex: 1;
  display: flex;
  flex-direction: column;
}
#awsheet-app #char-info {
  flex: 1;
  min-height: 500px;
}

#awsheet-app .panel-psych-wounds {
  padding: 0;
}
#awsheet-app .psych-wounds-wrapper {
  display: flex;
  gap: 15px;
}
#awsheet-app .psych-wounds-item {
  flex: 1;
}
#awsheet-app .btn-add-sub {
  margin-top: 5px;
}

#awsheet-app .exp-grid {
  padding: 15px;
}
#awsheet-app #exp-remain {
  color: var(--text-muted);
  border-bottom-color: transparent;
}
