
* {
  box-sizing: border-box;
}

:root {
  --bg: #101522;
  --panel: #192338;
  --raised: #263651;
  --line: #415571;
  --fg: #f3f7ff;
  --sub: #b4c7df;
  --green: #47e2a0;
  --blue: #7bb9ff;
  --red: #ff778d;
}

html,
body,
#display-block {
  width: 100%;
  height: 100%;
  margin: 0;
}

html,
body {
  overflow: hidden;
  background: var(--bg);
  color: var(--fg);
  font-family: Arial, Helvetica, sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  opacity: .4;
  cursor: default;
}

#display-block {
  display: block;
  position: relative;
  isolation: isolate;
}

.hidden {
  display: none !important;
}

/*
  ==================================================
  LANDING SCREEN
  ==================================================
*/

#landing {
  position: absolute;
  inset: 0;
  z-index: 12;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background:
    radial-gradient(
      ellipse at 25% 20%,
      #31496c 0%,
      transparent 48%
    ),
    radial-gradient(
      ellipse at 75% 85%,
      #45315a 0%,
      transparent 50%
    ),
    #101522;
}

.land-card {
  max-width: 640px;
  width: min(96%, 640px);
  max-height: 94%;
  overflow: auto;
  text-align: center;
  padding: clamp(22px, 4vw, 48px);
  background: #1a273e;
  border: 1px solid #526b89;
  border-radius: 23px;
  box-shadow: 0 25px 75px #0008;
}

.land-icon {
  font-size: 70px;
}

.land-title {
  font-size: clamp(40px, 7vw, 82px);
  margin: 12px 0 18px;
  letter-spacing: -2px;
  font-weight: 900;
}

.land-title span,
.brand span {
  color: var(--green);
}

.land-text {
  color: var(--sub);
  font-size: clamp(13px, 1.3vw, 17px);
  line-height: 1.8;
}

.land-features {
  background: #101c2f;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 17px;
  margin-top: 24px;
  text-align: left;
  line-height: 1.85;
  color: #c0d1e6;
  font-size: 13px;
}

/*
  ==================================================
  BUTTONS
  ==================================================
*/

.primary {
  background: var(--green) !important;
  border-color: #6bf8b7 !important;
  color: #082a1a !important;
  font-weight: 900 !important;
}

.primary:hover {
  background: #80fac2 !important;
}

.danger {
  border-color: #b36475 !important;
}

.danger:hover {
  background: #744052 !important;
}

.btn {
  background: #2b3d58;
  border: 1px solid #546d90;
  color: #edf5ff;
  border-radius: 8px;
  padding: 9px 12px;
  font-weight: 800;
  font-size: 12px;
  white-space: nowrap;
}

.btn:hover {
  background: #405777;
}

.btn-lg {
  padding: 15px 32px;
  font-size: 18px;
  border-radius: 12px;
  margin-top: 22px;
}

/*
  ==================================================
  STUDIO LAYOUT
  ==================================================
*/

#studio {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  min-height: 0;
}

#top {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 65px;
  min-height: 65px;
  padding: 9px 13px;
  background: #172238;
  border-bottom: 1px solid var(--line);
}

.brand {
  min-width: 138px;
  font-size: 20px;
  font-weight: 900;
  letter-spacing: -.5px;
}

.brand small {
  display: block;
  font-size: 10px;
  font-weight: normal;
  color: #9bb2d0;
  margin-top: 4px;
}

.filebar {
  display: flex;
  align-items: center;
  gap: 7px;
  flex: 1;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: thin;
}

.field {
  background: #0e192b;
  border: 1px solid #516784;
  border-radius: 7px;
  color: #fff;
  padding: 9px 10px;
  min-width: 0;
  outline: none;
  font-size: 12px;
}

.field:focus {
  border-color: var(--blue);
}

#artName {
  flex: 1 0 130px;
}

#savedSelect {
  flex: 1 0 150px;
}

/*
  ==================================================
  SETTINGS BAR
  ==================================================
*/

#settings {
  display: flex;
  align-items: center;
  gap: 12px;
  overflow-x: auto;
  overflow-y: hidden;
  flex: 0 0 51px;
  min-height: 51px;
  padding: 8px 13px;
  background: #1e2a40;
  border-bottom: 1px solid var(--line);
  scrollbar-width: thin;
}

.setting {
  display: flex;
  align-items: center;
  gap: 7px;
  flex: none;
  color: #becfe5;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.setting input[type=range] {
  width: 95px;
  accent-color: var(--green);
}

.setting output {
  min-width: 31px;
  text-align: right;
  color: #ffdf96;
}

.setting input[type=checkbox] {
  accent-color: var(--green);
}

.setting input[type=color] {
  width: 35px;
  height: 31px;
  padding: 2px;
  border: 1px solid #748ba9;
  border-radius: 6px;
  background: #16233a;
}

.separator {
  width: 1px;
  height: 29px;
  background: var(--line);
  flex: none;
}

/*
  ==================================================
  WORKSPACE
  ==================================================
*/

#workspace {
  display: flex;
  flex: 1;
  min-height: 0;
  min-width: 0;
}

/*
  ==================================================
  SIDEBAR
  ==================================================
*/

#sidebar {
  width: 205px;
  flex: 0 0 205px;
  padding: 12px;
  background: #172238;
  border-right: 1px solid var(--line);
  overflow-y: auto;
  scrollbar-width: thin;
}

.side-title {
  font-size: 10px;
  letter-spacing: 1.2px;
  font-weight: 900;
  color: #9eb5d2;
  margin: 5px 0 10px;
}

.tool-grid,
.object-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.tool {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 4px;
  min-height: 56px;
  background: #263752;
  border: 1px solid #47607e;
  border-radius: 9px;
  color: #dae6f6;
}

.tool:hover {
  background: #344d6f;
}

.tool.active {
  border-color: #64f0b0;
  background: #245e4c;
  box-shadow: inset 0 0 0 1px #64f0b0;
}

.tool .symbol {
  font-size: 20px;
}

.tool .name {
  font-size: 10px;
  font-weight: 900;
}

.side-line {
  height: 1px;
  background: var(--line);
  margin: 17px 0;
}

/*
  ==================================================
  COLOR PALETTE
  ==================================================
*/

#palette {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
}

.swatch {
  border-radius: 7px;
  border: 2px solid #fff5;
  aspect-ratio: 1;
  position: relative;
  padding: 0;
}

.swatch.active {
  border-color: #fff;
  outline: 2px solid #69e0ff;
  outline-offset: 1px;
}

.swatch.active:after {
  content: '✓';
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-weight: 900;
  color: #fff;
  text-shadow: 0 1px 5px #000;
}

.color-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 11px;
}

.color-row input {
  width: 45px;
  height: 38px;
  padding: 3px;
  border: 1px solid #748bab;
  border-radius: 7px;
  background: #20334f;
}

.color-preview {
  width: 31px;
  height: 31px;
  border: 2px solid white;
  border-radius: 6px;
  background: #222;
}

.color-caption {
  font-size: 10px;
  color: #b9c9df;
  line-height: 1.5;
}

.color-caption strong {
  font-family: Consolas, monospace;
  color: #eaf5ff;
}

.side-help {
  font-size: 11px;
  line-height: 1.7;
  color: #b8cce3;
}

.object-actions .btn {
  padding: 9px 3px;
  font-size: 10px;
}

/*
  ==================================================
  CANVAS AREA
  ==================================================
*/

#stage {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  min-width: 0;
  min-height: 0;
  padding: 14px;
  overflow: auto;
  background-color: #202c42;
  background-image:
    linear-gradient(
      45deg,
      #273650 25%,
      transparent 25%
    ),
    linear-gradient(
      -45deg,
      #273650 25%,
      transparent 25%
    ),
    linear-gradient(
      45deg,
      transparent 75%,
      #273650 75%
    ),
    linear-gradient(
      -45deg,
      transparent 75%,
      #273650 75%
    );
  background-size: 24px 24px;
  background-position:
    0 0,
    0 12px,
    12px -12px,
    -12px 0;
}

#paper {
  position: relative;
  flex: 0 1 auto;
  width: min(
    100%,
    calc((100dvh - 180px) * 1.724138)
  );
  max-width: 100%;
  max-height: 100%;
  aspect-ratio: 1000 / 580;
  background: white;
  border: 1px solid #9eabc1;
  box-shadow: 0 18px 46px #0008;
  overflow: hidden;
}

#artCanvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: crosshair;
}

/*
  ==================================================
  STATUS
  ==================================================
*/

#status {
  flex: 0 0 30px;
  min-height: 30px;
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  padding: 0 13px;
  background: #152037;
  border-top: 1px solid var(--line);
  color: #aec2dc;
  font-size: 11px;
}

#statusText {
  flex: 1;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

#docState {
  white-space: nowrap;
}

#storageState {
  white-space: nowrap;
  color: #95efbf;
}

/*
  ==================================================
  TEXT DIALOG
  ==================================================
*/

#modal {
  display: none;
  position: absolute;
  inset: 0;
  z-index: 20;
  align-items: center;
  justify-content: center;
  background: #071020cf;
  backdrop-filter: blur(4px);
  padding: 16px;
}

#modal.open {
  display: flex;
}

.modal-card {
  width: min(480px, 96%);
  max-height: 96%;
  overflow-y: auto;
  background: #1a2840;
  border: 1px solid #7186aa;
  border-radius: 18px;
  padding: 26px;
  box-shadow: 0 25px 70px #0009;
}

.modal-card h2 {
  margin: 0 0 7px;
  font-size: 24px;
}

.modal-card p {
  margin: 0 0 17px;
  color: #b2c7df;
  line-height: 1.55;
  font-size: 13px;
}

.modal-card textarea {
  width: 100%;
  min-height: 110px;
  resize: vertical;
  border-radius: 9px;
  border: 1px solid #7085a3;
  background: #101b2d;
  color: white;
  padding: 12px;
  outline: 0;
}

.modal-controls {
  display: flex;
  gap: 14px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 12px;
}

.modal-controls label {
  font-size: 12px;
  color: #d1e0f2;
}

.modal-controls input[type=number] {
  width: 78px;
  padding: 7px;
  border: 1px solid #6e83a3;
  border-radius: 6px;
  background: #101b2d;
  color: white;
}

.modal-actions {
  display: flex;
  gap: 9px;
  justify-content: flex-end;
  margin-top: 20px;
}

/*
  ==================================================
  NOTIFICATIONS
  ==================================================
*/

#toast {
  position: absolute;
  z-index: 30;
  left: 50%;
  bottom: 43px;
  transform: translateX(-50%);
  padding: 11px 18px;
  max-width: 85%;
  background: #0d1c30f2;
  border: 1px solid #6eedb2;
  border-radius: 10px;
  color: white;
  text-align: center;
  font-size: 12px;
  font-weight: 800;
  pointer-events: none;
  opacity: 0;
  transition: opacity .2s;
}

#toast.show {
  opacity: 1;
}

/*
  ==================================================
  RESPONSIVE DESIGN
  ==================================================
*/

@media (max-width: 900px) {
  #top {
    flex-basis: 52px;
    min-height: 52px;
    padding: 5px;
    gap: 5px;
  }

  .brand {
    min-width: 100px;
    font-size: 14px;
  }

  .brand small {
    font-size: 8px;
  }

  .btn {
    font-size: 10px;
    padding: 7px 8px;
  }

  .field {
    font-size: 10px;
    padding: 7px;
  }

  #settings {
    flex-basis: 44px;
    min-height: 44px;
    padding: 5px;
  }

  #sidebar {
    width: 156px;
    flex-basis: 156px;
    padding: 8px;
  }

  .tool {
    min-height: 42px;
  }

  .tool .symbol {
    font-size: 15px;
  }

  .tool .name {
    font-size: 9px;
  }

  #stage {
    padding: 6px;
  }

  #paper {
    width: min(
      100%,
      calc((100dvh - 160px) * 1.724138)
    );
  }
}

@media (max-width: 600px) {
  .brand {
    display: none;
  }

  #sidebar {
    width: 105px;
    flex-basis: 105px;
    padding: 5px;
  }

  .tool-grid,
  #palette,
  .object-actions {
    gap: 3px;
  }

  .tool {
    min-height: 37px;
  }

  .tool .symbol {
    font-size: 14px;
  }

  .tool .name,
  .side-title {
    font-size: 8px;
  }

  .color-caption,
  .side-help {
    font-size: 9px;
  }

  .color-row {
    gap: 3px;
  }

  .color-preview {
    display: none;
  }

  .color-row input {
    width: 30px;
  }

  .object-actions .btn {
    font-size: 8px;
  }

  .side-line {
    margin: 10px 0;
  }

  #status {
    font-size: 9px;
    padding: 0 5px;
  }

  .land-features {
    font-size: 11px;
  }
}
