/* ==========================================
   OLED DARK MODE RESET & MODERN CSS VARIABLES
   ========================================== */
:root {
  --bg-main: #0b141a;
  --bg-surface: #202c33;
  --bg-card: #111b21;
  --bg-card-hover: #202c33;
  --bg-input: #2a3942;
  --border-color: #222d34;
  --border-subtle: #182229;
  --accent-cyan: #00a884;
  --accent-blue: #00a884;
  --accent-glow: rgba(0, 168, 132, 0.25);
  --danger-red: #ef4444;
  --success-green: #00a884;
  --text-main: #e9edef;
  --text-muted: #8696a0;
  --text-dim: #667781;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

input, textarea {
  user-select: auto;
}

html, body {
  width: 100%;
  height: var(--app-height, 100dvh);
  margin: 0;
  padding: 0;
  background-color: var(--bg-main);
  color: var(--text-main);
  font-family: var(--font-sans);
  overflow: hidden;
  position: fixed;
  inset: 0;
  overscroll-behavior: none;
  -webkit-overflow-scrolling: auto;
}

.app-container {
  width: 100%;
  height: var(--app-height, 100dvh);
  max-height: var(--app-height, 100dvh);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

.view {
  width: 100%;
  height: var(--app-height, 100dvh);
  max-height: var(--app-height, 100dvh);
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  background-color: var(--bg-main);
  transition: opacity 0.2s ease, transform 0.2s ease;
  overflow: hidden;
  z-index: 1;
}

.view.hidden {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.99);
  visibility: hidden;
  z-index: 0;
}

.view.active {
  opacity: 1;
  pointer-events: auto;
  transform: scale(1);
  visibility: visible;
  z-index: 10;
}

.hidden {
  display: none !important;
}

/* ==========================================
   3-PUNKTE OVERFLOW DROPDOWN MENÜ
   ========================================== */
.overflow-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  width: 220px;
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  z-index: 100;
  transition: opacity 0.15s ease, transform 0.15s ease;
  transform-origin: top right;
}

.overflow-dropdown.hidden {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.95);
  visibility: hidden;
  display: none;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-size: 0.92rem;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: background-color 0.15s ease;
  width: 100%;
}

.dropdown-item:hover {
  background-color: var(--bg-card-hover);
}

.dropdown-divider {
  height: 1px;
  background-color: var(--border-color);
  margin: 4px 0;
}

/* ==========================================
   VIEW 1: CALCULATOR DISGUISE
   ========================================== */
#calculator-view {
  justify-content: center;
  align-items: center;
  background-color: var(--bg-main);
  padding: env(safe-area-inset-top, 16px) 16px env(safe-area-inset-bottom, 16px) 16px;
}

.calculator-wrapper {
  width: 100%;
  max-width: 380px;
  height: 100%;
  max-height: 720px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding-bottom: 12px;
}

.calc-display-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: flex-end;
  padding: 16px 12px;
  word-break: break-all;
}

.calc-history {
  font-size: 1.1rem;
  color: var(--text-dim);
  font-family: var(--font-mono);
  min-height: 1.5rem;
  margin-bottom: 4px;
}

.calc-display {
  font-size: 3.5rem;
  font-weight: 300;
  color: var(--text-main);
  font-family: var(--font-sans);
  line-height: 1.1;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: font-size 0.1s ease;
}

.calc-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.calc-btn {
  aspect-ratio: 1;
  border-radius: var(--radius-full);
  border: none;
  outline: none;
  font-size: 1.6rem;
  font-weight: 400;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  transition: filter 0.15s ease, transform 0.1s ease;
  position: relative;
}

.calc-btn:active {
  filter: brightness(1.3);
  transform: scale(0.95);
}

.btn-num {
  background-color: #333333;
  color: var(--text-main);
}

.btn-func {
  background-color: #a5a5a5;
  color: #000000;
  font-weight: 500;
}

.btn-op {
  background-color: #ff9f0a;
  color: #ffffff;
  font-size: 1.8rem;
}

.btn-equals {
  background-color: var(--accent-cyan);
  color: #000000;
  font-weight: 600;
  font-size: 1.8rem;
}

/* ==========================================
   CALCULATOR HISTORY DRAWER OVERLAY
   ========================================== */
.calc-history-drawer {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(11, 20, 26, 0.96);
  backdrop-filter: blur(12px);
  z-index: 110;
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top, 16px) 16px env(safe-area-inset-bottom, 16px) 16px;
  animation: slideInDown 0.2s ease;
}

.calc-history-drawer.hidden {
  display: none !important;
}

.calc-history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 4px;
  border-bottom: 1px solid var(--border-color);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-main);
}

.calc-history-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px 4px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.calc-history-item {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  transition: background-color 0.15s ease;
}

.calc-history-item:hover {
  background-color: var(--bg-card);
}

.calc-history-expr {
  font-size: 0.9rem;
  color: var(--text-dim);
  font-family: var(--font-mono);
}

.calc-history-res {
  font-size: 1.4rem;
  font-weight: 500;
  color: var(--text-main);
  font-family: var(--font-sans);
}

@keyframes slideInDown {
  from {
    transform: translateY(-100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}
