:root {
  /* Desktop Background Color */
  --cde-desktop-bg: #8a9da8; /* Classic slate blue */

  /* Main CDE Color Palette (Warm Gray/Lavander) */
  --cde-bg-color: #ae9cbf; /* Main background color */
  --cde-light-shadow: #dfd7e6; /* Bright bevel highlight */
  --cde-dark-shadow: #7a6e87; /* Inner shadow */
  --cde-deep-shadow: #4e4458; /* Deepest shadow */

  /* Text Colors */
  --cde-text-color: #000000;
  --cde-title-text-color: #ffffff;
  --cde-disabled-text: #7a6e87;

  /* Accent Colors (Active state) */
  --cde-active-bg: #5d4876; /* Dark Indigo/Lavander for active titles */
  --cde-inactive-bg: #857896; /* Duller Indigo/Lavander for inactive titles */
  
  /* Field backgrounds */
  --cde-field-bg: #ffffff;
}

/* Base resets and Typography */
body {
  background-color: var(--cde-desktop-bg);
  color: var(--cde-text-color);
  font-family: "Lucida Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 13px;
  margin: 0;
  padding: 0;
}

h1, h2, h3, h4, h5, h6 {
  font-family: "Lucida Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
  color: var(--cde-text-color);
  margin-top: 0;
}

/* Link styling */
a {
  color: #3b2a56;
  text-decoration: underline;
}

a:hover {
  color: var(--cde-active-bg);
}

a:focus {
  outline: 1px dotted var(--cde-active-bg);
}

/* 3D Border Effects (The core of CDE/Motif) */
.window {
  background-color: var(--cde-bg-color);
  border-style: solid;
  border-width: 3px;
  border-color: var(--cde-light-shadow) var(--cde-deep-shadow) var(--cde-deep-shadow) var(--cde-light-shadow);
  box-shadow: inset 1px 1px 0 var(--cde-light-shadow),
              inset -1px -1px 0 var(--cde-dark-shadow);
  padding: 5px;
  box-sizing: border-box;
}

.window-body {
  margin: 8px;
  font-size: 13px;
  line-height: 1.4;
}

/* Title Bar */
.title-bar {
  background-color: var(--cde-active-bg);
  color: var(--cde-title-text-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 6px;
  border-style: solid;
  border-width: 2px;
  border-color: var(--cde-light-shadow) var(--cde-deep-shadow) var(--cde-deep-shadow) var(--cde-light-shadow);
  box-shadow: inset 1px 1px 0 var(--cde-light-shadow);
}

.title-bar.inactive {
  background-color: var(--cde-inactive-bg);
}

.title-bar-text {
  font-weight: bold;
  letter-spacing: 0.5px;
  user-select: none;
}

.title-bar-controls {
  display: flex;
  gap: 3px;
}

/* CDE Title Bar Button Design */
.title-bar-controls button {
  display: block;
  min-height: 18px;
  min-width: 18px;
  padding: 0;
  margin: 0;
  background-color: var(--cde-bg-color);
  border-style: solid;
  border-width: 1px;
  border-color: var(--cde-light-shadow) var(--cde-deep-shadow) var(--cde-deep-shadow) var(--cde-light-shadow);
  box-shadow: inset 1px 1px 0 var(--cde-light-shadow);
  cursor: pointer;
  position: relative;
}

.title-bar-controls button:active {
  border-color: var(--cde-deep-shadow) var(--cde-light-shadow) var(--cde-light-shadow) var(--cde-deep-shadow);
  box-shadow: inset 1px 1px 0 var(--cde-dark-shadow);
}

/* CDE Window controls vector paths */
.title-bar-controls button[aria-label="Minimize"] {
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg width='12' height='12' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Crect x='4' y='8' width='4' height='2' fill='%23000'/%3E%3C/svg%3E");
  background-position: center;
  background-repeat: no-repeat;
}

.title-bar-controls button[aria-label="Maximize"] {
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg width='12' height='12' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1v10h10V1' stroke='%23000' stroke-width='1'/%3E%3Crect x='1' y='1' width='10' height='3' fill='%23000'/%3E%3C/svg%3E");
  background-position: center;
  background-repeat: no-repeat;
}

.title-bar-controls button[aria-label="Close"] {
  /* Thin X cross to match SunOS 5.8 Generic close button style */
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg width='12' height='12' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M2 2l8 8M10 2L2 10' stroke='%23000' stroke-width='1'/%3E%3C/svg%3E");
  background-position: center;
  background-repeat: no-repeat;
}

/* System Buttons */
button {
  background-color: var(--cde-bg-color);
  color: var(--cde-text-color);
  font-family: inherit;
  font-size: 13px;
  font-weight: bold;
  border-style: solid;
  border-width: 2px;
  border-color: var(--cde-light-shadow) var(--cde-deep-shadow) var(--cde-deep-shadow) var(--cde-light-shadow);
  box-shadow: inset 1px 1px 0 var(--cde-light-shadow),
              inset -1px -1px 0 var(--cde-dark-shadow);
  padding: 4px 14px;
  box-sizing: border-box;
  min-height: 26px;
  cursor: pointer;
}

button:active {
  border-color: var(--cde-deep-shadow) var(--cde-light-shadow) var(--cde-light-shadow) var(--cde-deep-shadow);
  box-shadow: inset 1px 1px 0 var(--cde-dark-shadow);
  padding: 5px 13px 3px 15px; /* Offset text on click */
}

button:focus {
  outline: 1px dotted var(--cde-deep-shadow);
  outline-offset: -3px;
}

button:disabled {
  color: var(--cde-disabled-text);
  cursor: not-allowed;
}

/* Fields & Text Area */
input[type="text"], input[type="password"], textarea, select {
  background-color: var(--cde-field-bg);
  color: var(--cde-text-color);
  border-style: solid;
  border-width: 2px;
  border-color: var(--cde-deep-shadow) var(--cde-light-shadow) var(--cde-light-shadow) var(--cde-deep-shadow);
  box-shadow: inset 1px 1px 0 var(--cde-dark-shadow);
  font-family: inherit;
  font-size: 13px;
  padding: 4px 6px;
  box-sizing: border-box;
  outline: none;
}

input[type="text"]:focus, input[type="password"]:focus, textarea:focus, select:focus {
  outline: 1px solid var(--cde-active-bg);
}

/* Select Dropdown */
select {
  appearance: none;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg width='12' height='12' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M3 4h6L6 8 3 4z' fill='%23000'/%3E%3C/svg%3E");
  background-position: right 6px center;
  background-repeat: no-repeat;
  padding-right: 24px;
}

/* Status Bar */
.status-bar {
  display: flex;
  gap: 2px;
  margin-top: 4px;
}

.status-bar-field {
  background-color: var(--cde-bg-color);
  border-style: solid;
  border-width: 1px;
  border-color: var(--cde-deep-shadow) var(--cde-light-shadow) var(--cde-light-shadow) var(--cde-deep-shadow);
  box-shadow: inset 1px 1px 0 var(--cde-dark-shadow);
  padding: 3px 6px;
  flex-grow: 1;
  font-size: 12px;
}

/* Tree view */
ul.tree-view {
  background-color: var(--cde-field-bg);
  border-style: solid;
  border-width: 2px;
  border-color: var(--cde-deep-shadow) var(--cde-light-shadow) var(--cde-light-shadow) var(--cde-deep-shadow);
  padding: 6px;
  margin: 0;
  list-style: none;
}

ul.tree-view li {
  margin-left: 14px;
  position: relative;
}

/* Field row spacing helper */
.field-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.field-row-stacked {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 8px;
}

/* Scrollbars */
::-webkit-scrollbar {
  width: 18px;
  height: 18px;
}

::-webkit-scrollbar-track {
  background-color: var(--cde-dark-shadow);
  box-shadow: inset 1px 1px 0 var(--cde-deep-shadow);
}

::-webkit-scrollbar-thumb {
  background-color: var(--cde-bg-color);
  border-style: solid;
  border-width: 2px;
  border-color: var(--cde-light-shadow) var(--cde-deep-shadow) var(--cde-deep-shadow) var(--cde-light-shadow);
  box-shadow: inset 1px 1px 0 var(--cde-light-shadow);
}

::-webkit-scrollbar-thumb:active {
  border-color: var(--cde-deep-shadow) var(--cde-light-shadow) var(--cde-light-shadow) var(--cde-deep-shadow);
  box-shadow: inset 1px 1px 0 var(--cde-dark-shadow);
}

/* Menu Bar / Nav styling */
.menu-bar {
  display: flex;
  background-color: var(--cde-bg-color);
  padding: 3px 6px;
  gap: 4px;
  border-bottom: 2px solid var(--cde-deep-shadow);
  margin-bottom: 12px;
}

.menu-bar a {
  color: var(--cde-text-color);
  text-decoration: none;
  padding: 4px 10px;
  font-size: 13px;
  border: 1px solid transparent;
}

.menu-bar a:hover, .menu-bar a[aria-current="page"] {
  background-color: var(--cde-active-bg);
  color: var(--cde-title-text-color);
}

/* Gallery CDE styles */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin: 16px 0;
}

.piece {
  display: block;
  background-color: var(--cde-bg-color);
  border-style: solid;
  border-width: 2px;
  border-color: var(--cde-deep-shadow) var(--cde-light-shadow) var(--cde-light-shadow) var(--cde-deep-shadow);
  box-shadow: inset 1px 1px 0 var(--cde-dark-shadow);
  padding: 12px;
  text-decoration: none;
  color: var(--cde-text-color);
  min-height: 120px;
}

.piece:hover {
  background-color: var(--cde-light-shadow);
  border-color: var(--cde-light-shadow) var(--cde-deep-shadow) var(--cde-deep-shadow) var(--cde-light-shadow);
  box-shadow: inset 1px 1px 0 var(--cde-light-shadow),
              inset -1px -1px 0 var(--cde-dark-shadow);
}

.piece-kicker {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  color: var(--cde-active-bg);
  font-weight: bold;
  margin-bottom: 6px;
}

.piece strong {
  display: block;
  font-size: 14px;
  margin-bottom: 6px;
  color: var(--cde-text-color);
}

.piece span:last-child {
  display: block;
  font-size: 12px;
  color: #333;
}

/* Modal overlay and modal window styles */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(0, 0, 0, 0.4);
  z-index: 1999;
}

.modal-window {
  display: none;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 85%;
  max-width: 700px;
  height: 80%;
  max-height: 600px;
  z-index: 2000;
  flex-direction: column;
}

.modal-window .window-body {
  flex-grow: 1;
  margin: 0;
  padding: 0;
  background-color: #ffffff;
  overflow: hidden;
}

.modal-iframe {
  width: 100%;
  height: 100%;
  border: none;
  background-color: #ffffff;
}

/* Iframe view reset to avoid nested CDE window borders */
body.in-iframe {
  padding: 10px !important;
  background-color: #ffffff !important;
  overflow-y: auto !important;
}

body.in-iframe > .window {
  border: none !important;
  box-shadow: none !important;
  padding: 0 !important;
  background-color: transparent !important;
}

body.in-iframe .title-bar,
body.in-iframe .menu-bar,
body.in-iframe footer {
  display: none !important;
}

/* CDE Desktop styling */
body.cde-desktop {
  background-color: var(--cde-desktop-bg);
  height: 100vh;
  width: 100vw;
  margin: 0;
  padding: 0;
  overflow: hidden;
  position: relative;
  box-sizing: border-box;
}

body.cde-desktop .window {
  position: absolute;
  z-index: 10;
}

body.cde-desktop .title-bar {
  cursor: move;
}

/* Front Panel Container */
.cde-front-panel {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 90%;
  max-width: 900px;
  background-color: var(--cde-bg-color);
  height: 70px;
  border-style: solid;
  border-width: 3px;
  border-color: var(--cde-light-shadow) var(--cde-deep-shadow) var(--cde-deep-shadow) var(--cde-light-shadow);
  box-shadow: inset 1px 1px 0 var(--cde-light-shadow),
              inset -1px -1px 0 var(--cde-dark-shadow);
  z-index: 9999;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 10px;
  box-sizing: border-box;
}

.cde-front-panel-section {
  display: flex;
  align-items: center;
  gap: 6px;
}

.cde-panel-btn {
  background-color: var(--cde-bg-color);
  border-style: solid;
  border-width: 2px;
  border-color: var(--cde-light-shadow) var(--cde-deep-shadow) var(--cde-deep-shadow) var(--cde-light-shadow);
  box-shadow: inset 1px 1px 0 var(--cde-light-shadow),
              inset -1px -1px 0 var(--cde-dark-shadow);
  color: var(--cde-text-color);
  font-weight: bold;
  height: 48px;
  min-width: 60px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  font-size: 11px;
  cursor: pointer;
  padding: 2px 6px;
  box-sizing: border-box;
}

.cde-panel-btn:active, .cde-panel-btn.active {
  border-color: var(--cde-deep-shadow) var(--cde-light-shadow) var(--cde-light-shadow) var(--cde-deep-shadow);
  box-shadow: inset 1px 1px 0 var(--cde-dark-shadow);
  padding: 3px 5px 1px 7px;
}

.cde-panel-icon {
  font-size: 16px;
  margin-bottom: 2px;
}

/* Workspace Switcher in center of Front Panel */
.cde-workspace-switcher {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  grid-template-rows: repeat(2, 1fr);
  gap: 2px;
  width: 90px;
  height: 48px;
  background-color: var(--cde-dark-shadow);
  border: 2px solid var(--cde-deep-shadow);
  padding: 2px;
  box-sizing: border-box;
}

.cde-workspace-btn {
  background-color: var(--cde-bg-color);
  border: 1px solid var(--cde-light-shadow);
  color: var(--cde-text-color);
  font-size: 9px;
  font-weight: bold;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  padding: 0;
  margin: 0;
  min-width: unset;
  min-height: unset;
  box-shadow: none;
}

.cde-workspace-btn.active {
  background-color: var(--cde-active-bg);
  color: var(--cde-title-text-color);
  border-color: var(--cde-deep-shadow);
}

/* Reloj del CDE Front Panel */
.cde-clock {
  background-color: #000000;
  color: #00ff00;
  font-family: monospace;
  font-size: 13px;
  font-weight: bold;
  padding: 4px 8px;
  border-style: solid;
  border-width: 1px;
  border-color: var(--cde-deep-shadow) var(--cde-light-shadow) var(--cde-light-shadow) var(--cde-deep-shadow);
  width: 70px;
  text-align: center;
  box-sizing: border-box;
}.window.maximized {
  top: 0 !important;
  left: 0 !important;
  width: 100vw !important;
  height: calc(100vh - 74px) !important;
  position: fixed !important;
}
